From: mdw Date: Sun, 12 Oct 2003 14:54:00 +0000 (+0000) Subject: Finish the work. X-Git-Tag: 2.0.4~61 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/mLib/commitdiff_plain/750c61c0cb7cd313a9fb0905e1dd64dc533d58a8 Finish the work. --- diff --git a/conn.c b/conn.c index e734f30..1478fad 100644 --- a/conn.c +++ b/conn.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: conn.c,v 1.8 2003/10/12 14:47:10 mdw Exp $ + * $Id: conn.c,v 1.9 2003/10/12 14:54:00 mdw Exp $ * * Nonblocking connect handling * @@ -30,6 +30,9 @@ /*----- Revision history --------------------------------------------------* * * $Log: conn.c,v $ + * Revision 1.9 2003/10/12 14:54:00 mdw + * Finish the work. + * * Revision 1.8 2003/10/12 14:47:10 mdw * New interface for messing with preconnected sockets. * @@ -167,10 +170,8 @@ int conn_init(conn *c, sel_state *s, int fd, { int f; - if ((f = fcntl(fd, F_GETFL)) < 0 || fcntl(fd, F_SETFL, f | O_NONBLOCK)) { - close(fd); - return (-1); - } + if ((f = fcntl(fd, F_GETFL)) < 0 || fcntl(fd, F_SETFL, f | O_NONBLOCK)) + goto fail; if (!connect(fd, dst, dsz)) func(fd, p); @@ -179,6 +180,10 @@ int conn_init(conn *c, sel_state *s, int fd, else conn_fd(c, s, fd, func, p); return (0); + +fail: + close(fd); + return (-1); } /* --- @conn_kill@ --- *