Skip to content

Commit

Permalink
Handle EINTR and EAGAIN in babel_send.
Browse files Browse the repository at this point in the history
  • Loading branch information
Juliusz Chroboczek committed Mar 16, 2008
1 parent 0469965 commit f944e01
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions net.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ THE SOFTWARE.
#include <netinet/in.h>
#include <errno.h>

#include "babel.h"
#include "util.h"
#include "net.h"

int
Expand Down Expand Up @@ -126,6 +128,19 @@ babel_send(int s,
msg.msg_namelen = slen;
msg.msg_iov = iovec;
msg.msg_iovlen = 2;

again:
rc = sendmsg(s, &msg, 0);
if(rc < 0) {
if(errno == EINTR)
goto again;
else if(errno == EAGAIN) {
int rc2;
rc2 = wait_for_fd(1, s, 5);
if(rc2 > 0)
goto again;
errno = EAGAIN;
}
}
return rc;
}

0 comments on commit f944e01

Please sign in to comment.