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.

71 lines
2.4 KiB

  1. From 631a70f8baff6d26a2a6692ccd368de8d3948bf9 Mon Sep 17 00:00:00 2001
  2. From: Willy Tarreau <w@1wt.eu>
  3. Date: Mon, 7 Jul 2014 21:07:51 +0200
  4. Subject: [PATCH 18/21] BUG/MEDIUM: unix: completely unbind abstract sockets
  5. during a pause()
  6. Abstract namespace sockets ignore the shutdown() call and do not make
  7. it possible to temporarily stop listening. The issue it causes is that
  8. during a soft reload, the new process cannot bind, complaining that the
  9. address is already in use.
  10. This change registers a new pause() function for unix sockets and
  11. completely unbinds the abstract ones since it's possible to rebind
  12. them later. It requires the two previous patches as well as preceeding
  13. fixes.
  14. This fix should be backported into 1.5 since the issue apperas there.
  15. (cherry picked from commit fd0e008d9d4db2f860b739bd28f6cd31d9aaf2b5)
  16. ---
  17. include/proto/proto_uxst.h | 1 +
  18. src/proto_uxst.c | 15 +++++++++++++++
  19. 2 files changed, 16 insertions(+)
  20. diff --git a/include/proto/proto_uxst.h b/include/proto/proto_uxst.h
  21. index 9422ea7..8e796ec 100644
  22. --- a/include/proto/proto_uxst.h
  23. +++ b/include/proto/proto_uxst.h
  24. @@ -27,6 +27,7 @@
  25. #include <types/task.h>
  26. void uxst_add_listener(struct listener *listener);
  27. +int uxst_pause_listener(struct listener *l);
  28. int uxst_get_src(int fd, struct sockaddr *sa, socklen_t salen, int dir);
  29. int uxst_get_dst(int fd, struct sockaddr *sa, socklen_t salen, int dir);
  30. diff --git a/src/proto_uxst.c b/src/proto_uxst.c
  31. index 409c659..adc1b46 100644
  32. --- a/src/proto_uxst.c
  33. +++ b/src/proto_uxst.c
  34. @@ -68,6 +68,7 @@ static struct protocol proto_unix = {
  35. .disable_all = disable_all_listeners,
  36. .get_src = uxst_get_src,
  37. .get_dst = uxst_get_dst,
  38. + .pause = uxst_pause_listener,
  39. .listeners = LIST_HEAD_INIT(proto_unix.listeners),
  40. .nb_listeners = 0,
  41. };
  42. @@ -373,6 +374,20 @@ void uxst_add_listener(struct listener *listener)
  43. proto_unix.nb_listeners++;
  44. }
  45. +/* Pause a listener. Returns < 0 in case of failure, 0 if the listener
  46. + * was totally stopped, or > 0 if correctly paused. Nothing is done for
  47. + * plain unix sockets since currently it's the new process which handles
  48. + * the renaming. Abstract sockets are completely unbound.
  49. + */
  50. +int uxst_pause_listener(struct listener *l)
  51. +{
  52. + if (((struct sockaddr_un *)&l->addr)->sun_path[0])
  53. + return 1;
  54. +
  55. + unbind_listener(l);
  56. + return 0;
  57. +}
  58. +
  59. /*
  60. * This function initiates a UNIX connection establishment to the target assigned
  61. --
  62. 1.8.5.5