chiark / gitweb /
Do not assume that loop->on_fd is idempotent
authorIan Jackson <ian@chiark.greenend.org.uk>
Sat, 8 May 2010 13:45:05 +0000 (14:45 +0100)
committerIan Jackson <ian@chiark.greenend.org.uk>
Sat, 8 May 2010 13:45:05 +0000 (14:45 +0100)
backends/innduct.c

index 8104fee..29fe5c1 100644 (file)
@@ -511,6 +511,7 @@ struct Conn {
   ISNODE(Conn);
   int fd; /* may be 0, meaning closed (during construction/destruction) */
   oop_read *rd; /* likewise */
+  int oopwriting; /* since on_fd is not idempotent */
   int max_queue, stream;
   const char *quitting;
   int since_activity; /* periods */
@@ -1547,12 +1548,16 @@ static void conn_maybe_write(Conn *conn)  {
     conn_make_some_xmits(conn);
     if (!conn->xmitu) {
       loop->cancel_fd(loop, conn->fd, OOP_WRITE);
+      conn->oopwriting= 0;
       return;
     }
 
     void *rp= conn_write_some_xmits(conn);
     if (rp==OOP_CONTINUE) {
-      loop->on_fd(loop, conn->fd, OOP_WRITE, conn_writeable, conn);
+      if (!conn->oopwriting) {
+       loop->on_fd(loop, conn->fd, OOP_WRITE, conn_writeable, conn);
+       conn->oopwriting= 1;
+      }
       return;
     } else if (rp==OOP_HALT) {
       return;