Fix broken error checking around pthread functions

This commit is contained in:
Alex Young
2012-06-11 16:08:19 +01:00
parent 5996c8f7ba
commit 2a71b4e7a4
4 changed files with 10 additions and 9 deletions

View File

@@ -179,7 +179,7 @@ int client_read_request( struct client * client , struct nbd_request *out_reques
return 0; /* neat point to close the socket */
}
else {
FATAL_IF_NEGATIVE(-1, "Error reading request");
fatal("Error reading request");
}
}

View File

@@ -258,8 +258,8 @@ int control_mirror(struct control_params* client, int linesc, char** lines)
client->serve->mirror = mirror;
FATAL_IF_NEGATIVE( /* FIXME should free mirror on error */
pthread_create(
FATAL_IF( /* FIXME should free mirror on error */
0 != pthread_create(
&mirror->thread,
NULL,
mirror_runner,
@@ -373,8 +373,8 @@ void accept_control_connection(struct server* params, int client_fd,
control_params->socket = client_fd;
control_params->serve = params;
FATAL_IF_NEGATIVE(
pthread_create(
FATAL_IF(
0 != pthread_create(
&control_thread,
NULL,
control_serve,

View File

@@ -112,11 +112,11 @@ void server_dirty(struct server *serve, off64_t from, int len)
}
#define SERVER_LOCK( s, f, msg ) \
{ NULLCHECK( s ); \
FATAL_IF_NEGATIVE( pthread_mutex_lock( &s->f ), msg ); }
do { NULLCHECK( s ); \
FATAL_IF( 0 != pthread_mutex_lock( &s->f ), msg ); } while (0)
#define SERVER_UNLOCK( s, f, msg ) \
{ NULLCHECK( s ); \
FATAL_IF_NEGATIVE( pthread_mutex_unlock( &s->f ), msg ); }
do { NULLCHECK( s ); \
FATAL_IF( 0 != pthread_mutex_unlock( &s->f ), msg ); } while (0)
void server_lock_io( struct server * serve)
{

View File

@@ -94,6 +94,7 @@ void mylog(int line_level, const char* format, ...);
error_handler(1); \
} while(0)
#define ERROR_IF( test, msg, ... ) do { if ((test)) { error(msg, ##__VA_ARGS__); } } while(0)
#define FATAL_IF( test, msg, ... ) do { if ((test)) { fatal(msg, ##__VA_ARGS__); } } while(0)