Add raop_is_running function.
[deb_shairplay.git] / src / lib / httpd.c
index 6ad28696b397c3edc3247a1899035f5ace652510..0dbc84776caf8b5383ac7e90718ff3055bcb098f 100644 (file)
@@ -235,10 +235,10 @@ httpd_thread(void *arg)
                                assert(connection->request);
                        }
 
-                       logger_log(httpd->logger, LOGGER_DEBUG, "Receiving on socket %d\n", httpd->connections[i].socket_fd);
+                       logger_log(httpd->logger, LOGGER_DEBUG, "Receiving on socket %d\n", connection->socket_fd);
                        ret = recv(connection->socket_fd, buffer, sizeof(buffer), 0);
                        if (ret == 0) {
-                               logger_log(httpd->logger, LOGGER_INFO, "Connection closed\n");
+                               logger_log(httpd->logger, LOGGER_INFO, "Connection closed for socket %d\n", connection->socket_fd);
                                httpd_remove_connection(httpd, connection);
                                continue;
                        }
@@ -293,11 +293,11 @@ httpd_thread(void *arg)
                if (!connection->connected) {
                        continue;
                }
-               logger_log(httpd->logger, LOGGER_INFO, "Removing connection\n");
+               logger_log(httpd->logger, LOGGER_INFO, "Removing connection for socket %d\n", connection->socket_fd);
                httpd_remove_connection(httpd, connection);
        }
 
-       logger_log(httpd->logger, LOGGER_INFO, "Exiting thread\n");
+       logger_log(httpd->logger, LOGGER_INFO, "Exiting HTTP thread\n");
 
        return 0;
 }
@@ -336,6 +336,20 @@ httpd_start(httpd_t *httpd, unsigned short *port)
        return 1;
 }
 
+int
+httpd_is_running(httpd_t *httpd)
+{
+       int running;
+
+       assert(httpd);
+
+       MUTEX_LOCK(httpd->run_mutex);
+       running = httpd->running || !httpd->joined;
+       MUTEX_UNLOCK(httpd->run_mutex);
+
+       return running;
+}
+
 void
 httpd_stop(httpd_t *httpd)
 {