X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=command.c;h=53465e3089d862647e7476228033b3021314d4b7;hp=7b474ab1e9337c85dfc5db7b1a997a0c81e59da0;hb=cad2842e228ab3e42702a05af759ad292b89bed9;hpb=7dc1b56764191dab6aedf360c7a6d648fa49a37c diff --git a/command.c b/command.c index 7b474ab1..53465e30 100644 --- a/command.c +++ b/command.c @@ -36,6 +36,9 @@ #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 @@ -314,7 +317,7 @@ fail: return ret; } -int com_sender(struct command_context *cc) +static int com_sender(struct command_context *cc) { int i, ret = 0; char *msg = NULL; @@ -371,7 +374,7 @@ int com_sender(struct command_context *cc) } /* 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; @@ -414,7 +417,7 @@ int com_si(struct command_context *cc) } /* version */ -int com_version(struct command_context *cc) +static int com_version(struct command_context *cc) { char *msg; size_t len; @@ -495,7 +498,7 @@ out: #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; @@ -605,7 +608,7 @@ static struct server_command *get_cmd_ptr(const char *name, char **handler) } /* help */ -int com_help(struct command_context *cc) +static int com_help(struct command_context *cc) { struct server_command *cmd; char *perms, *handler, *buf; @@ -644,7 +647,7 @@ int com_help(struct command_context *cc) } /* hup */ -int com_hup(struct command_context *cc) +static int com_hup(struct command_context *cc) { if (cc->argc != 1) return -E_COMMAND_SYNTAX; @@ -653,7 +656,7 @@ int com_hup(struct command_context *cc) } /* term */ -int com_term(struct command_context *cc) +static int com_term(struct command_context *cc) { if (cc->argc != 1) return -E_COMMAND_SYNTAX; @@ -661,7 +664,7 @@ int com_term(struct command_context *cc) 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; @@ -673,7 +676,7 @@ int com_play(struct command_context *cc) } /* stop */ -int com_stop(struct command_context *cc) +static int com_stop(struct command_context *cc) { if (cc->argc != 1) return -E_COMMAND_SYNTAX; @@ -686,7 +689,7 @@ int com_stop(struct command_context *cc) } /* pause */ -int com_pause(struct command_context *cc) +static int com_pause(struct command_context *cc) { if (cc->argc != 1) return -E_COMMAND_SYNTAX; @@ -701,7 +704,7 @@ int com_pause(struct command_context *cc) } /* next */ -int com_next(struct command_context *cc) +static int com_next(struct command_context *cc) { if (cc->argc != 1) return -E_COMMAND_SYNTAX; @@ -713,7 +716,7 @@ int com_next(struct command_context *cc) } /* nomore */ -int com_nomore(struct command_context *cc) +static int com_nomore(struct command_context *cc) { if (cc->argc != 1) return -E_COMMAND_SYNTAX; @@ -725,7 +728,7 @@ int com_nomore(struct command_context *cc) } /* ff */ -int com_ff(struct command_context *cc) +static int com_ff(struct command_context *cc) { long promille; int ret, backwards = 0; @@ -764,7 +767,7 @@ out: } /* jmp */ -int com_jmp(struct command_context *cc) +static int com_jmp(struct command_context *cc) { long unsigned int i; int ret; @@ -981,7 +984,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" - "Features: sideband,foo\n" + "Features: sideband\n" ); if (ret < 0) goto net_err; @@ -1100,18 +1103,24 @@ __noreturn void handle_connect(int fd, const char *peername) 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); - 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); + 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); }