Move checking for a closed client out of server_lock_io and into client_serve_request
This commit is contained in:
18
src/client.c
18
src/client.c
@@ -298,20 +298,24 @@ int client_serve_request(struct client* client)
|
||||
{
|
||||
struct nbd_request request;
|
||||
int request_err;
|
||||
|
||||
if ( !client_read_request( client, &request ) ) { return 1; }
|
||||
int success = 1;
|
||||
|
||||
if ( !client_read_request( client, &request ) ) { return success; }
|
||||
if ( !client_request_needs_reply( client, request, &request_err ) ) {
|
||||
return request_err;
|
||||
}
|
||||
|
||||
if ( server_lock_io( client->serve ) ){
|
||||
client_reply( client, request );
|
||||
server_unlock_io( client->serve );
|
||||
server_lock_io( client->serve );
|
||||
|
||||
if ( server_detect_closed( client->serve ) ) {
|
||||
success = 0;
|
||||
} else {
|
||||
return 1;
|
||||
client_reply( client, request );
|
||||
}
|
||||
|
||||
return 0;
|
||||
server_unlock_io( client->serve );
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -71,10 +71,7 @@ void* mirror_runner(void* serve_params_uncast)
|
||||
pthread_mutex_lock(&serve->l_accept),
|
||||
"Problem with accept lock"
|
||||
);
|
||||
SERVER_ERROR_ON_FAILURE(
|
||||
pthread_mutex_lock(&serve->l_io),
|
||||
"Problem with I/O lock"
|
||||
);
|
||||
server_lock_io( serve );
|
||||
}
|
||||
|
||||
while (current < serve->size) {
|
||||
@@ -97,11 +94,9 @@ void* mirror_runner(void* serve_params_uncast)
|
||||
* is likely to slow things down but will be
|
||||
* safe.
|
||||
*/
|
||||
if (pass < last_pass)
|
||||
SERVER_ERROR_ON_FAILURE(
|
||||
pthread_mutex_lock(&serve->l_io),
|
||||
"Problem with I/O lock"
|
||||
);
|
||||
if (pass < last_pass) {
|
||||
server_lock_io( serve );
|
||||
}
|
||||
|
||||
/** FIXME: do something useful with bytes/second */
|
||||
|
||||
@@ -117,11 +112,9 @@ void* mirror_runner(void* serve_params_uncast)
|
||||
/* now mark it clean */
|
||||
bitset_clear_range(map, current, run);
|
||||
|
||||
if (pass < last_pass)
|
||||
SERVER_ERROR_ON_FAILURE(
|
||||
pthread_mutex_unlock(&serve->l_io),
|
||||
"Problem with I/O unlock"
|
||||
);
|
||||
if (pass < last_pass) {
|
||||
server_unlock_io( serve );
|
||||
}
|
||||
|
||||
written += run;
|
||||
}
|
||||
@@ -157,10 +150,7 @@ void* mirror_runner(void* serve_params_uncast)
|
||||
pthread_mutex_unlock(&serve->l_accept),
|
||||
"Problem with accept unlock"
|
||||
);
|
||||
SERVER_ERROR_ON_FAILURE(
|
||||
pthread_mutex_unlock(&serve->l_io),
|
||||
"Problem with I/O unlock"
|
||||
);
|
||||
server_unlock_io( serve );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@@ -45,14 +45,6 @@ int server_lock_io( struct server * serve)
|
||||
"Problem with I/O lock"
|
||||
);
|
||||
|
||||
if (server_detect_closed(serve)) {
|
||||
SERVER_ERROR_ON_FAILURE(
|
||||
pthread_mutex_unlock(&serve->l_io),
|
||||
"Problem with I/O unlock"
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user