You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.5 KiB

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