Removed proxying completely and fixed the pthread_join bug revealed in the process

This commit is contained in:
Alex Young
2012-06-12 15:08:07 +01:00
parent 2a71b4e7a4
commit c7525f87dc
7 changed files with 50 additions and 37 deletions

View File

@@ -201,6 +201,7 @@ int tryjoin_client_thread( struct client_tbl_entry *entry, int (*joinfunc)(pthre
int was_closed = 0;
void * status;
int join_errno;
if (entry->thread != 0) {
char s_client_address[64];
@@ -212,8 +213,14 @@ int tryjoin_client_thread( struct client_tbl_entry *entry, int (*joinfunc)(pthre
s_client_address,
64 );
if (joinfunc(entry->thread, &status) != 0) {
FATAL_UNLESS( errno == EBUSY, "Problem with joining thread" );
join_errno = joinfunc(entry->thread, &status);
/* join_errno can legitimately be ESRCH if the thread is
* already dead, but the cluent still needs tidying up. */
if (join_errno != 0 && !entry->client->stopped ) {
FATAL_UNLESS( join_errno == EBUSY,
"Problem with joining thread %p: %s",
entry->thread,
strerror(join_errno) );
}
else {
debug("nbd thread %p exited (%s) with status %ld",
@@ -384,7 +391,7 @@ void accept_nbd_client(
return;
}
debug("nbd thread %d started (%s)", (int) params->nbd_client[slot].thread, s_client_address);
debug("nbd thread %p started (%s)", params->nbd_client[slot].thread, s_client_address);
}
@@ -436,7 +443,7 @@ void server_close_clients( struct server *params )
}
}
for( j = 0; j < MAX_NBD_CLIENTS; j++ ) {
join_client_thread( &params->nbd_client[i] );
join_client_thread( &params->nbd_client[j] );
}
}
@@ -566,7 +573,6 @@ void serve_cleanup(struct server* params,
if (params->server_fd){ close(params->server_fd); }
if (params->control_fd){ close(params->control_fd); }
if (params->control_socket_name){ ; }
if (params->proxy_fd){ close(params->proxy_fd); }
if (params->close_signal) {
self_pipe_destroy( params->close_signal );
@@ -583,10 +589,11 @@ void serve_cleanup(struct server* params,
for (i=0; i < MAX_NBD_CLIENTS; i++) {
void* status;
pthread_t thread_id = params->nbd_client[i].thread;
if (params->nbd_client[i].thread != 0) {
debug("joining thread %d", i);
pthread_join(params->nbd_client[i].thread, &status);
if (thread_id != 0) {
debug("joining thread %p", thread_id);
pthread_join(thread_id, &status);
}
}
}