projects
/
paraslash.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Replace gettimeofday() by clock_gettime().
[paraslash.git]
/
command.c
diff --git
a/command.c
b/command.c
index 7b474ab1e9337c85dfc5db7b1a997a0c81e59da0..ec822c82978d78649b6641d2206f41db44ab3bd7 100644
(file)
--- a/
command.c
+++ b/
command.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (C) 1997-201
2
Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 1997-201
3
Andre Noll <maan@systemlinux.org>
*
* Licensed under the GPL v2. For licencing details see COPYING.
*/
*
* Licensed under the GPL v2. For licencing details see COPYING.
*/
@@
-8,7
+8,6
@@
#include <regex.h>
#include <signal.h>
#include <regex.h>
#include <signal.h>
-#include <sys/time.h>
#include <sys/types.h>
#include <osl.h>
#include <sys/types.h>
#include <osl.h>
@@
-36,6
+35,9
@@
#include "signal.h"
#include "version.h"
#include "signal.h"
#include "version.h"
+struct server_command afs_cmds[] = {DEFINE_AFS_CMD_ARRAY};
+struct server_command server_cmds[] = {DEFINE_SERVER_CMD_ARRAY};
+
/** Commands including options must be shorter than this. */
#define MAX_COMMAND_LEN 32768
/** Commands including options must be shorter than this. */
#define MAX_COMMAND_LEN 32768
@@
-121,7
+123,7
@@
static unsigned get_status(struct misc_meta_data *nmmd, int parser_friendly,
localtime_r(&nmmd->mtime, &mtime_tm);
strftime(mtime, 29, "%b %d %Y", &mtime_tm);
}
localtime_r(&nmmd->mtime, &mtime_tm);
strftime(mtime, 29, "%b %d %Y", &mtime_tm);
}
-
gettimeofday(¤t_time, NULL
);
+
clock_get_realtime(¤t_time
);
/*
* The calls to WRITE_STATUS_ITEM() below never fail because
* b->max_size is zero (unlimited), see para_printf(). However, clang
/*
* The calls to WRITE_STATUS_ITEM() below never fail because
* b->max_size is zero (unlimited), see para_printf(). However, clang
@@
-256,6
+258,14
@@
__printf_3_4 int send_sb_va(struct stream_cipher_context *scc, int band,
return send_sb(scc, msg, ret, band, false);
}
return send_sb(scc, msg, ret, band, false);
}
+/**
+ * Send an error message to a client.
+ *
+ * \param cc Client info.
+ * \param err The (positive) error code.
+ *
+ * \return The return value of the underlying call to send_sb_va().
+ */
int send_strerror(struct command_context *cc, int err)
{
return cc->use_sideband?
int send_strerror(struct command_context *cc, int err)
{
return cc->use_sideband?
@@
-314,7
+324,7
@@
fail:
return ret;
}
return ret;
}
-int com_sender(struct command_context *cc)
+
static
int com_sender(struct command_context *cc)
{
int i, ret = 0;
char *msg = NULL;
{
int i, ret = 0;
char *msg = NULL;
@@
-371,7
+381,7
@@
int com_sender(struct command_context *cc)
}
/* server info */
}
/* server info */
-int com_si(struct command_context *cc)
+
static
int com_si(struct command_context *cc)
{
int i, ret;
char *msg, *ut, *sender_info = NULL;
{
int i, ret;
char *msg, *ut, *sender_info = NULL;
@@
-400,7
+410,7
@@
int com_si(struct command_context *cc)
mmd->num_commands,
mmd->num_connects,
conf.loglevel_arg,
mmd->num_commands,
mmd->num_connects,
conf.loglevel_arg,
-
SERVER_AUDIO_FORMAT
S,
+
AUDIO_FORMAT_HANDLER
S,
sender_info
);
mutex_unlock(mmd_mutex);
sender_info
);
mutex_unlock(mmd_mutex);
@@
-414,7
+424,7
@@
int com_si(struct command_context *cc)
}
/* version */
}
/* version */
-int com_version(struct command_context *cc)
+
static
int com_version(struct command_context *cc)
{
char *msg;
size_t len;
{
char *msg;
size_t len;
@@
-495,7
+505,7
@@
out:
#undef EMPTY_STATUS_ITEMS
/* stat */
#undef EMPTY_STATUS_ITEMS
/* stat */
-int com_stat(struct command_context *cc)
+
static
int com_stat(struct command_context *cc)
{
int i, ret;
struct misc_meta_data tmp, *nmmd = &tmp;
{
int i, ret;
struct misc_meta_data tmp, *nmmd = &tmp;
@@
-605,7
+615,7
@@
static struct server_command *get_cmd_ptr(const char *name, char **handler)
}
/* help */
}
/* help */
-int com_help(struct command_context *cc)
+
static
int com_help(struct command_context *cc)
{
struct server_command *cmd;
char *perms, *handler, *buf;
{
struct server_command *cmd;
char *perms, *handler, *buf;
@@
-644,7
+654,7
@@
int com_help(struct command_context *cc)
}
/* hup */
}
/* hup */
-int com_hup(struct command_context *cc)
+
static
int com_hup(struct command_context *cc)
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
@@
-653,7
+663,7
@@
int com_hup(struct command_context *cc)
}
/* term */
}
/* term */
-int com_term(struct command_context *cc)
+
static
int com_term(struct command_context *cc)
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
@@
-661,7
+671,7
@@
int com_term(struct command_context *cc)
return 1;
}
return 1;
}
-int com_play(struct command_context *cc)
+
static
int com_play(struct command_context *cc)
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
@@
-673,7
+683,7
@@
int com_play(struct command_context *cc)
}
/* stop */
}
/* stop */
-int com_stop(struct command_context *cc)
+
static
int com_stop(struct command_context *cc)
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
@@
-686,7
+696,7
@@
int com_stop(struct command_context *cc)
}
/* pause */
}
/* pause */
-int com_pause(struct command_context *cc)
+
static
int com_pause(struct command_context *cc)
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
@@
-701,7
+711,7
@@
int com_pause(struct command_context *cc)
}
/* next */
}
/* next */
-int com_next(struct command_context *cc)
+
static
int com_next(struct command_context *cc)
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
@@
-713,7
+723,7
@@
int com_next(struct command_context *cc)
}
/* nomore */
}
/* nomore */
-int com_nomore(struct command_context *cc)
+
static
int com_nomore(struct command_context *cc)
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
{
if (cc->argc != 1)
return -E_COMMAND_SYNTAX;
@@
-725,7
+735,7
@@
int com_nomore(struct command_context *cc)
}
/* ff */
}
/* ff */
-int com_ff(struct command_context *cc)
+
static
int com_ff(struct command_context *cc)
{
long promille;
int ret, backwards = 0;
{
long promille;
int ret, backwards = 0;
@@
-764,7
+774,7
@@
out:
}
/* jmp */
}
/* jmp */
-int com_jmp(struct command_context *cc)
+
static
int com_jmp(struct command_context *cc)
{
long unsigned int i;
int ret;
{
long unsigned int i;
int ret;
@@
-981,7
+991,7
@@
__noreturn void handle_connect(int fd, const char *peername)
/* send Welcome message */
ret = write_va_buffer(fd, "This is para_server, version "
PACKAGE_VERSION ".\n"
/* send Welcome message */
ret = write_va_buffer(fd, "This is para_server, version "
PACKAGE_VERSION ".\n"
- "Features: sideband
,foo
\n"
+ "Features: sideband\n"
);
if (ret < 0)
goto net_err;
);
if (ret < 0)
goto net_err;
@@
-1100,18
+1110,24
@@
__noreturn void handle_connect(int fd, const char *peername)
if (ret >= 0)
goto out;
err_out:
if (ret >= 0)
goto out;
err_out:
- send_strerror(cc, -ret);
+ if (send_strerror(cc, -ret) >= 0 && cc->use_sideband)
+ send_sb(&cc->scc, NULL, 0, SBD_EXIT__FAILURE, true);
net_err:
PARA_NOTICE_LOG("%s\n", para_strerror(-ret));
out:
free(buf);
free(command);
net_err:
PARA_NOTICE_LOG("%s\n", para_strerror(-ret));
out:
free(buf);
free(command);
- sc_free(cc->scc.recv);
- sc_free(cc->scc.send);
mutex_lock(mmd_mutex);
if (cc->cmd && (cc->cmd->perms & AFS_WRITE) && ret >= 0)
mmd->events++;
mmd->active_connections--;
mutex_unlock(mmd_mutex);
mutex_lock(mmd_mutex);
if (cc->cmd && (cc->cmd->perms & AFS_WRITE) && ret >= 0)
mmd->events++;
mmd->active_connections--;
mutex_unlock(mmd_mutex);
+ if (ret >= 0 && cc->use_sideband) {
+ ret = send_sb(&cc->scc, NULL, 0, SBD_EXIT__SUCCESS, true);
+ if (ret < 0)
+ PARA_NOTICE_LOG("%s\n", para_strerror(-ret));
+ }
+ sc_free(cc->scc.recv);
+ sc_free(cc->scc.send);
exit(ret < 0? EXIT_FAILURE : EXIT_SUCCESS);
}
exit(ret < 0? EXIT_FAILURE : EXIT_SUCCESS);
}