Merge branch 'master' into next

This commit is contained in:
Michael Stapelberg 2013-01-09 18:11:17 +01:00
commit fc0e80ee7f
1 changed files with 7 additions and 5 deletions

View File

@ -10,6 +10,7 @@
#include <unistd.h> #include <unistd.h>
#include <stdint.h> #include <stdint.h>
#include <err.h> #include <err.h>
#include <errno.h>
#include <i3/ipc.h> #include <i3/ipc.h>
@ -38,14 +39,15 @@ int ipc_send_message(int sockfd, uint32_t message_size,
memcpy(walk, payload, message_size); memcpy(walk, payload, message_size);
int sent_bytes = 0; int sent_bytes = 0;
int bytes_to_go = buffer_size; while (sent_bytes < buffer_size) {
while (sent_bytes < bytes_to_go) { int n = write(sockfd, msg + sent_bytes, buffer_size - sent_bytes);
int n = write(sockfd, msg + sent_bytes, bytes_to_go); if (n == -1) {
if (n == -1) if (errno == EAGAIN)
continue;
return -1; return -1;
}
sent_bytes += n; sent_bytes += n;
bytes_to_go -= n;
} }
return 0; return 0;