Nullcheck *before* dereferencing.
Also bracketing, replacing a lost comment, and some variable naming.
This commit is contained in:
@@ -412,6 +412,8 @@ void client_reply_to_write( struct client* client, struct nbd_request request )
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
debug("No allocation map, writing directly.");
|
debug("No allocation map, writing directly.");
|
||||||
|
/* If we get cut off partway through reading this data:
|
||||||
|
* */
|
||||||
ERROR_IF_NEGATIVE(
|
ERROR_IF_NEGATIVE(
|
||||||
readloop( client->socket,
|
readloop( client->socket,
|
||||||
client->mapped + request.from,
|
client->mapped + request.from,
|
||||||
|
26
src/serve.c
26
src/serve.c
@@ -757,20 +757,23 @@ void serve_accept_loop(struct server* params)
|
|||||||
while( server_accept( params ) );
|
while( server_accept( params ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void* build_allocation_map_thread(void* params1)
|
void* build_allocation_map_thread(void* serve_uncast)
|
||||||
{
|
{
|
||||||
struct server* params = (struct server*) params1;
|
NULLCHECK(serve_uncast);
|
||||||
int fd = open(params->filename, O_RDONLY);
|
|
||||||
FATAL_IF_NEGATIVE(fd, "Couldn't open %s", params->filename);
|
|
||||||
NULLCHECK(params);
|
|
||||||
|
|
||||||
params->allocation_map = bitset_alloc(params->size,
|
struct server* serve = (struct server*) serve_uncast;
|
||||||
block_allocation_resolution);
|
int fd = open(serve->filename, O_RDONLY);
|
||||||
|
FATAL_IF_NEGATIVE(fd, "Couldn't open %s", serve->filename);
|
||||||
|
|
||||||
if (build_allocation_map(params->allocation_map, fd))
|
serve->allocation_map =
|
||||||
params->allocation_map_built = 1;
|
bitset_alloc(serve->size, block_allocation_resolution);
|
||||||
else
|
|
||||||
warn("Didn't build allocation map for %s", params->filename);
|
if (build_allocation_map(serve->allocation_map, fd)) {
|
||||||
|
serve->allocation_map_built = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
warn("Didn't build allocation map for %s", serve->filename);
|
||||||
|
}
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -805,6 +808,7 @@ void serve_signal_close( struct server * serve )
|
|||||||
self_pipe_signal( serve->close_signal );
|
self_pipe_signal( serve->close_signal );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Block until the server closes the server_fd.
|
/* Block until the server closes the server_fd.
|
||||||
*/
|
*/
|
||||||
void serve_wait_for_close( struct server * serve )
|
void serve_wait_for_close( struct server * serve )
|
||||||
|
Reference in New Issue
Block a user