Skip to content

Commit

Permalink
evhttp: Add evhttp_foreach_bound_socket.
Browse files Browse the repository at this point in the history
Applies the function specified in the first argument to all
evhttp_bound_sockets associated with a struct evhttp. The user
must not attempt to free or remove any connections, sockets or
listeners in the callback function.
  • Loading branch information
Samy Al Bahra authored and nmathewson committed Oct 26, 2011
1 parent 356554c commit a2c48e3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
10 changes: 10 additions & 0 deletions http.c
Original file line number Diff line number Diff line change
Expand Up @@ -3239,6 +3239,16 @@ evhttp_accept_socket(struct evhttp *http, evutil_socket_t fd)
return (0);
}

void
evhttp_foreach_bound_socket(struct evhttp *http,
evhttp_bound_socket_foreach_fn *function,
void *argument)
{
struct evhttp_bound_socket *bound;

TAILQ_FOREACH(bound, &http->sockets, next)
function(bound, argument);
}

struct evhttp_bound_socket *
evhttp_accept_socket_with_handle(struct evhttp *http, evutil_socket_t fd)
Expand Down
13 changes: 13 additions & 0 deletions include/event2/http.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,19 @@ struct evhttp_bound_socket *evhttp_bind_listener(struct evhttp *http, struct evc
*/
struct evconnlistener *evhttp_bound_socket_get_listener(struct evhttp_bound_socket *bound);

typedef void evhttp_bound_socket_foreach_fn(struct evhttp_bound_socket *, void *);
/**
* Applies the function specified in the first argument to all
* evhttp_bound_sockets associated with "http". The user must not
* attempt to free or remove any connections, sockets or listeners
* in the callback "function".
*
* @param http pointer to an evhttp object
* @param function function to apply to every bound socket
* @param argument pointer value passed to function for every socket iterated
*/
void evhttp_foreach_bound_socket(struct evhttp *http, evhttp_bound_socket_foreach_fn *function, void *argument);

/**
* Makes an HTTP server stop accepting connections on the specified socket
*
Expand Down

0 comments on commit a2c48e3

Please sign in to comment.