diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-05-07 15:22:26 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-05-07 15:22:26 +0200 |
commit | cc578c842e43e15590cc23c1e1eac27bc950a4ad (patch) | |
tree | 3c1548c05bc43970ef8bb90d79aa33f47defcdc5 | |
parent | do not destroy the mutex and condition before we have used to to join with all slaves (diff) | |
download | mds-cc578c842e43e15590cc23c1e1eac27bc950a4ad.tar.gz mds-cc578c842e43e15590cc23c1e1eac27bc950a4ad.tar.bz2 mds-cc578c842e43e15590cc23c1e1eac27bc950a4ad.tar.xz |
m + ignore EINTR when sending a message
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | src/mds-server.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/src/mds-server.c b/src/mds-server.c index 1e3362c..64af077 100644 --- a/src/mds-server.c +++ b/src/mds-server.c @@ -552,7 +552,12 @@ void* slave_loop(void* data) goto reexec; - /* TODO multicast information about the client closing. */ + /* TODO multicast information about the client closing. + "Client closed: %" PRIu32 ":" PRIu32 "%\n" + "\n", + (uint32_t)(information->id >> 32), + (uint32_t)(information->id >> 0) + */ fail: /* The loop does break, this done on success as well. */ @@ -604,7 +609,7 @@ void* slave_loop(void* data) * * @param client The client has sent a message */ -void message_received(client_t* client) /* TODO interceptions */ +void message_received(client_t* client) { mds_message_t message = client->message; int assign_id = 0; @@ -628,7 +633,7 @@ void message_received(client_t* client) /* TODO interceptions */ else if (startswith(h, "Priority: ")) priority = atoll(strstr(h, ": ") + 2); } - /* Ignore message if not labeled with a message ID. */ + /* Ignore message if not labelled with a message ID. */ if (message_id == NULL) { eprint("received message with a message ID, ignoring."); @@ -716,9 +721,14 @@ void message_received(client_t* client) /* TODO interceptions */ } + /* TODO multicast this message */ + + /* Send asigned ID. */ if (assign_id) { + size_t sent; + /* Construct response. */ n = 2 * 10 + strlen(message_id) + 1; n += strlen("ID assignment: :\nIn response to: \n\n"); @@ -737,10 +747,23 @@ void message_received(client_t* client) /* TODO interceptions */ message_id == NULL ? "" : message_id); n = strlen(msgbuf); + + /* TODO multicast msgbuf[:n] */ + + /* Send message. */ with_mutex(client->mutex, - if (send_message(client->socket_fd, msgbuf, n) < n) /* TODO support EINTR */ - perror(*argv); + while (n > 0) + { + sent = send_message(client->socket_fd, msgbuf, n); + if ((sent < n) && (errno != EINTR)) /* Ignore EINTR */ + { + perror(*argv); + break; + } + n -= sent; + msgbuf += sent; + } ); free(msgbuf); } |