Code

connection: Update the connection name as early as possible.
authorSebastian Harl <sh@tokkee.org>
Wed, 14 Jan 2015 20:56:22 +0000 (21:56 +0100)
committerSebastian Harl <sh@tokkee.org>
Wed, 14 Jan 2015 20:56:22 +0000 (21:56 +0100)
This is just to avoid weird error messages if setting up the connection
failed.

src/frontend/connection.c

index f35f7b39c82a8278f47137e65810163094c33044..c35d2d213bd5cee21e9d0e5d3a069f17bce45736 100644 (file)
@@ -156,6 +156,10 @@ connection_init(sdb_object_t *obj, va_list ap)
                return -1;
        }
 
+       /* update the object name */
+       snprintf(obj->name + strlen(CONN_FD_PREFIX),
+                       strlen(CONN_FD_PLACEHOLDER), "%i", conn->fd);
+
        /* defaults */
        conn->read = conn_read;
        conn->write = conn_write;
@@ -193,10 +197,6 @@ connection_init(sdb_object_t *obj, va_list ap)
        conn->cmd = SDB_CONNECTION_IDLE;
        conn->cmd_len = 0;
        conn->skip_len = 0;
-
-       /* update the object name */
-       snprintf(obj->name + strlen(CONN_FD_PREFIX),
-                       strlen(CONN_FD_PLACEHOLDER), "%i", conn->fd);
        return 0;
 } /* connection_init */