]> granicus.if.org Git - libevent/commitdiff
Make evhttp_bound_socket visible, and provide an accessor to its fd
authorNick Mathewson <nickm@torproject.org>
Sun, 16 Aug 2009 19:21:57 +0000 (19:21 +0000)
committerNick Mathewson <nickm@torproject.org>
Sun, 16 Aug 2009 19:21:57 +0000 (19:21 +0000)
Declare the previously private struct evhttp_bound_socket in
event2/http.h as an opaque struct.

Implement evhttp_bound_socket_get_fd, which returns the file descriptor
of an evhttp_bound_socket.

[Patch from David Reiss]

svn:r1421

http.c
include/event2/http.h

diff --git a/http.c b/http.c
index 52362bc9efa9ce2203264ddd9c008882347b2ec1..39528fc712199e302a307f88878005eb54887202 100644 (file)
--- a/http.c
+++ b/http.c
@@ -2433,6 +2433,11 @@ evhttp_accept_socket(struct evhttp *http, evutil_socket_t fd)
        return (0);
 }
 
+evutil_socket_t evhttp_bound_socket_get_fd(struct evhttp_bound_socket *bound)
+{
+       return bound->bind_ev.ev_fd;
+}
+
 static struct evhttp*
 evhttp_new_object(void)
 {
index e1ddaee7156f214dc4a63c8619c48b44a453ff38..93c805f801be41403860a9b5c51f0c9863bf2e53 100644 (file)
@@ -69,6 +69,7 @@ struct event_base;
 struct evhttp;
 struct evhttp_request;
 struct evkeyvalq;
+struct evhttp_bound_socket;
 
 /**
  * Create a new HTTP server.
@@ -111,6 +112,15 @@ int evhttp_bind_socket(struct evhttp *http, const char *address, ev_uint16_t por
  */
 int evhttp_accept_socket(struct evhttp *http, evutil_socket_t fd);
 
+/**
+ * Get the raw file descriptor referenced by an evhttp_bound_socket.
+ *
+ * @param bound_socket a handle returned by evhttp_{bind,accept}_socket_with_handle
+ * @return the file descriptor used by the bound socket
+ * @see evhttp_bind_socket_with_handle(), evhttp_accept_socket_with_handle()
+ */
+evutil_socket_t evhttp_bound_socket_get_fd(struct evhttp_bound_socket *bound_socket);
+
 /**
  * Free the previously created HTTP server.
  *