mirror of
https://github.com/wassname/ray.git
synced 2026-07-21 12:50:45 +08:00
Replace direct calls to recv with read_bytes. (#78)
* Replace direct calls to recv with read_bytes. * Fixes. * Formatting.
This commit is contained in:
committed by
Philipp Moritz
parent
de2dd1f506
commit
61755bc168
+3
-1
@@ -6,6 +6,8 @@
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "io.h"
|
||||
|
||||
/* This is used to define the array of object IDs. */
|
||||
const UT_icd object_id_icd = {sizeof(object_id), NULL, NULL, NULL};
|
||||
|
||||
@@ -20,7 +22,7 @@ unique_id globally_unique_id(void) {
|
||||
LOG_ERROR("Could not generate random number");
|
||||
}
|
||||
unique_id result;
|
||||
read(fd, &result.id[0], UNIQUE_ID_SIZE);
|
||||
CHECK(read_bytes(fd, &result.id[0], UNIQUE_ID_SIZE) >= 0);
|
||||
close(fd);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,16 @@ void process_plasma_notification(event_loop *loop,
|
||||
local_scheduler_state *s = context;
|
||||
/* Read the notification from Plasma. */
|
||||
object_id obj_id;
|
||||
recv(client_sock, (char *) &obj_id, sizeof(obj_id), 0);
|
||||
int error = read_bytes(client_sock, (uint8_t *) &obj_id, sizeof(obj_id));
|
||||
if (error < 0) {
|
||||
/* The store has closed the socket. */
|
||||
LOG_DEBUG(
|
||||
"The plasma store has closed the object notification socket, or some "
|
||||
"other error has occurred.");
|
||||
event_loop_remove_file(loop, client_sock);
|
||||
close(client_sock);
|
||||
return;
|
||||
}
|
||||
handle_object_available(s->scheduler_info, s->scheduler_state, obj_id);
|
||||
}
|
||||
|
||||
|
||||
@@ -1303,15 +1303,16 @@ void process_object_notification(event_loop *loop,
|
||||
plasma_manager_state *state = context;
|
||||
object_id obj_id;
|
||||
/* Read the notification from Plasma. */
|
||||
int n = recv(client_sock, (char *) &obj_id, sizeof(object_id), MSG_WAITALL);
|
||||
if (n == 0) {
|
||||
int error = read_bytes(client_sock, (uint8_t *) &obj_id, sizeof(obj_id));
|
||||
if (error < 0) {
|
||||
/* The store has closed the socket. */
|
||||
LOG_DEBUG("The plasma store has closed the object notification socket.");
|
||||
LOG_DEBUG(
|
||||
"The plasma store has closed the object notification socket, or some "
|
||||
"other error has occurred.");
|
||||
event_loop_remove_file(loop, client_sock);
|
||||
close(client_sock);
|
||||
return;
|
||||
}
|
||||
CHECK(n == sizeof(object_id));
|
||||
/* Add object to locally available object. */
|
||||
/* TODO(pcm): Where is this deallocated? */
|
||||
available_object *entry =
|
||||
|
||||
Reference in New Issue
Block a user