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.

209 lines
6.5 KiB

  1. From 91b00c2194b728ccd61133cca83f03de3650b674 Mon Sep 17 00:00:00 2001
  2. From: Willy Tarreau <w@1wt.eu>
  3. Date: Tue, 16 Sep 2014 13:41:21 +0200
  4. Subject: [PATCH 10/13] MEDIUM: config: compute the exact bind-process before
  5. listener's maxaccept
  6. This is a continuation of previous patch, the listener's maxaccept is divided
  7. by the number of processes, so it's best if we can swap the two blocks so that
  8. the number of processes is already known when computing the maxaccept value.
  9. (cherry picked from commit 419ead8eca9237f9cc2ec32630d96fde333282ee)
  10. ---
  11. src/cfgparse.c | 156 ++++++++++++++++++++++++++++++---------------------------
  12. 1 file changed, 81 insertions(+), 75 deletions(-)
  13. diff --git a/src/cfgparse.c b/src/cfgparse.c
  14. index d53f69e..f3907bf 100644
  15. --- a/src/cfgparse.c
  16. +++ b/src/cfgparse.c
  17. @@ -6042,12 +6042,11 @@ int check_config_validity()
  18. proxy = next;
  19. }
  20. - while (curproxy != NULL) {
  21. + for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
  22. struct switching_rule *rule;
  23. struct server_rule *srule;
  24. struct sticking_rule *mrule;
  25. struct tcp_rule *trule;
  26. - struct listener *listener;
  27. unsigned int next_id;
  28. int nbproc;
  29. @@ -6115,14 +6114,6 @@ int check_config_validity()
  30. }
  31. }
  32. - /* here, if bind_proc is null, it means no limit, otherwise it's explicit.
  33. - * We now check how many processes the proxy will effectively run on.
  34. - */
  35. -
  36. - nbproc = global.nbproc;
  37. - if (curproxy->bind_proc)
  38. - nbproc = popcount(curproxy->bind_proc & nbits(global.nbproc));
  39. -
  40. if (global.nbproc > 1 && curproxy->table.peers.name) {
  41. Alert("Proxy '%s': peers can't be used in multi-process mode (nbproc > 1).\n",
  42. curproxy->id);
  43. @@ -7005,6 +6996,86 @@ out_uri_auth_compat:
  44. if (curproxy->options2 & PR_O2_RDPC_PRST)
  45. curproxy->be_req_ana |= AN_REQ_PRST_RDP_COOKIE;
  46. }
  47. + }
  48. +
  49. + /***********************************************************/
  50. + /* At this point, target names have already been resolved. */
  51. + /***********************************************************/
  52. +
  53. + /* Check multi-process mode compatibility */
  54. +
  55. + if (global.nbproc > 1 && global.stats_fe) {
  56. + list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) {
  57. + unsigned long mask;
  58. +
  59. + mask = nbits(global.nbproc);
  60. + if (global.stats_fe->bind_proc)
  61. + mask &= global.stats_fe->bind_proc;
  62. +
  63. + if (bind_conf->bind_proc)
  64. + mask &= bind_conf->bind_proc;
  65. +
  66. + /* stop here if more than one process is used */
  67. + if (popcount(mask) > 1)
  68. + break;
  69. + }
  70. + if (&bind_conf->by_fe != &global.stats_fe->conf.bind) {
  71. + Warning("stats socket will not work as expected in multi-process mode (nbproc > 1), you should force process binding globally using 'stats bind-process' or per socket using the 'process' attribute.\n");
  72. + }
  73. + }
  74. +
  75. + /* Make each frontend inherit bind-process from its listeners when not specified. */
  76. + for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
  77. + if (curproxy->bind_proc)
  78. + continue;
  79. +
  80. + list_for_each_entry(bind_conf, &curproxy->conf.bind, by_fe) {
  81. + unsigned long mask;
  82. +
  83. + mask = bind_conf->bind_proc ? bind_conf->bind_proc : ~0UL;
  84. + curproxy->bind_proc |= mask;
  85. + }
  86. +
  87. + if (!curproxy->bind_proc)
  88. + curproxy->bind_proc = ~0UL;
  89. + }
  90. +
  91. + if (global.stats_fe) {
  92. + list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) {
  93. + unsigned long mask;
  94. +
  95. + mask = bind_conf->bind_proc ? bind_conf->bind_proc : ~0UL;
  96. + global.stats_fe->bind_proc |= mask;
  97. + }
  98. + if (!global.stats_fe->bind_proc)
  99. + global.stats_fe->bind_proc = ~0UL;
  100. + }
  101. +
  102. + /* propagate bindings from frontends to backends */
  103. + for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
  104. + if (curproxy->cap & PR_CAP_FE)
  105. + propagate_processes(curproxy, NULL);
  106. + }
  107. +
  108. + /* Bind each unbound backend to all processes when not specified. */
  109. + for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
  110. + if (curproxy->bind_proc)
  111. + continue;
  112. + curproxy->bind_proc = ~0UL;
  113. + }
  114. +
  115. + /*******************************************************/
  116. + /* At this step, all proxies have a non-null bind_proc */
  117. + /*******************************************************/
  118. +
  119. + /* perform the final checks before creating tasks */
  120. +
  121. + for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
  122. + struct listener *listener;
  123. + unsigned int next_id;
  124. + int nbproc;
  125. +
  126. + nbproc = popcount(curproxy->bind_proc & nbits(global.nbproc));
  127. #ifdef USE_OPENSSL
  128. /* Configure SSL for each bind line.
  129. @@ -7149,71 +7220,6 @@ out_uri_auth_compat:
  130. curproxy->id);
  131. cfgerr++;
  132. }
  133. -
  134. - curproxy = curproxy->next;
  135. - }
  136. -
  137. - /* Check multi-process mode compatibility */
  138. - if (global.nbproc > 1 && global.stats_fe) {
  139. - list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) {
  140. - unsigned long mask;
  141. -
  142. - mask = nbits(global.nbproc);
  143. - if (global.stats_fe->bind_proc)
  144. - mask &= global.stats_fe->bind_proc;
  145. -
  146. - if (bind_conf->bind_proc)
  147. - mask &= bind_conf->bind_proc;
  148. -
  149. - /* stop here if more than one process is used */
  150. - if (popcount(mask) > 1)
  151. - break;
  152. - }
  153. - if (&bind_conf->by_fe != &global.stats_fe->conf.bind) {
  154. - Warning("stats socket will not work as expected in multi-process mode (nbproc > 1), you should force process binding globally using 'stats bind-process' or per socket using the 'process' attribute.\n");
  155. - }
  156. - }
  157. -
  158. - /* At this point, target names have already been resolved */
  159. -
  160. - /* Make each frontend inherit bind-process from its listeners when not specified. */
  161. - for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
  162. - if (curproxy->bind_proc)
  163. - continue;
  164. -
  165. - list_for_each_entry(bind_conf, &curproxy->conf.bind, by_fe) {
  166. - unsigned long mask;
  167. -
  168. - mask = bind_conf->bind_proc ? bind_conf->bind_proc : ~0UL;
  169. - curproxy->bind_proc |= mask;
  170. - }
  171. -
  172. - if (!curproxy->bind_proc)
  173. - curproxy->bind_proc = ~0UL;
  174. - }
  175. -
  176. - if (global.stats_fe) {
  177. - list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) {
  178. - unsigned long mask;
  179. -
  180. - mask = bind_conf->bind_proc ? bind_conf->bind_proc : ~0UL;
  181. - global.stats_fe->bind_proc |= mask;
  182. - }
  183. - if (!global.stats_fe->bind_proc)
  184. - global.stats_fe->bind_proc = ~0UL;
  185. - }
  186. -
  187. - /* propagate bindings from frontends to backends */
  188. - for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
  189. - if (curproxy->cap & PR_CAP_FE)
  190. - propagate_processes(curproxy, NULL);
  191. - }
  192. -
  193. - /* Bind each unbound backend to all processes when not specified. */
  194. - for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
  195. - if (curproxy->bind_proc)
  196. - continue;
  197. - curproxy->bind_proc = ~0UL;
  198. }
  199. /* automatically compute fullconn if not set. We must not do it in the
  200. --
  201. 1.8.5.5