summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 621126e)
raw | patch | inline | side by side (parent: 621126e)
author | Sebastian Harl <sh@tokkee.org> | |
Wed, 30 Oct 2013 10:16:48 +0000 (11:16 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Wed, 30 Oct 2013 10:16:48 +0000 (11:16 +0100) |
There's no reason for two separate structs.
src/frontend/sock.c | patch | blob | history |
diff --git a/src/frontend/sock.c b/src/frontend/sock.c
index 414c90775657294c0408ffb1e8c1eaea78ae8f0d..53a8a860d6f5a811181f0e4ba831d9e58704165f 100644 (file)
--- a/src/frontend/sock.c
+++ b/src/frontend/sock.c
*/
typedef struct {
+ sdb_object_t super;
+
int fd;
struct sockaddr_storage client_addr;
socklen_t client_addr_len;
-} connection_t;
-
-typedef struct {
- sdb_object_t super;
- connection_t conn;
} connection_obj_t;
#define CONN(obj) ((connection_obj_t *)(obj))
static int
connection_init(sdb_object_t *obj, va_list ap)
{
- connection_t *conn;
+ connection_obj_t *conn;
int sock_fd;
int sock_fl;
assert(obj);
- conn = &CONN(obj)->conn;
+ conn = CONN(obj);
sock_fd = va_arg(ap, int);
static void
connection_destroy(sdb_object_t *obj)
{
- connection_t *conn;
+ connection_obj_t *conn;
assert(obj);
- conn = &CONN(obj)->conn;
+ conn = CONN(obj);
sdb_log(SDB_LOG_DEBUG, "frontend: Closing connection on fd=%i", conn->fd);
close(conn->fd);
continue;
}
- status = connection_read(conn->conn.fd);
+ status = connection_read(conn->fd);
if (status <= 0) {
/* error or EOF -> close connection */
sdb_object_deref(SDB_OBJ(conn));
while (sdb_llist_iter_has_next(iter)) {
sdb_object_t *obj = sdb_llist_iter_get_next(iter);
- if (FD_ISSET(CONN(obj)->conn.fd, exceptions))
+ if (FD_ISSET(CONN(obj)->fd, exceptions))
sdb_log(SDB_LOG_INFO, "Exception on fd %d",
- CONN(obj)->conn.fd);
+ CONN(obj)->fd);
- if (FD_ISSET(CONN(obj)->conn.fd, ready)) {
+ if (FD_ISSET(CONN(obj)->fd, ready)) {
sdb_llist_iter_remove_current(iter);
sdb_channel_write(sock->chan, &obj);
}
while (sdb_llist_iter_has_next(iter)) {
sdb_object_t *obj = sdb_llist_iter_get_next(iter);
- FD_SET(CONN(obj)->conn.fd, &ready);
- FD_SET(CONN(obj)->conn.fd, &exceptions);
+ FD_SET(CONN(obj)->fd, &ready);
+ FD_SET(CONN(obj)->fd, &exceptions);
- if (CONN(obj)->conn.fd > max_fd)
- max_fd = CONN(obj)->conn.fd;
+ if (CONN(obj)->fd > max_fd)
+ max_fd = CONN(obj)->fd;
}
sdb_llist_iter_destroy(iter);