flexnbd client: Catch a few cases where the killswitch wasn't disarmed
This commit is contained in:
21
src/client.c
21
src/client.c
@@ -25,7 +25,7 @@ void client_killswitch_hit(int signal __attribute__ ((unused)), siginfo_t *info,
|
|||||||
|
|
||||||
FATAL_IF(
|
FATAL_IF(
|
||||||
-1 == shutdown( fd, SHUT_RDWR ),
|
-1 == shutdown( fd, SHUT_RDWR ),
|
||||||
"Failed to kill shutdown() the socket, killing the server"
|
SHOW_ERRNO( "Failed to shutdown() the socket, killing the server" )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -577,15 +577,24 @@ int client_serve_request(struct client* client)
|
|||||||
* in general, makes the server respond only to kill -9, and breaks
|
* in general, makes the server respond only to kill -9, and breaks
|
||||||
* outward mirroring in a most unpleasant way.
|
* outward mirroring in a most unpleasant way.
|
||||||
*
|
*
|
||||||
|
* Don't forget to disarm before exiting, no matter what!
|
||||||
|
*
|
||||||
* The replication is simple: open a connection to the flexnbd server, write
|
* The replication is simple: open a connection to the flexnbd server, write
|
||||||
* a single byte, and then wait.
|
* a single byte, and then wait.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
client_arm_killswitch( client );
|
client_arm_killswitch( client );
|
||||||
|
|
||||||
if ( !client_read_request( client, &request, &disconnected ) ) { return stop; }
|
if ( !client_read_request( client, &request, &disconnected ) ) {
|
||||||
if ( disconnected ) { return stop; }
|
client_disarm_killswitch( client );
|
||||||
if ( !client_request_needs_reply( client, request ) ) {
|
return stop;
|
||||||
|
}
|
||||||
|
if ( disconnected ) {
|
||||||
|
client_disarm_killswitch( client );
|
||||||
|
return stop;
|
||||||
|
}
|
||||||
|
if ( !client_request_needs_reply( client, request ) ) {
|
||||||
|
client_disarm_killswitch( client );
|
||||||
return client->disconnect;
|
return client->disconnect;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -597,7 +606,6 @@ int client_serve_request(struct client* client)
|
|||||||
}
|
}
|
||||||
|
|
||||||
client_disarm_killswitch( client );
|
client_disarm_killswitch( client );
|
||||||
|
|
||||||
return stop;
|
return stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -612,6 +620,9 @@ void client_cleanup(struct client* client,
|
|||||||
{
|
{
|
||||||
info("client cleanup for client %p", client);
|
info("client cleanup for client %p", client);
|
||||||
|
|
||||||
|
/* If the thread hits an error, we need to ensure this is off */
|
||||||
|
client_disarm_killswitch( client );
|
||||||
|
|
||||||
if (client->socket) {
|
if (client->socket) {
|
||||||
FATAL_IF_NEGATIVE( close(client->socket),
|
FATAL_IF_NEGATIVE( close(client->socket),
|
||||||
"Error closing client socket %d",
|
"Error closing client socket %d",
|
||||||
|
Reference in New Issue
Block a user