From 49f9218d330f5842fe24bce79267bd2c5b239df3 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 16 Jun 2014 19:24:17 +0200 Subject: Improve uplink handling, add code to debug thread creation/destruction, change stupid convention of freeDiskSpace returning 0 on error, which is ambiguous to the disk simply being full... --- src/server/server.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/server/server.c') diff --git a/src/server/server.c b/src/server/server.c index f19b4fe..844365b 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -326,7 +326,10 @@ int main(int argc, char *argv[]) // setup rpc //pthread_t thread_rpc; - //pthread_create(&(thread_rpc), NULL, &dnbd3_rpc_mainloop, NULL); + //thread_create(&(thread_rpc), NULL, &dnbd3_rpc_mainloop, NULL); + pthread_attr_t threadAttrs; + pthread_attr_init( &threadAttrs ); + pthread_attr_setdetachstate( &threadAttrs, PTHREAD_CREATE_DETACHED ); memlogf( "[INFO] Server is ready..." ); @@ -372,16 +375,14 @@ int main(int argc, char *argv[]) continue; } - pthread_attr_t threadAttrs; - pthread_attr_init( &threadAttrs ); - pthread_attr_setdetachstate( &threadAttrs, PTHREAD_CREATE_DETACHED ); - if ( 0 != pthread_create( &(dnbd3_client->thread), &threadAttrs, net_client_handler, (void *)(uintptr_t)dnbd3_client ) ) { + if ( 0 != thread_create( &(dnbd3_client->thread), &threadAttrs, net_client_handler, (void *)(uintptr_t)dnbd3_client ) ) { memlogf( "[ERROR] Could not start thread for new client." ); dnbd3_remove_client( dnbd3_client ); dnbd3_client = dnbd3_free_client( dnbd3_client ); continue; } } + pthread_attr_destroy( &threadAttrs ); dnbd3_cleanup(); } -- cgit v1.2.3-55-g7522