X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=command.c;h=4eab9f65348990e5f4f95568623f032376a43b4e;hp=379cc4d90044659fa893b22781b4f685f8534bac;hb=cd8aecdb81f2ffb1a6e34a866d6156f8c915a467;hpb=7a0852896a75d852dbd2ac848ec5c0be3b5dea71 diff --git a/command.c b/command.c index 379cc4d9..4eab9f65 100644 --- a/command.c +++ b/command.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1997-2007 Andre Noll + * Copyright (C) 1997-2008 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -20,12 +20,12 @@ #include "afs.h" #include "server.h" #include "vss.h" +#include "list.h" #include "send.h" #include "rc4.h" #include "net.h" #include "daemon.h" #include "fd.h" -#include "list.h" #include "user_list.h" #include "server_command_list.h" #include "afs_command_list.h" @@ -40,8 +40,16 @@ static unsigned char rc4_buf[2 * RC4_KEY_LEN]; extern struct misc_meta_data *mmd; extern struct sender senders[]; -static void dummy(__a_unused int s) -{} +static void dummy(int s) +{ + /* + * At least on Solaris, SIGUSR1 is one-shot, i.e. the signal action is + * restored to the default state once the signal handler has been + * called. + */ + if (s == SIGUSR1) + signal(SIGUSR1, dummy); +} static void mmd_dup(struct misc_meta_data *new_mmd) { @@ -108,7 +116,7 @@ static char *get_status(struct misc_meta_data *nmmd) flags = vss_get_status_flags(nmmd->vss_status_flags); if (nmmd->size) { /* parent currently has an audio file open */ localtime_r(&nmmd->mtime, &mtime_tm); - strftime(mtime, 29, "%a %b %d %Y", &mtime_tm); + strftime(mtime, 29, "%b %d %Y", &mtime_tm); } gettimeofday(&now, NULL); ret = make_message( @@ -234,9 +242,9 @@ int com_sender(int fd, int argc, char * const * argv) if (scd.sender_num < 0) return ret; msg = senders[scd.sender_num].help(); - send_buffer(fd, msg); + ret = send_buffer(fd, msg); free(msg); - return 1; + return ret; } for (i = 0; i < 10; i++) { mmd_lock(); @@ -278,7 +286,7 @@ int com_si(int fd, int argc, __a_unused char * const * argv) "supported senders: %s\n" "%s", ut, mmd->num_played, - getppid(), + (int)getppid(), mmd->active_connections, mmd->num_commands, mmd->num_connects, @@ -301,7 +309,7 @@ int com_version(int fd, int argc, __a_unused char * const * argv) return -E_COMMAND_SYNTAX; return send_buffer(fd, VERSION_TEXT("server") "built: " BUILD_DATE "\n" - SYSTEM ", " CC_VERSION "\n" + UNAME_RS ", " CC_VERSION "\n" ); } @@ -327,7 +335,7 @@ int com_stat(int fd, int argc, char * const * argv) if (ret < 0) goto out; ret = 1; - if (num == 1) + if (num > 0 && !--num) goto out; sleep(50); if (getppid() == 1) @@ -570,7 +578,7 @@ out: */ static int check_perms(unsigned int perms, struct server_command *cmd_ptr) { - PARA_DEBUG_LOG("%s", "checking permissions\n"); + PARA_DEBUG_LOG("checking permissions\n"); return (cmd_ptr->perms & perms) < cmd_ptr->perms ? -E_PERM : 0; } @@ -696,7 +704,6 @@ int handle_connect(int fd, const char *peername) signal(SIGINT, SIG_DFL); signal(SIGTERM, SIG_DFL); signal(SIGHUP, SIG_DFL); - signal(SIGUSR1, SIG_IGN); /* we need a blocking fd here as recv() might return EAGAIN otherwise. */ ret = mark_fd_blocking(fd); @@ -797,9 +804,9 @@ int handle_connect(int fd, const char *peername) goto out; } err_out: - send_va_buffer(fd, "%s\n", PARA_STRERROR(-ret)); + send_va_buffer(fd, "%s\n", para_strerror(-ret)); net_err: - PARA_NOTICE_LOG("%s\n", PARA_STRERROR(-ret)); + PARA_NOTICE_LOG("%s\n", para_strerror(-ret)); ret = EXIT_FAILURE; out: free(command);