/*
- * $Id: afp_dsi.c,v 1.47 2009-10-25 07:18:12 didg Exp $
+ * $Id: afp_dsi.c,v 1.50 2010-02-08 13:39:56 franklahm Exp $
*
* Copyright (c) 1999 Adrian Sun (asun@zoology.washington.edu)
* Copyright (c) 1990,1993 Regents of The University of Michigan.
reload_request = 1;
}
+/* ---------------------------------
+ * SIGINT: enable max_debug LOGging
+ */
+volatile static sig_atomic_t debug_request = 0;
+
+static void afp_dsi_debug(int sig _U_)
+{
+ debug_request = 1;
+}
+
/* ---------------------- */
#ifdef SERVERTEXT
static void afp_dsi_getmesg (int sig _U_)
u_int32_t err, cmd;
u_int8_t function;
struct sigaction action;
- const char *afpcmpstr;
obj->exit = afp_dsi_die;
obj->reply = (int (*)()) dsi_cmdreply;
sigaddset(&action.sa_mask, SIGALRM);
sigaddset(&action.sa_mask, SIGTERM);
sigaddset(&action.sa_mask, SIGUSR1);
+ sigaddset(&action.sa_mask, SIGINT);
#ifdef SERVERTEXT
sigaddset(&action.sa_mask, SIGUSR2);
#endif
sigaddset(&action.sa_mask, SIGALRM);
sigaddset(&action.sa_mask, SIGHUP);
sigaddset(&action.sa_mask, SIGUSR1);
+ sigaddset(&action.sa_mask, SIGINT);
#ifdef SERVERTEXT
sigaddset(&action.sa_mask, SIGUSR2);
#endif
sigaddset(&action.sa_mask, SIGTERM);
sigaddset(&action.sa_mask, SIGUSR1);
sigaddset(&action.sa_mask, SIGHUP);
+ sigaddset(&action.sa_mask, SIGINT);
action.sa_flags = SA_RESTART;
if ( sigaction( SIGUSR2, &action, NULL) < 0 ) {
LOG(log_error, logtype_afpd, "afp_over_dsi: sigaction: %s", strerror(errno) );
sigaddset(&action.sa_mask, SIGALRM);
sigaddset(&action.sa_mask, SIGHUP);
sigaddset(&action.sa_mask, SIGTERM);
+ sigaddset(&action.sa_mask, SIGINT);
#ifdef SERVERTEXT
sigaddset(&action.sa_mask, SIGUSR2);
#endif
afp_dsi_die(EXITERR_SYS);
}
+ /* SIGINT - enable max_debug LOGging to /tmp/afpd.PID.XXXXXX */
+ action.sa_handler = afp_dsi_debug;
+ sigfillset( &action.sa_mask );
+ action.sa_flags = SA_RESTART;
+ if ( sigaction( SIGINT, &action, NULL) < 0 ) {
+ LOG(log_error, logtype_afpd, "afp_over_dsi: sigaction: %s", strerror(errno) );
+ afp_dsi_die(EXITERR_SYS);
+ }
+
#ifndef DEBUGGING
/* tickle handler */
action.sa_handler = alarm_handler;
sigaddset(&action.sa_mask, SIGHUP);
sigaddset(&action.sa_mask, SIGTERM);
sigaddset(&action.sa_mask, SIGUSR1);
+ sigaddset(&action.sa_mask, SIGINT);
#ifdef SERVERTEXT
sigaddset(&action.sa_mask, SIGUSR2);
#endif
child.tickle = 0;
child.flags &= ~CHILD_SLEEPING;
dsi_sleep(dsi, 0); /* wake up */
+
if (reload_request) {
reload_request = 0;
load_volumes(child.obj);
}
+ if (debug_request) {
+ char logstr[50];
+ debug_request = 0;
+
+ /* The first SIGINT enables debugging, the second one kills us */
+ action.sa_handler = afp_dsi_die;
+ sigfillset( &action.sa_mask );
+ action.sa_flags = SA_RESTART;
+ if ( sigaction( SIGINT, &action, NULL ) < 0 ) {
+ LOG(log_error, logtype_afpd, "afp_over_dsi: sigaction: %s", strerror(errno) );
+ afp_dsi_die(EXITERR_SYS);
+ }
+
+ sprintf(logstr, "default log_maxdebug /tmp/afpd.%u.XXXXXX", getpid());
+ setuplog(logstr);
+ }
+
if (cmd == DSIFUNC_TICKLE) {
/* timer is not every 30 seconds anymore, so we don't get killed on the client side. */
if ((child.flags & CHILD_DIE))
dsi->datalen = DSI_DATASIZ;
child.flags |= CHILD_RUNNING;
- afpcmpstr = AfpNum2name(function);
- LOG(log_debug, logtype_afpd, "=> Start AFP command: %s", afpcmpstr);
+ LOG(log_debug, logtype_afpd, "<== Start AFP command: %s", AfpNum2name(function));
err = (*afp_switch[function])(obj,
(char *)&dsi->commands, dsi->cmdlen,
(char *)&dsi->data, &dsi->datalen);
- LOG(log_debug, logtype_afpd, "=> Finished AFP command: %s", afpcmpstr);
+ LOG(log_debug, logtype_afpd, "==> Finished AFP command: %s -> %s",
+ AfpNum2name(function), AfpErr2name(err));
#ifdef FORCE_UIDGID
/* bring everything back to old euid, egid */
if (obj->force_uid)