Patch 3: Adds a HUP signal handler to ietd.c and keeps a copy of the
configuration file location in memory.
diff -upr trunk.orig/usr/ietd.c trunk/usr/ietd.c
--- trunk.orig/usr/ietd.c 2008-09-12 14:21:32.000000000 -0400
+++ trunk/usr/ietd.c 2008-09-12 14:26:56.000000000 -0400
@@ -13,6 +13,7 @@
#include <unistd.h>
#include <getopt.h>
#include <netdb.h>
+#include <signal.h>
#include <sys/poll.h>
#include <sys/socket.h>
@@ -43,6 +44,7 @@ enum {
};
static char* server_address;
+static char* config_file = NULL;
uint16_t server_port = ISCSI_LISTEN_PORT;
static struct pollfd poll_array[POLL_MAX];
@@ -425,6 +427,12 @@ void event_loop(int timeout)
}
}
+void handle_hup_signal(int signum)
+{
+ printf("%s: Reloading configuration\n", program_name);
+ cops->default_load(config_file);
+}
+
int main(int argc, char **argv)
{
int ch, longindex, timeout = -1;
@@ -518,6 +526,11 @@ int main(int argc, char **argv)
dup2(0, 2);
setsid();
}
+
+ if (config) {
+ config_file = malloc(strlen(config) + 1);
+ strncpy(config_file, config, strlen(config));
+ }
cops->init(config, &isns, &isns_ac);
if (isns)
@@ -531,6 +544,10 @@ int main(int argc, char **argv)
if (uid && setuid(uid) < 0)
perror("setuid");
+ if (signal(SIGHUP, handle_hup_signal)) {
+ printf("Can't direct signal HUP to handler.\n");
+ }
+
event_loop(timeout);
return 0;
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/_______________________________________________
Iscsitarget-devel mailing list
Iscsitarget-devel@...
https://lists.sourceforge.net/lists/listinfo/iscsitarget-devel