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.

58 lines
2.1 KiB

  1. From 241164a201e03acce363e902fb25e452827211f0 Mon Sep 17 00:00:00 2001
  2. From: Fabian Mauchle <fabian.mauchle@switch.ch>
  3. Date: Mon, 26 Jul 2021 14:12:15 +0200
  4. Subject: [PATCH] fix setstacksize for glibc 2.34 (fix #91)
  5. ---
  6. ChangeLog | 1 +
  7. radsecproxy.c | 10 ++++++++--
  8. radsecproxy.h | 12 +++---------
  9. 3 files changed, 12 insertions(+), 11 deletions(-)
  10. --- a/radsecproxy.c
  11. +++ b/radsecproxy.c
  12. @@ -3031,6 +3031,7 @@ int createpidfile(const char *pidfile) {
  13. int radsecproxy_main(int argc, char **argv) {
  14. pthread_t sigth;
  15. sigset_t sigset;
  16. + size_t stacksize;
  17. struct list_node *entry;
  18. uint8_t foreground = 0, pretend = 0, loglevel = 0;
  19. char *configfile = NULL, *pidfile = NULL;
  20. @@ -3042,8 +3043,13 @@ int radsecproxy_main(int argc, char **ar
  21. if (pthread_attr_init(&pthread_attr))
  22. debugx(1, DBG_ERR, "pthread_attr_init failed");
  23. - if (pthread_attr_setstacksize(&pthread_attr, PTHREAD_STACK_SIZE))
  24. - debugx(1, DBG_ERR, "pthread_attr_setstacksize failed");
  25. +#if defined(PTHREAD_STACK_MIN)
  26. + stacksize = THREAD_STACK_SIZE > PTHREAD_STACK_MIN ? THREAD_STACK_SIZE : PTHREAD_STACK_MIN;
  27. +#else
  28. + stacksize = THREAD_STACK_SIZE;
  29. +#endif
  30. + if (pthread_attr_setstacksize(&pthread_attr, stacksize))
  31. + debug(DBG_WARN, "pthread_attr_setstacksize failed! Using system default. Memory footprint might be increased!");
  32. #if defined(HAVE_MALLOPT)
  33. if (mallopt(M_TRIM_THRESHOLD, 4 * 1024) != 1)
  34. debugx(1, DBG_ERR, "mallopt failed");
  35. --- a/radsecproxy.h
  36. +++ b/radsecproxy.h
  37. @@ -28,15 +28,9 @@
  38. #define STATUS_SERVER_PERIOD 25
  39. #define IDLE_TIMEOUT 300
  40. -/* We want PTHREAD_STACK_SIZE to be 32768, but some platforms
  41. - * have a higher minimum value defined in PTHREAD_STACK_MIN. */
  42. -#define PTHREAD_STACK_SIZE 32768
  43. -#if defined(PTHREAD_STACK_MIN)
  44. -#if PTHREAD_STACK_MIN > PTHREAD_STACK_SIZE
  45. -#undef PTHREAD_STACK_SIZE
  46. -#define PTHREAD_STACK_SIZE PTHREAD_STACK_MIN
  47. -#endif
  48. -#endif
  49. +/* Target value for stack size.
  50. + * Some platforms might define higher minimums in PTHREAD_STACK_MIN. */
  51. +#define THREAD_STACK_SIZE 32768
  52. /* For systems that only support RFC 2292 Socket API, but not RFC 3542
  53. * like Cygwin */