diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2022-08-26 06:51:36 +0200 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2022-08-26 07:15:45 +0200 |
commit | 03223398b38c550533fb8579b599fa84716d41c4 (patch) | |
tree | 923debb1480997f17f353bb40ed6f0557265bb17 /src/tcp_server.c | |
parent | worker: allow graceful shutdowns (diff) | |
download | cimple-03223398b38c550533fb8579b599fa84716d41c4.tar.gz cimple-03223398b38c550533fb8579b599fa84716d41c4.zip |
fix pthread error handling
pthread functions return positive error codes.
Diffstat (limited to 'src/tcp_server.c')
-rw-r--r-- | src/tcp_server.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/tcp_server.c b/src/tcp_server.c index dc7d47b..e479cd0 100644 --- a/src/tcp_server.c +++ b/src/tcp_server.c @@ -58,29 +58,29 @@ int tcp_server_accept(const struct tcp_server *server, tcp_server_conn_handler h *ctx = (struct child_context){conn_fd, handler, arg}; ret = pthread_attr_init(&child_attr); - if (ret < 0) { - print_errno("pthread_attr_init"); + if (ret) { + pthread_print_errno(ret, "pthread_attr_init"); goto free_ctx; } ret = pthread_attr_setdetachstate(&child_attr, PTHREAD_CREATE_DETACHED); - if (ret < 0) { - print_errno("pthread_attr_setdetachstate"); + if (ret) { + pthread_print_errno(ret, "pthread_attr_setdetachstate"); goto destroy_attr; } ret = pthread_create(&child, &child_attr, connection_thread, ctx); - if (ret < 0) { - print_errno("pthread_create"); + if (ret) { + pthread_print_errno(ret, "pthread_create"); goto destroy_attr; } - pthread_attr_destroy(&child_attr); + pthread_check(pthread_attr_destroy(&child_attr), "pthread_attr_destroy"); return ret; destroy_attr: - pthread_attr_destroy(&child_attr); + pthread_check(pthread_attr_destroy(&child_attr), "pthread_attr_destroy"); free_ctx: free(ctx); |