summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2015-11-06 14:13:53 +0000
committerFrediano Ziglio <fziglio@redhat.com>2015-11-09 10:25:32 +0000
commitcd15fcb6278138be9505814e09cd78bac1e6b4bb (patch)
tree883a0e8abc7ca7cddda165ad168542a103f0b472
parent452edd8f7aa25fc1e69b6c2a747f59f58ab07f32 (diff)
downloadspice-cd15fcb6278138be9505814e09cd78bac1e6b4bb.zip
spice-cd15fcb6278138be9505814e09cd78bac1e6b4bb.tar.gz
spice-cd15fcb6278138be9505814e09cd78bac1e6b4bb.tar.xz
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>
-rw-r--r--server/dispatcher.c6
-rw-r--r--server/red_dispatcher.h32
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.
*/