00bc9449012778056566b47a485c50cdf0e2623d
[openwrt-packages.git] /
1 commit 14844e448b637fea2770bcb03a43a010c4c8176d
2 Author: Olivier Houchard <ohouchard@haproxy.com>
3 Date:   Thu Sep 27 14:55:34 2018 +0200
4
5     MINOR: threads: Make sure threads_sync_pipe is initialized before using it.
6     
7     thread_want_sync() might be called before thread_sync_init() was called,
8     at least when reading the server state file, as apply_server_state() is called
9     before thread_sync_init(). So make sure the threads_sync_pipe was initialized
10     before writing to it, if it was not, there's no thread, so no need to sync
11     anything anyway, and if we don't check it we'll end up writing a 'S' on
12     stdin.
13     
14     this only applies to 1.8.
15
16 diff --git a/src/hathreads.c b/src/hathreads.c
17 index 97ed31c5..9dba4356 100644
18 --- a/src/hathreads.c
19 +++ b/src/hathreads.c
20 @@ -28,7 +28,7 @@ void thread_sync_io_handler(int fd)
21  #ifdef USE_THREAD
22  
23  static HA_SPINLOCK_T sync_lock;
24 -static int           threads_sync_pipe[2];
25 +static int           threads_sync_pipe[2] = {-1, -1};
26  static unsigned long threads_want_sync = 0;
27  volatile unsigned long threads_want_rdv_mask = 0;
28  volatile unsigned long threads_harmless_mask = 0;
29 @@ -76,7 +76,8 @@ void thread_want_sync()
30         if (all_threads_mask & (all_threads_mask - 1)) {
31                 if (threads_want_sync & tid_bit)
32                         return;
33 -               if (HA_ATOMIC_OR(&threads_want_sync, tid_bit) == tid_bit)
34 +               if (HA_ATOMIC_OR(&threads_want_sync, tid_bit) == tid_bit &&
35 +                   threads_sync_pipe[1] != -1)
36                         shut_your_big_mouth_gcc(write(threads_sync_pipe[1], "S", 1));
37         }
38         else {
git clone https://git.99rst.org/PROJECT