summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 633201f)
raw | patch | inline | side by side (parent: 633201f)
author | Sebastian Harl <sh@tokkee.org> | |
Fri, 25 Oct 2013 17:04:56 +0000 (19:04 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Fri, 25 Oct 2013 17:04:56 +0000 (19:04 +0200) |
Close the connection on EOF and pass back the connection to the main loop in
case no data is currently available (read() would block).
case no data is currently available (read() would block).
src/frontend/sock.c | patch | blob | history |
diff --git a/src/frontend/sock.c b/src/frontend/sock.c
index fb79f105f686295c77ef4b8a332a47aa27f2840b..d157853bb64bc4b7489af9beb8c12dff5ab0e853 100644 (file)
--- a/src/frontend/sock.c
+++ b/src/frontend/sock.c
assert(obj);
conn = &CONN(obj)->conn;
+ sdb_log(SDB_LOG_DEBUG, "frontend: Closing connection on fd=%i", conn->fd);
close(conn->fd);
conn->fd = -1;
} /* connection_destroy */
continue;
}
- /* XXX */
- sdb_log(SDB_LOG_INFO, "frontend: Data available on connection fd=%i\n",
- conn->conn.fd);
+ status = connection_read(conn->conn.fd);
+ if (status <= 0) {
+ /* error or EOF → close connection */
+ sdb_object_deref(SDB_OBJ(conn));
+ }
+ else {
+ if (sdb_llist_append(sock->open_connections, SDB_OBJ(conn))) {
+ sdb_log(SDB_LOG_ERR, "frontend: Failed to re-append "
+ "connection %s to list of open connections",
+ SDB_OBJ(conn)->name);
+ }
+
+ /* pass ownership back to list; or destroy in case of an error */
+ sdb_object_deref(SDB_OBJ(conn));
+ }
}
return NULL;
} /* connection_handler */
CONN(obj)->conn.fd);
if (FD_ISSET(CONN(obj)->conn.fd, &ready)) {
- sdb_log(SDB_LOG_INFO, "Data on fd %d", CONN(obj)->conn.fd);
sdb_llist_iter_remove_current(iter);
sdb_channel_write(sock->chan, &obj);
}