summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c91469d)
raw | patch | inline | side by side (parent: c91469d)
author | Sebastian Harl <sh@tokkee.org> | |
Sat, 26 Oct 2013 12:10:04 +0000 (14:10 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sat, 26 Oct 2013 12:10:04 +0000 (14:10 +0200) |
src/frontend/sock.c | patch | blob | history |
diff --git a/src/frontend/sock.c b/src/frontend/sock.c
index 27a1b679c2815f17932cd3845383ff7649a9d502..d47240c35db359b1fda80d46e691b6d78273bbb4 100644 (file)
--- a/src/frontend/sock.c
+++ b/src/frontend/sock.c
listener->sock_fd = -1;
} /* listener_close */
+static void
+socket_close(sdb_fe_socket_t *sock)
+{
+ size_t i;
+
+ assert(sock);
+ for (i = 0; i < sock->listeners_num; ++i)
+ listener_close(sock->listeners + i);
+} /* socket_close */
+
/*
* private data types
*/
/* XXX: make the number of threads configurable */
pthread_t handler_threads[5];
- if ((! sock) || (! sock->listeners_num) || (! loop))
- return -1;
-
- if (sock->chan)
+ if ((! sock) || (! sock->listeners_num) || (! loop) || sock->chan)
return -1;
FD_ZERO(&sockets);
-
for (i = 0; i < sock->listeners_num; ++i) {
listener_t *listener = sock->listeners + i;
- if (listener_listen(listener))
+ if (listener_listen(listener)) {
+ socket_close(sock);
return -1;
+ }
FD_SET(listener->sock_fd, &sockets);
if (listener->sock_fd > max_listen_fd)
}
sock->chan = sdb_channel_create(1024, sizeof(connection_obj_t *));
- if (! sock->chan)
+ if (! sock->chan) {
+ socket_close(sock);
return -1;
+ }
memset(&handler_threads, 0, sizeof(handler_threads));
/* XXX: error handling */
sdb_llist_iter_destroy(iter);
}
- for (i = 0; i < sock->listeners_num; ++i)
- listener_close(sock->listeners + i);
+ socket_close(sock);
sdb_log(SDB_LOG_INFO, "frontend: Waiting for connection handler threads "
"to terminate");