PERFORCE change 123833 for review
Andrew Turner
andrew at FreeBSD.org
Sat Jul 21 03:49:45 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=123833
Change 123833 by andrew at andrew_hermies on 2007/07/21 03:49:03
When a the communications thread is closed also kill the update thread
Listen to more signals
Affected files ...
.. //depot/projects/soc2007/andrew-update/backend/facund-be.c#15 edit
Differences ...
==== //depot/projects/soc2007/andrew-update/backend/facund-be.c#15 (text+ko) ====
@@ -76,6 +76,7 @@
static struct facund_response *facund_call_restart_services(const char *,
struct facund_object *);
+static int facund_signals[] = { SIGHUP, SIGINT, SIGTERM };
static void facund_signal_handler(int, siginfo_t *, void *);
/*
@@ -152,6 +153,12 @@
/* Add a signal event to check if there was a signal sent */
EV_SET(&event, SIGINT, EVFILT_SIGNAL, EV_ADD, 0, 0, NULL);
kevent(kq, &event, 1, NULL, 0, NULL);
+ for (pos = 0; pos < sizeof(facund_signals) / sizeof(facund_signals[0]);
+ pos++) {
+ EV_SET(&event, facund_signals[pos], EVFILT_SIGNAL, EV_ADD,
+ 0, 0, NULL);
+ kevent(kq, &event, 1, NULL, 0, NULL);
+ }
use_kqueue = 1;
found_updates = 0;
@@ -557,6 +564,7 @@
struct facund_conn *conn;
const char *config_file;
char *basedirs_string, **base_dirs;
+ unsigned int pos;
int config_fd;
properties config_data;
char ch;
@@ -580,10 +588,13 @@
basedirs_string = NULL;
- sa.sa_sigaction = facund_signal_handler;
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = SA_SIGINFO;
- sigaction(SIGINT, &sa, NULL);
+ for (pos = 0; pos < sizeof(facund_signals) / sizeof(facund_signals[0]);
+ pos++) {
+ sa.sa_sigaction = facund_signal_handler;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = SA_SIGINFO;
+ sigaction(facund_signals[pos], &sa, NULL);
+ }
/* Read in the config file */
config_fd = open(config_file, O_RDONLY);
@@ -632,6 +643,11 @@
/* Wait for the threads to quit */
pthread_join(comms_thread, NULL);
+ /*
+ * As the communications thread has quit we should
+ * also kill the update thread so we can exit
+ */
+ pthread_kill(update_thread, SIGINT);
pthread_join(update_thread, NULL);
if (conn != NULL)
More information about the p4-projects
mailing list