error handling

This commit is contained in:
John Jones 2017-09-25 17:55:45 -05:00
parent 19acc052dc
commit c56d58f404
2 changed files with 11 additions and 6 deletions

View file

@ -335,6 +335,7 @@ int libp2p_routing_dht_handle_get_value(struct SessionContext* session, struct K
// We need to get the data from the disk
if(!filestore->node_get((unsigned char*)message->key, message->key_size, (void**)&data, &data_size, filestore)) {
libp2p_logger_debug("dht_protocol", "handle_get_value: Unable to get key from filestore\n");
return 0;
}
libp2p_logger_debug("dht_protocol", "handle_get_value: value retrieved from the datastore\n");

View file

@ -654,6 +654,9 @@ int libp2p_secio_receive_protocol(struct SessionContext* session) {
size_t buffer_size = 0;
int retVal = session->default_stream->read(session, &buffer, &buffer_size, numSecs);
if (retVal == 0 || buffer != NULL) {
if (buffer == NULL) {
libp2p_logger_error("secio", "Expected the secio protocol header, but received NULL.\n");
} else {
if (strncmp(protocol, (char*)buffer, strlen(protocol)) == 0) {
free(buffer);
return 1;
@ -662,6 +665,7 @@ int libp2p_secio_receive_protocol(struct SessionContext* session) {
libp2p_logger_error("secio", "Expected the secio protocol header, but received %s.\n", buffer);
}
}
}
if (buffer != NULL)
free(buffer);
return 0;