From: Fredrik Tolf Date: Fri, 21 Mar 2008 15:05:43 +0000 (+0100) Subject: Return errors directly from sockflush. X-Git-Tag: 1.3~11^2~3 X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=89d650f1e7be2401bcbd7c6a1782d29eaa33c413;p=doldaconnect.git Return errors directly from sockflush. --- diff --git a/daemon/net.c b/daemon/net.c index 9ca222a..7a68dae 100644 --- a/daemon/net.c +++ b/daemon/net.c @@ -704,14 +704,16 @@ static void sockrecv(struct ufd *ufd) } } -static void sockflush(struct ufd *ufd) +static int sockflush(struct ufd *ufd) { int ret; struct dgrambuf *dbuf; int dgram; - if((dgram = ufddgram(ufd)) < 0) - return; + if((dgram = ufddgram(ufd)) < 0) { + errno = EBADFD; + return(-1); + } if(dgram) { dbuf = sockgetdgbuf(ufd->sk); sendto(ufd->fd, dbuf->data, dbuf->size, MSG_DONTWAIT | MSG_NOSIGNAL, dbuf->addr, dbuf->addrlen); @@ -721,16 +723,14 @@ static void sockflush(struct ufd *ufd) ret = send(ufd->fd, ufd->sk->buf.s.buf, ufd->sk->buf.s.datasize, MSG_DONTWAIT | MSG_NOSIGNAL); else ret = write(ufd->fd, ufd->sk->buf.s.buf, ufd->sk->buf.s.datasize); - if(ret < 0) { - /* For now, assume transient error, since - * the socket is polled for errors */ - return; - } + if(ret < 0) + return(-1); if(ret > 0) { memmove(ufd->sk->buf.s.buf, ((char *)ufd->sk->buf.s.buf) + ret, ufd->sk->buf.s.datasize -= ret); sockread(ufd->sk); } } + return(0); } void closesock(struct socket *sk) @@ -1119,8 +1119,13 @@ int pollsocks(int timeout) sockrecv(ufd); if(ufd->fd == -1) continue; - if(FD_ISSET(ufd->fd, &wfds)) - sockflush(ufd); + if(FD_ISSET(ufd->fd, &wfds)) { + if(sockflush(ufd)) { + sockerror(ufd->sk, errno); + closeufd(ufd); + continue; + } + } } } }