Define evhttp_del_accept_socket
authorNick Mathewson <nickm@torproject.org>
Sun, 16 Aug 2009 19:22:10 +0000 (19:22 +0000)
committerNick Mathewson <nickm@torproject.org>
Sun, 16 Aug 2009 19:22:10 +0000 (19:22 +0000)
[Patch from David Reiss]

svn:r1423

http.c
include/event2/http.h

diff --git a/http.c b/http.c
index 2c94edb46e7ae4f07b3e822b145544c81774f001..8fc1e7d3bf229ad0c6d660a146c4fdb08311271b 100644 (file)
--- a/http.c
+++ b/http.c
@@ -2462,6 +2462,14 @@ evutil_socket_t evhttp_bound_socket_get_fd(struct evhttp_bound_socket *bound)
        return bound->bind_ev.ev_fd;
 }
 
+void
+evhttp_del_accept_socket(struct evhttp *http, struct evhttp_bound_socket *bound)
+{
+       TAILQ_REMOVE(&http->sockets, bound, next);
+       event_del(&bound->bind_ev);
+       mm_free(bound);
+}
+
 static struct evhttp*
 evhttp_new_object(void)
 {
index c65b7f29490a548c5df7ea6eae9226ae18a2d6e4..30cc5f16fca8c7f27918b08d539ac35d69e535ab 100644 (file)
@@ -137,6 +137,22 @@ int evhttp_accept_socket(struct evhttp *http, evutil_socket_t fd);
  */
 struct evhttp_bound_socket *evhttp_accept_socket_with_handle(struct evhttp *http, evutil_socket_t fd);
 
+/**
+ * Makes an HTTP server stop accepting connections on the specified socket
+ *
+ * This may be useful when a socket has been sent via file descriptor passing
+ * and is no longer needed by the current process.
+ *
+ * This function does not close the socket.
+ *
+ * \a bound_socket is an invalid pointer after this call returns.
+ *
+ * @param http a pointer to an evhttp object
+ * @param bound_socket a handle returned by evhttp_{bind,accept}_socket_with_handle
+ * @see evhttp_bind_socket_with_handle(), evhttp_accept_socket_with_handle()
+ */
+void evhttp_del_accept_socket(struct evhttp *http, struct evhttp_bound_socket *bound_socket);
+
 /**
  * Get the raw file descriptor referenced by an evhttp_bound_socket.
  *