[Exim] [patch] exim 3.21: RST fix

Etusivu
Poista viesti
Vastaa
Lähettäjä: Tim Waugh
Päiväys:  
Vastaanottaja: exim-users
Aihe: [Exim] [patch] exim 3.21: RST fix
This patch (made against 3.13 put which still applies to 3.21)
makes exim read all of the data from identd before closing the socket,
preventing RST packets getting sent back in some situations.

Comments?

Tim.
*/

--- exim-3.13/src/libident/id_close.c.rst    Fri Oct 13 15:25:42 2000
+++ exim-3.13/src/libident/id_close.c    Fri Oct 13 15:37:27 2000
@@ -20,6 +20,39 @@
 {
     int res;


+    shutdown (id->fd, 0);
+    for (;;) {
+        fd_set rs, ws, es;
+        struct timeval timeout;
+
+        FD_ZERO (&rs);
+        FD_ZERO (&ws);
+        FD_ZERO (&es);
+
+        FD_SET (id->fd, &rs);
+        FD_SET (id->fd, &es);
+
+        timeout.tv_sec = 0;
+        timeout.tv_usec = 0;
+
+#if defined(hpux) || defined(__HP3050) || defined(__HP3050R)
+        if ((res = select (FD_SETSIZE, (int *) &rs, (int *) &ws, (int *) &es, &timeout)) < 0)
+#else
+        if ((res = select (FD_SETSIZE, &rs, &ws, &es, &timeout)) < 0)
+#endif
+            break;
+
+        if (FD_ISSET (id->fd, &es))
+            break;
+
+        if (FD_ISSET (id->fd, &rs)) {
+            char discard[100];
+            if (read (id->fd, discard, sizeof (discard)))
+                continue;
+        }
+
+        break;
+    }
     res = close(id->fd);
     free(id);