From: mdw Date: Sun, 13 Jan 2002 13:28:44 +0000 (+0000) Subject: Rearrange @conn_init@ to be a bit more comprehensible. X-Git-Tag: 2.0.4~87 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/mLib/commitdiff_plain/c9bb3f9e38564a6bce4b4d1bd9b3086c78ef3351 Rearrange @conn_init@ to be a bit more comprehensible. --- diff --git a/conn.c b/conn.c index 6057428..081b6fc 100644 --- a/conn.c +++ b/conn.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: conn.c,v 1.6 2001/06/22 19:35:20 mdw Exp $ + * $Id: conn.c,v 1.7 2002/01/13 13:28:44 mdw Exp $ * * Nonblocking connect handling * @@ -30,6 +30,9 @@ /*----- Revision history --------------------------------------------------* * * $Log: conn.c,v $ + * Revision 1.7 2002/01/13 13:28:44 mdw + * Rearrange @conn_init@ to be a bit more comprehensible. + * * Revision 1.6 2001/06/22 19:35:20 mdw * Interface change to @conn_init@ -- return error rather than calling the * function. This reduces the number of different environments the @@ -141,16 +144,16 @@ int conn_init(conn *c, sel_state *s, int fd, fcntl(fd, F_SETFL, f | O_NONBLOCK)) goto fail; - if (connect(fd, dst, dsz) < 0) { - if (errno != EINPROGRESS) - goto fail; + if (!connect(fd, dst, dsz)) + func(fd, p); + else if (errno != EINPROGRESS) + goto fail; + else { c->func = func; c->p = p; sel_initfile(s, &c->writer, fd, SEL_WRITE, conn_connect, c); sel_addfile(&c->writer); - } else - func(fd, p); - + } return (0); /* --- Something went pear-shaped --- */