From: Fredrik Tolf Date: Fri, 21 Mar 2008 15:01:55 +0000 (+0100) Subject: Fixed some socket leaks. X-Git-Tag: 1.3~11^2~4 X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=834b0aa6ab7b7f167731d2310ba9c4ad0b2d3bf9;p=doldaconnect.git Fixed some socket leaks. --- diff --git a/daemon/net.c b/daemon/net.c index 751c493..9ca222a 100644 --- a/daemon/net.c +++ b/daemon/net.c @@ -975,6 +975,7 @@ static void runbatches(void) nsc = sc->n; if(sc->s->conncb != NULL) sc->s->conncb(sc->s, 0, sc->s->data); + putsock(sc->s); free(sc); } for(sc = rbatch, rbatch = NULL; sc; sc = nsc) { @@ -986,12 +987,14 @@ static void runbatches(void) sc->s->errcb(sc->s, 0, sc->s->data); sc->s->eos = 2; } + putsock(sc->s); free(sc); } for(sc = wbatch, wbatch = NULL; sc; sc = nsc) { nsc = sc->n; if(sc->s->writecb != NULL) sc->s->writecb(sc->s, sc->s->data); + putsock(sc->s); free(sc); } } @@ -1002,7 +1005,7 @@ static void cleansocks(void) for(ufd = ufds; ufd != NULL; ufd = next) { next = ufd->next; - if(ufd->sk && (sockgetdatalen(ufd->sk) == 0)) { + if(ufd->sk && ((ufd->fd < 0) || (sockgetdatalen(ufd->sk) == 0))) { if(ufd->sk->eos == 1) { ufd->sk->eos = 2; closeufd(ufd);