From ce5160a39d26a8e7cf0633d0d144436a5156837a Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 19 Aug 2015 13:37:19 +0200 Subject: put full_send in libmdsserver, clients that only has one socket uses a macro to remove the socket parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/mds-clipboard.c | 42 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 31 deletions(-) (limited to 'src/mds-clipboard.c') diff --git a/src/mds-clipboard.c b/src/mds-clipboard.c index 8a52381..cbfed79 100644 --- a/src/mds-clipboard.c +++ b/src/mds-clipboard.c @@ -84,6 +84,17 @@ static clipitem_t* clipboard[CLIPBOARD_LEVELS]; +/** + * Send a full message even if interrupted + * + * @param message:const char* The message to send + * @param length:size_t The length of the message + * @return :int Zero on success, -1 on error + */ +#define full_send(message, length) \ + ((full_send)(socket_fd, message, length)) + + /** * This function will be invoked before `initialise_server` (if not re-exec:ing) * or before `unmarshal_server` (if re-exec:ing) @@ -391,37 +402,6 @@ int master_loop(void) } -/** - * Send a full message even if interrupted - * - * @param message The message to send - * @param length The length of the message - * @return Zero on success, -1 on error - */ -int full_send(const char* message, size_t length) -{ - size_t sent; - - while (length > 0) - { - sent = send_message(socket_fd, message, length); - if (sent > length) - { - eprint("Sent more of a message than exists in the message, aborting."); - return -1; - } - else - fail_if ((sent < length) && (errno != EINTR)); - message += sent; - length -= sent; - } - return 0; - fail: - xperror(*argv); - return -1; -} - - /** * Handle the received message * -- cgit v1.2.3-70-g09d2