try more when writev return EINTR

This commit is contained in:
云风
2012-08-07 15:17:18 +08:00
parent 0afda95801
commit 60cdbf4693
2 changed files with 12 additions and 2 deletions

View File

@@ -1,6 +1,5 @@
#include "mread.h"
#include "ringbuffer.h"
#include "map.h"
#include <sys/epoll.h>
#include <sys/types.h>

View File

@@ -1,6 +1,7 @@
#include "skynet.h"
#include <sys/uio.h>
#include <errno.h>
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>
@@ -20,7 +21,17 @@ _cb(struct skynet_context * context, void * ud, int session, const char * addr,
buffer[1].iov_base = (void *)msg;
buffer[1].iov_len = sz;
writev(fd, buffer, 2);
for (;;) {
int err = writev(fd, buffer, 2);
if (err < 0) {
switch (errno) {
case EAGAIN:
case EINTR:
continue;
}
return;
}
}
}
int