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.

53 lines
2.1 KiB

  1. commit b143711afe833f9824a7372b88ef9435ff240e9a
  2. Author: Willy Tarreau <w@1wt.eu>
  3. Date: Tue Sep 3 18:55:02 2019 +0200
  4. BUG/MEDIUM: check/threads: make external checks run exclusively on thread 1
  5. See GH issues #141 for all the context. In short, registered signal
  6. handlers are not inherited by other threads during startup, which is
  7. normally not a problem, except that we need that the same thread as
  8. the one doing the fork() cleans up the old process using waitpid()
  9. once its death is reported via SIGCHLD, as happens in external checks.
  10. The only simple solution to this at the moment is to make sure that
  11. external checks are exclusively run on the first thread, the one
  12. which registered the signal handlers on startup. It will be far more
  13. than enough anyway given that external checks must not require to be
  14. load balanced on multiple threads! A more complex solution could be
  15. designed over the long term to let each thread deal with all signals
  16. but it sounds overkill.
  17. This must be backported as far as 1.8.
  18. (cherry picked from commit 6dd4ac890b5810b0f0fe81725fda05ad3d052849)
  19. Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
  20. diff --git a/src/checks.c b/src/checks.c
  21. index 7b55abda..b088da2e 100644
  22. --- a/src/checks.c
  23. +++ b/src/checks.c
  24. @@ -2175,7 +2175,7 @@ static struct task *process_chk_proc(struct task *t, void *context, unsigned sho
  25. /* a success was detected */
  26. check_notify_success(check);
  27. }
  28. - task_set_affinity(t, MAX_THREADS_MASK);
  29. + task_set_affinity(t, 1);
  30. check->state &= ~CHK_ST_INPROGRESS;
  31. pid_list_del(check->curpid);
  32. @@ -2423,8 +2423,13 @@ static int start_check_task(struct check *check, int mininter,
  33. int nbcheck, int srvpos)
  34. {
  35. struct task *t;
  36. + unsigned long thread_mask = MAX_THREADS_MASK;
  37. +
  38. + if (check->type == PR_O2_EXT_CHK)
  39. + thread_mask = 1;
  40. +
  41. /* task for the check */
  42. - if ((t = task_new(MAX_THREADS_MASK)) == NULL) {
  43. + if ((t = task_new(thread_mask)) == NULL) {
  44. ha_alert("Starting [%s:%s] check: out of memory.\n",
  45. check->server->proxy->id, check->server->id);
  46. return 0;