From: Fredrik Tolf Date: Thu, 24 Apr 2008 01:37:02 +0000 (+0200) Subject: Detect errors when writing to sockets. X-Git-Tag: 1.3~11^2^2~14 X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=c7ff7e937c3ccc7713013d423517484df5d259f2;p=doldaconnect.git Detect errors when writing to sockets. --- diff --git a/daemon/net.c b/daemon/net.c index 44974f1..212310a 100644 --- a/daemon/net.c +++ b/daemon/net.c @@ -172,6 +172,7 @@ static struct socket *newsock(int type) struct socket *new; new = smalloc(sizeof(*new)); + memset(new, 0, sizeof(*new)); new->refcount = 2; new->fd = -1; new->isrealsocket = 1; @@ -525,8 +526,12 @@ static void sockflush(struct socket *sk) ret = write(sk->fd, sk->outbuf.s.buf, sk->outbuf.s.datasize); if(ret < 0) { - /* For now, assume transient error, since - * the socket is polled for errors */ + if((errno != EINTR) && (errno != EAGAIN)) + { + if(sk->errcb != NULL) + sk->errcb(sk, errno, sk->data); + closesock(sk); + } break; } if(ret > 0)