Fix for bug #2037: cs_listen failed - is not handled correctly.
[yaz-moved-to-github.git] / src / tcpip.c
index 0e31fc6..8115be7 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: tcpip.c,v 1.38 2007-11-30 11:44:47 adam Exp $
+ * $Id: tcpip.c,v 1.40 2008-01-21 13:07:43 adam Exp $
  */
 /**
  * \file tcpip.c
@@ -720,7 +720,11 @@ int tcpip_listen(COMSTACK h, char *raddr, int *addrlen,
             )
             h->cerrno = CSNODATA;
         else
+        {
+            shutdown(h->iofile, SHUT_RD);
+            listen(h->iofile, SOMAXCONN);
             h->cerrno = CSYSERR;
+        }
         return -1;
     }
     if (addrlen && (size_t) (*addrlen) >= sizeof(struct sockaddr_in))
@@ -820,9 +824,9 @@ COMSTACK tcpip_accept(COMSTACK h)
             state->ssl = SSL_new (state->ctx);
             SSL_set_fd (state->ssl, cnew->iofile);
         }
+#endif
         state->connect_request_buf = 0;
         state->connect_response_buf = 0;
-#endif
         h = cnew;
     }
     if (h->state == CS_ST_ACCEPT)