diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2018-06-24 23:21:07 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2018-06-24 23:21:07 +0200 |
commit | c39c40f5da4b373bc771362e064dd81d40836fa2 (patch) | |
tree | c66656da368cb570fe81fe537a0d7f08acf0de98 /src | |
parent | cae1514aa299c63b3d8cec88333cfdf82ff16e9b (diff) |
BUG: replaced pthread_detach with pthread_attr_setdetachstate to fix possible SIGSEGVs on ARM platforms
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/redirector.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/redirector.c b/src/redirector.c index b4d7a78..de7e922 100644 --- a/src/redirector.c +++ b/src/redirector.c @@ -42,6 +42,8 @@ static void * client_mainloop(void *arg); static int client_io(event_ctx *ev_ctx, int src_fd, void *user_data); +static pthread_attr_t pattr; + int redirector_init_ctx(redirector_ctx **ctx) { @@ -57,6 +59,12 @@ int redirector_init_ctx(redirector_ctx **ctx) if (fwd_init_ctx(&fwd)) return 1; + if (pthread_attr_init(&pattr)) + return 1; + /* BUG: Do not use pthread_detach in pthread routine! */ + if (pthread_attr_setdetachstate(&pattr, PTHREAD_CREATE_DETACHED)) + return 1; + return 0; } @@ -291,7 +299,7 @@ static int redirector_accept_client(event_ctx *ev_ctx, int fd, void *user_data) rdr_ctx->host_buf, rdr_ctx->service_buf, args->client_sock.fd); - if (pthread_create(&args->self, NULL, + if (pthread_create(&args->self, &pattr, client_mainloop, args)) { E_STRERR("Thread creation for %s:%s on fd %d", @@ -322,7 +330,6 @@ client_mainloop(void *arg) assert(arg); args = (client_thread *) arg; - pthread_detach(args->self); event_init(&ev_ctx); if (event_setup(ev_ctx)) { |