summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0fe9414)
raw | patch | inline | side by side (parent: 0fe9414)
author | Sebastian Harl <sh@tokkee.org> | |
Mon, 21 Apr 2014 18:22:22 +0000 (20:22 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Mon, 21 Apr 2014 18:22:22 +0000 (20:22 +0200) |
This function may be used to shut down and clear all listeners associated with
a socket object without affecting any open connections.
a socket object without affecting any open connections.
src/frontend/sock.c | patch | blob | history | |
src/include/frontend/sock.h | patch | blob | history |
diff --git a/src/frontend/sock.c b/src/frontend/sock.c
index 7cfdb7cac4b84d21c2f476e38b08855ea80c970b..90aeab1406a6a6389f8ce083dbab72a624b4a936 100644 (file)
--- a/src/frontend/sock.c
+++ b/src/frontend/sock.c
return listener;
} /* listener_create */
+static void
+socket_clear(sdb_fe_socket_t *sock)
+{
+ size_t i;
+
+ assert(sock);
+ for (i = 0; i < sock->listeners_num; ++i)
+ listener_destroy(sock->listeners + i);
+ if (sock->listeners)
+ free(sock->listeners);
+ sock->listeners = NULL;
+ sock->listeners_num = 0;
+} /* socket_clear */
+
static void
socket_close(sdb_fe_socket_t *sock)
{
void
sdb_fe_sock_destroy(sdb_fe_socket_t *sock)
{
- size_t i;
-
if (! sock)
return;
- for (i = 0; i < sock->listeners_num; ++i) {
- listener_destroy(sock->listeners + i);
- }
- if (sock->listeners)
- free(sock->listeners);
- sock->listeners = NULL;
+ socket_clear(sock);
sdb_llist_destroy(sock->open_connections);
sock->open_connections = NULL;
return 0;
} /* sdb_fe_sock_add_listener */
+void
+sdb_fe_sock_clear_listeners(sdb_fe_socket_t *sock)
+{
+ if (! sock)
+ return;
+
+ socket_clear(sock);
+} /* sdb_fe_sock_clear_listeners */
+
int
sdb_fe_sock_listen_and_serve(sdb_fe_socket_t *sock, sdb_fe_loop_t *loop)
{
index 7d1fd7a3ceed81995e790921a2258949d8d25f7a..2b93a6f724d1adaca687d81e149fa49fecb5bf68 100644 (file)
int
sdb_fe_sock_add_listener(sdb_fe_socket_t *sock, const char *address);
+/*
+ * sdb_fe_sock_clear_listeners:
+ * Shut down all listeners from the socket object and clear the list of
+ * listeners. All open connections will not be affected by this.
+ */
+void
+sdb_fe_sock_clear_listeners(sdb_fe_socket_t *sock);
+
/*
* sdb_fe_sock_listen_and_serve:
* Listen on the specified socket and serve client requests. The loop