chiark / gitweb /
General alignment assumptions and tweaks.
[mLib] / conn.c
diff --git a/conn.c b/conn.c
index 60574288fd405a07e8e1b4e44a8fe1926964d3a4..081b6fce1208d43edbf54af9040caf96dd75b7a6 100644 (file)
--- 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 --- */