Add more debugging information to httpd.c
[deb_shairplay.git] / src / lib / httpd.c
index 7606933696e1cb8548dc57e326bd346221a831d5..0f82b261fe34c12e81717fb447acaa33f4170dcb 100644 (file)
@@ -240,7 +240,7 @@ httpd_thread(void *arg)
                                continue;
                        }
                }
-               if (FD_ISSET(httpd->server_fd6, &rfds)) {
+               if (httpd->server_fd6 != -1 && FD_ISSET(httpd->server_fd6, &rfds)) {
                        ret = httpd_accept_connection(httpd, httpd->server_fd6, 1);
                        if (ret == -1) {
                                break;
@@ -311,6 +311,8 @@ httpd_thread(void *arg)
                                        logger_log(httpd->logger, LOGGER_INFO, "Didn't get response");
                                }
                                http_response_destroy(response);
+                       } else {
+                               logger_log(httpd->logger, LOGGER_DEBUG, "Request not complete, waiting for more data...");
                        }
                }
        }
@@ -326,6 +328,16 @@ httpd_thread(void *arg)
                httpd_remove_connection(httpd, connection);
        }
 
+       /* Close server sockets since they are not used any more */
+       if (httpd->server_fd4 != -1) {
+               closesocket(httpd->server_fd4);
+               httpd->server_fd4 = -1;
+       }
+       if (httpd->server_fd6 != -1) {
+               closesocket(httpd->server_fd6);
+               httpd->server_fd6 = -1;
+       }
+
        logger_log(httpd->logger, LOGGER_INFO, "Exiting HTTP thread");
 
        return 0;