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.

93 lines
3.2 KiB

  1. From e56c4f1f76c6731a5a0f4b128540071cffeb1951 Mon Sep 17 00:00:00 2001
  2. From: Willy Tarreau <w@1wt.eu>
  3. Date: Tue, 16 Sep 2014 13:21:03 +0200
  4. Subject: [PATCH 09/13] MEDIUM: config: make the frontends automatically bind
  5. to the listeners' processes
  6. When a frontend does not have any bind-process directive, make it
  7. automatically bind to the union of all of its listeners' processes
  8. instead of binding to all processes. That will make it possible to
  9. have the expected behaviour without having to explicitly specify a
  10. bind-process directive.
  11. Note that if the listeners are not bound to a specific process, the
  12. default is still to bind to all processes.
  13. This change could be backported to 1.5 as it simplifies process
  14. management, and was planned to be done during the 1.5 development phase.
  15. (cherry picked from commit b369a045d545b41ef2b250bf747caf83c97e0ca8)
  16. ---
  17. doc/configuration.txt | 4 ++++
  18. src/cfgparse.c | 36 ++++++++++++++++++++++++++++++++++++
  19. 2 files changed, 40 insertions(+)
  20. diff --git a/doc/configuration.txt b/doc/configuration.txt
  21. index 3c75c92..1e32057 100644
  22. --- a/doc/configuration.txt
  23. +++ b/doc/configuration.txt
  24. @@ -1905,6 +1905,10 @@ bind-process [ all | odd | even | <number 1-64>[-<number 1-64>] ] ...
  25. Each "bind" line may further be limited to a subset of the proxy's processes,
  26. please consult the "process" bind keyword in section 5.1.
  27. + When a frontend has no explicit "bind-process" line, it tries to bind to all
  28. + the processes referenced by its "bind" lines. That means that frontends can
  29. + easily adapt to their listeners' processes.
  30. +
  31. If some backends are referenced by frontends bound to other processes, the
  32. backend automatically inherits the frontend's processes.
  33. diff --git a/src/cfgparse.c b/src/cfgparse.c
  34. index b9853ef..d53f69e 100644
  35. --- a/src/cfgparse.c
  36. +++ b/src/cfgparse.c
  37. @@ -7175,11 +7175,47 @@ out_uri_auth_compat:
  38. }
  39. /* At this point, target names have already been resolved */
  40. +
  41. + /* Make each frontend inherit bind-process from its listeners when not specified. */
  42. + for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
  43. + if (curproxy->bind_proc)
  44. + continue;
  45. +
  46. + list_for_each_entry(bind_conf, &curproxy->conf.bind, by_fe) {
  47. + unsigned long mask;
  48. +
  49. + mask = bind_conf->bind_proc ? bind_conf->bind_proc : ~0UL;
  50. + curproxy->bind_proc |= mask;
  51. + }
  52. +
  53. + if (!curproxy->bind_proc)
  54. + curproxy->bind_proc = ~0UL;
  55. + }
  56. +
  57. + if (global.stats_fe) {
  58. + list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) {
  59. + unsigned long mask;
  60. +
  61. + mask = bind_conf->bind_proc ? bind_conf->bind_proc : ~0UL;
  62. + global.stats_fe->bind_proc |= mask;
  63. + }
  64. + if (!global.stats_fe->bind_proc)
  65. + global.stats_fe->bind_proc = ~0UL;
  66. + }
  67. +
  68. + /* propagate bindings from frontends to backends */
  69. for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
  70. if (curproxy->cap & PR_CAP_FE)
  71. propagate_processes(curproxy, NULL);
  72. }
  73. + /* Bind each unbound backend to all processes when not specified. */
  74. + for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
  75. + if (curproxy->bind_proc)
  76. + continue;
  77. + curproxy->bind_proc = ~0UL;
  78. + }
  79. +
  80. /* automatically compute fullconn if not set. We must not do it in the
  81. * loop above because cross-references are not yet fully resolved.
  82. */
  83. --
  84. 1.8.5.5