git-svn: trunk@4816
Török Edvin authored on 2009/02/18 05:05:35... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Tue Feb 17 22:35:53 EET 2009 (edwin) |
|
2 |
+------------------------------------ |
|
3 |
+ * clamd/server-th.c, unit_tests/check_clamd.sh: signals may not wake |
|
4 |
+ a poll(), so make sure thread wakes up (BB #1400). |
|
5 |
+ |
|
1 | 6 |
Tue Feb 17 22:10:48 EET 2009 (edwin) |
2 | 7 |
------------------------------------ |
3 | 8 |
* unit_tests/check_clamd.c: add missing header |
... | ... |
@@ -131,29 +131,38 @@ static void scanner_thread(void *arg) |
131 | 131 |
return; |
132 | 132 |
} |
133 | 133 |
|
134 |
+static int syncpipe_wake_recv_w = -1; |
|
135 |
+ |
|
134 | 136 |
void sighandler_th(int sig) |
135 | 137 |
{ |
138 |
+ int action = 0; |
|
136 | 139 |
switch(sig) { |
137 | 140 |
case SIGINT: |
138 | 141 |
case SIGTERM: |
139 | 142 |
progexit = 1; |
143 |
+ action = 1; |
|
140 | 144 |
break; |
141 | 145 |
|
142 | 146 |
#ifdef SIGHUP |
143 | 147 |
case SIGHUP: |
144 | 148 |
sighup = 1; |
149 |
+ action = 1; |
|
145 | 150 |
break; |
146 | 151 |
#endif |
147 | 152 |
|
148 | 153 |
#ifdef SIGUSR2 |
149 | 154 |
case SIGUSR2: |
150 | 155 |
reload = 1; |
156 |
+ action = 1; |
|
151 | 157 |
break; |
152 | 158 |
#endif |
153 | 159 |
|
154 | 160 |
default: |
155 | 161 |
break; /* Take no action on other signals - e.g. SIGPIPE */ |
156 | 162 |
} |
163 |
+ /* a signal doesn't always wake poll(), for example on FreeBSD */ |
|
164 |
+ if (action && syncpipe_wake_recv_w != -1) |
|
165 |
+ write(syncpipe_wake_recv_w, "", 1); |
|
157 | 166 |
} |
158 | 167 |
|
159 | 168 |
static struct cl_engine *reload_db(struct cl_engine *engine, unsigned int dboptions, const struct optstruct *opts, int do_check, int *ret) |
... | ... |
@@ -787,6 +796,8 @@ int recvloop_th(int *socketds, unsigned nsockets, struct cl_engine *engine, unsi |
787 | 787 |
exit(-1); |
788 | 788 |
} |
789 | 789 |
|
790 |
+ syncpipe_wake_recv_w = acceptdata.syncpipe_wake_recv[1]; |
|
791 |
+ |
|
790 | 792 |
if (fds_add(fds, acceptdata.syncpipe_wake_recv[0], 1, 0) == -1 || |
791 | 793 |
fds_add(&acceptdata.fds, acceptdata.syncpipe_wake_accept[0], 1, 0)) { |
792 | 794 |
logg("!failed to add pipe fd\n"); |