Skip to content

Commit

Permalink
fix setstacksize for glibc 2.34 (fix #91)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabian Mauchle committed Jul 26, 2021
1 parent 6456a93 commit 241164a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ unreleased changes
- Fix small memory leak in config parser
- Fix lazy certificate check when connecting to TLS servers
- Fix connect is aborted if first host in list has invalid certificate
- Fix setstacksize for glibc 2.34 (#91)

2021-05-28 1.9.0
New features:
Expand Down
10 changes: 8 additions & 2 deletions radsecproxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -3033,6 +3033,7 @@ int createpidfile(const char *pidfile) {
int radsecproxy_main(int argc, char **argv) {
pthread_t sigth;
sigset_t sigset;
size_t stacksize;
struct list_node *entry;
uint8_t foreground = 0, pretend = 0, loglevel = 0;
char *configfile = NULL, *pidfile = NULL;
Expand All @@ -3044,8 +3045,13 @@ int radsecproxy_main(int argc, char **argv) {

if (pthread_attr_init(&pthread_attr))
debugx(1, DBG_ERR, "pthread_attr_init failed");
if (pthread_attr_setstacksize(&pthread_attr, PTHREAD_STACK_SIZE))
debugx(1, DBG_ERR, "pthread_attr_setstacksize failed");
#if defined(PTHREAD_STACK_MIN)
stacksize = THREAD_STACK_SIZE > PTHREAD_STACK_MIN ? THREAD_STACK_SIZE : PTHREAD_STACK_MIN;
#else
stacksize = THREAD_STACK_SIZE;
#endif
if (pthread_attr_setstacksize(&pthread_attr, stacksize))
debug(DBG_WARN, "pthread_attr_setstacksize failed! Using system default. Memory footprint might be increased!");
#if defined(HAVE_MALLOPT)
if (mallopt(M_TRIM_THRESHOLD, 4 * 1024) != 1)
debugx(1, DBG_ERR, "mallopt failed");
Expand Down
12 changes: 3 additions & 9 deletions radsecproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,9 @@
#define STATUS_SERVER_PERIOD 25
#define IDLE_TIMEOUT 300

/* We want PTHREAD_STACK_SIZE to be 32768, but some platforms
* have a higher minimum value defined in PTHREAD_STACK_MIN. */
#define PTHREAD_STACK_SIZE 32768
#if defined(PTHREAD_STACK_MIN)
#if PTHREAD_STACK_MIN > PTHREAD_STACK_SIZE
#undef PTHREAD_STACK_SIZE
#define PTHREAD_STACK_SIZE PTHREAD_STACK_MIN
#endif
#endif
/* Target value for stack size.
* Some platforms might define higher minimums in PTHREAD_STACK_MIN. */
#define THREAD_STACK_SIZE 32768

/* For systems that only support RFC 2292 Socket API, but not RFC 3542
* like Cygwin */
Expand Down

0 comments on commit 241164a

Please sign in to comment.