dispatcher: remove receive_data and send_data functions

Use read_safe/write_safe instead which do the same stuff

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
Marc-André Lureau 2015-11-06 14:13:53 +00:00 committed by Frediano Ziglio
parent 452edd8f7a
commit cd15fcb627
2 changed files with 3 additions and 35 deletions

View File

@ -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;
}

View File

@ -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.
*/