/* -*-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
*
/*----- 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
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 --- */