[srvx-commits] CVS: services/src common.h,1.72,1.72.2.1 ioset.c,1.5,1.5.2.1 main.c,1.124,1.124.2.1
Brought to you by:
entrope
|
From: Adrian D. <sai...@us...> - 2002-10-23 04:09:54
|
Update of /cvsroot/srvx/services/src
In directory usw-pr-cvs1:/tmp/cvs-serv7182
Modified Files:
Tag: rel-1_1-branch
common.h ioset.c main.c
Log Message:
Change the signal handlers to mark tasks as needing to be done instead of executing them right away. This is because using malloc(), free(), and many other functions is not safe inside signal handlers.
Index: common.h
===================================================================
RCS file: /cvsroot/srvx/services/src/common.h,v
retrieving revision 1.72
retrieving revision 1.72.2.1
diff -C2 -r1.72 -r1.72.2.1
*** common.h 11 May 2002 02:52:30 -0000 1.72
--- common.h 23 Oct 2002 04:09:51 -0000 1.72.2.1
***************
*** 94,97 ****
--- 94,98 ----
extern time_t now;
extern int quit_services;
+ extern volatile int need_dbwrite, need_rehash;
struct userNode *AddService(const char *nick, const char *desc);
Index: ioset.c
===================================================================
RCS file: /cvsroot/srvx/services/src/ioset.c,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -C2 -r1.5 -r1.5.2.1
*** ioset.c 8 Jun 2002 20:27:37 -0000 1.5
--- ioset.c 23 Oct 2002 04:09:51 -0000 1.5.2.1
***************
*** 43,46 ****
--- 43,47 ----
#include "log.h"
#include "timeq.h"
+ #include "conf.h"
#ifndef IOSET_DEBUG
***************
*** 50,53 ****
--- 51,56 ----
extern int uplink_connect(void);
+ extern char *services_config;
+
static struct io_fd **fds;
static unsigned int fds_size;
***************
*** 197,200 ****
--- 200,217 ----
*/
if (FD_ISSET(nn, &write_fds) && (fd->send_used > 0)) ioset_try_write(fd);
+ }
+
+ /* Rehash if we got a SIGHUP recently */
+ if (need_rehash) {
+ log(MAIN_LOG, LOG_INFO, "Received rehash signal.\n");
+ conf_read(services_config);
+ reopen_logs();
+ need_rehash = 0;
+ }
+ /* Write the DB if we got a SIGINT recently */
+ if (need_dbwrite) {
+ log(MAIN_LOG, LOG_INFO, "Received database write signal.\n");
+ write_databases();
+ need_dbwrite = 0;
}
Index: main.c
===================================================================
RCS file: /cvsroot/srvx/services/src/main.c,v
retrieving revision 1.124
retrieving revision 1.124.2.1
diff -C2 -r1.124 -r1.124.2.1
*** main.c 8 Jun 2002 20:32:44 -0000 1.124
--- main.c 23 Oct 2002 04:09:51 -0000 1.124.2.1
***************
*** 86,89 ****
--- 86,90 ----
int ping_freq = 120, ping_timeout = 30;
int silent, quit_services, max_cycles;
+ volatile int need_dbwrite, need_rehash;
char *services_config = "srvx.conf";
***************
*** 393,402 ****
void sigaction_writedb(int x)
{
! #ifndef HAVE_STRSIGNAL
! log(MAIN_LOG, LOG_INFO, "Signal %d -- writing databases.\n", x);
! #else
! log(MAIN_LOG, LOG_INFO, "%s -- writing databases.\n", strsignal(x));
! #endif
! write_databases();
}
--- 394,399 ----
void sigaction_writedb(int x)
{
! (void)x;
! need_dbwrite = 1;
}
***************
*** 421,431 ****
void sigaction_rehash(int x)
{
! #ifndef HAVE_STRSIGNAL
! log(MAIN_LOG, LOG_INFO, "Signal %d -- rehashing.\n", x);
! #else
! log(MAIN_LOG, LOG_INFO, "%s -- rehashing.\n", strsignal(x));
! #endif
! conf_read(services_config);
! reopen_logs();
}
--- 418,423 ----
void sigaction_rehash(int x)
{
! (void)x;
! need_rehash = 1;
}
|