summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6352cfa)
raw | patch | inline | side by side (parent: 6352cfa)
author | Sebastian Harl <sh@tokkee.org> | |
Fri, 25 Oct 2013 15:50:17 +0000 (17:50 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Fri, 25 Oct 2013 15:50:17 +0000 (17:50 +0200) |
src/frontend/sock.c | patch | blob | history |
diff --git a/src/frontend/sock.c b/src/frontend/sock.c
index 12690d8cb83e23557306d8224c67ad1cf6c11e1d..3662a2650cc41d313ea5c6e8613c59810825fd50 100644 (file)
--- a/src/frontend/sock.c
+++ b/src/frontend/sock.c
return NULL;
} /* connection_handler */
+static int
+accept_connection(sdb_fe_socket_t *sock, listener_t *listener)
+{
+ sdb_object_t *obj;
+
+ /* the X's will be replaced with the accepted file descriptor
+ * when initializing the object */
+ obj = sdb_object_create(CONN_FD_PREFIX CONN_FD_PLACEHOLDER,
+ connection_type, listener->sock_fd);
+ if (! obj)
+ return -1;
+
+ if (sdb_llist_append(sock->open_connections, obj)) {
+ sdb_log(SDB_LOG_ERR, "frontend: Failed to append "
+ "connection %s to list of open connections",
+ obj->name);
+ sdb_object_deref(obj);
+ return -1;
+ }
+
+ /* hand ownership over to the list */
+ sdb_object_deref(obj);
+ return 0;
+} /* accept_connection */
+
/*
* public API
*/
for (i = 0; i < sock->listeners_num; ++i) {
listener_t *listener = sock->listeners + i;
-
- if (FD_ISSET(listener->sock_fd, &ready)) {
- sdb_object_t *obj;
-
- /* the X's will be replaced with the accepted file descriptor
- * when initializing the object */
- obj = sdb_object_create(CONN_FD_PREFIX CONN_FD_PLACEHOLDER,
- connection_type, listener->sock_fd);
- if (! obj)
+ if (FD_ISSET(listener->sock_fd, &ready))
+ if (accept_connection(sock, listener))
continue;
-
- if (sdb_llist_append(sock->open_connections, obj)) {
- sdb_log(SDB_LOG_ERR, "frontend: Failed to append "
- "connection %s to list of open connections",
- obj->name);
- sdb_object_deref(obj);
- continue;
- }
-
- /* hand ownership over to the list */
- sdb_object_deref(obj);
- }
}
iter = sdb_llist_get_iter(sock->open_connections);