From: Marc-André Lureau <marcandre.lureau@xxxxxxxxx> Use read_safe/write_safe instead which do the same stuff --- server/dispatcher.c | 6 +++--- server/red_dispatcher.h | 32 -------------------------------- 2 files changed, 3 insertions(+), 35 deletions(-) diff --git a/server/dispatcher.c b/server/dispatcher.c index d334117..945edba 100644 --- a/server/dispatcher.c +++ b/server/dispatcher.c @@ -32,7 +32,6 @@ #include "common/mem.h" #include "common/spice_common.h" #include "dispatcher.h" -#include "red_dispatcher.h" //#define DEBUG_DISPATCHER @@ -203,12 +202,13 @@ unlock: uint32_t dispatcher_read_message(Dispatcher *dispatcher) { - uint32_t message; + uint32_t message = 0; spice_return_val_if_fail(dispatcher, 0); spice_return_val_if_fail(dispatcher->send_fd != -1, 0); - receive_data(dispatcher->send_fd, &message, sizeof(message)); + if (read_safe(dispatcher->send_fd, (uint8_t*)&message, sizeof(message), 1) == -1) + spice_warn_if_reached(); return message; } diff --git a/server/red_dispatcher.h b/server/red_dispatcher.h index fde965d..02337b8 100644 --- a/server/red_dispatcher.h +++ b/server/red_dispatcher.h @@ -45,38 +45,6 @@ void red_dispatcher_client_monitors_config(VDAgentMonitorsConfig *monitors_confi typedef uint32_t RedWorkerMessage; -static inline void send_data(int fd, void *in_buf, int n) -{ - uint8_t *buf = in_buf; - do { - int now; - if ((now = write(fd, buf, n)) == -1) { - if (errno == EINTR) { - continue; - } - spice_error("%s", strerror(errno)); - } - buf += now; - n -= now; - } while (n); -} - -static inline void receive_data(int fd, void *in_buf, int n) -{ - uint8_t *buf = in_buf; - do { - int now; - if ((now = read(fd, buf, n)) == -1) { - if (errno == EINTR) { - continue; - } - spice_error("%s", strerror(errno)); - } - buf += now; - n -= now; - } while (n); -} - /* Keep message order, only append new messages! * Replay code store enum values into save files. */ -- 2.4.3 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel