Code

connection: Renamed sdb_connection_read to sdb_connection_handle.
authorSebastian Harl <sh@tokkee.org>
Mon, 15 Dec 2014 08:12:10 +0000 (09:12 +0100)
committerSebastian Harl <sh@tokkee.org>
Mon, 15 Dec 2014 08:12:10 +0000 (09:12 +0100)
The function does more than read from the connection, so the old name was a
bad choice.

src/frontend/connection.c
src/frontend/sock.c
src/include/frontend/connection.h
t/unit/frontend/connection_test.c

index 66ccfd4c2fb727009063ddbb85288d3e2caa0310..ea2970f2f61f2f9faa1022b9457ce3e0c217a184 100644 (file)
@@ -467,7 +467,7 @@ sdb_connection_close(sdb_conn_t *conn)
 } /* sdb_connection_close */
 
 ssize_t
-sdb_connection_read(sdb_conn_t *conn)
+sdb_connection_handle(sdb_conn_t *conn)
 {
        ssize_t n = 0;
 
@@ -498,7 +498,7 @@ sdb_connection_read(sdb_conn_t *conn)
 
        sdb_conn_set_ctx(NULL);
        return n;
-} /* sdb_connection_read */
+} /* sdb_connection_handle */
 
 ssize_t
 sdb_connection_send(sdb_conn_t *conn, uint32_t code,
index 96bc04baf805640b747f46861d181ec0177e4e4b..cb6b9fcdd7a889405e0da21771a99a9acd2c47fa 100644 (file)
@@ -366,7 +366,7 @@ connection_handler(void *data)
                        continue;
                }
 
-               status = (int)sdb_connection_read(conn);
+               status = (int)sdb_connection_handle(conn);
                if (status <= 0) {
                        /* error or EOF -> close connection */
                        sdb_object_deref(SDB_OBJ(conn));
index 5dc2b1a8c5ce35105f7b57b972b3dd924bca3ab8..20cc6c2b4b321d34a436be54c2459fa46d9df94e 100644 (file)
@@ -88,15 +88,16 @@ void
 sdb_connection_close(sdb_conn_t *conn);
 
 /*
- * sdb_connection_read:
- * Read from an open connection until reading would block.
+ * sdb_connection_handle:
+ * Read from an open connection until reading would block and handle all
+ * incoming commands.
  *
  * Returns:
  *  - the number of bytes read (0 on EOF)
  *  - a negative value on error
  */
 ssize_t
-sdb_connection_read(sdb_conn_t *conn);
+sdb_connection_handle(sdb_conn_t *conn);
 
 /*
  * sdb_connection_send:
index 13ae221a0f509e6f8402c2c5c10e838f4df8b2ef..de5b01007f4521a8a81b19dfa2810095c468c479 100644 (file)
@@ -189,13 +189,13 @@ connection_startup(sdb_conn_t *conn)
                        username, check, expected);
 
        mock_conn_rewind(conn);
-       check = sdb_connection_read(conn);
+       check = sdb_connection_handle(conn);
        fail_unless(check == expected,
-                       "On startup: sdb_connection_read() = %zi; expected: %zi",
+                       "On startup: sdb_connection_handle() = %zi; expected: %zi",
                        check, expected);
 
        fail_unless(sdb_strbuf_len(conn->errbuf) == 0,
-                       "sdb_connection_read() left %zu bytes in the error "
+                       "sdb_connection_handle() left %zu bytes in the error "
                        "buffer (%s); expected: 0", sdb_strbuf_len(conn->errbuf),
                        sdb_strbuf_string(conn->errbuf));
 
@@ -282,24 +282,24 @@ START_TEST(test_conn_setup)
                }
 
                mock_conn_rewind(conn);
-               check = sdb_connection_read(conn);
+               check = sdb_connection_handle(conn);
                fail_unless(check == expected,
-                               "sdb_connection_read() = %zi; expected: %zi",
+                               "sdb_connection_handle() = %zi; expected: %zi",
                                check, expected);
 
                fail_unless(sdb_strbuf_len(conn->buf) == 0,
-                               "sdb_connection_read() left %zu bytes in the buffer; "
+                               "sdb_connection_handle() left %zu bytes in the buffer; "
                                "expected: 0", sdb_strbuf_len(conn->buf));
 
                if (golden_data[i].err) {
                        const char *err = sdb_strbuf_string(conn->errbuf);
                        fail_unless(strcmp(err, golden_data[i].err) == 0,
-                                       "sdb_connection_read(): got error '%s'; "
+                                       "sdb_connection_handle(): got error '%s'; "
                                        "expected: '%s'", err, golden_data[i].err);
                }
                else
                        fail_unless(sdb_strbuf_len(conn->errbuf) == 0,
-                                       "sdb_connection_read() left %zu bytes in the error "
+                                       "sdb_connection_handle() left %zu bytes in the error "
                                        "buffer (%s); expected: 0", sdb_strbuf_len(conn->errbuf),
                                        sdb_strbuf_string(conn->errbuf));
        }
@@ -376,44 +376,44 @@ START_TEST(test_conn_io)
                                check, msg_len);
 
                mock_conn_rewind(conn);
-               check = sdb_connection_read(conn);
+               check = sdb_connection_handle(conn);
                fail_unless(check == (ssize_t)msg_len,
-                               "sdb_connection_read() = %zi; expected: %zu",
+                               "sdb_connection_handle() = %zi; expected: %zu",
                                check, msg_len);
 
                if (golden_data[i].buf_len) {
                        /* partial commands need to be stored in the object */
                        fail_unless(conn->cmd == golden_data[i].code,
-                                       "sdb_connection_read() set partial command "
+                                       "sdb_connection_handle() set partial command "
                                        "to %u; expected: %u", conn->cmd, golden_data[i].code);
                        fail_unless(conn->cmd_len > golden_data[i].buf_len,
-                                       "sdb_connection_read() set partial command length "
+                                       "sdb_connection_handle() set partial command length "
                                        "to %u; expected: > %u", conn->cmd_len,
                                        golden_data[i].buf_len);
                }
                else {
                        fail_unless(conn->cmd == SDB_CONNECTION_IDLE,
-                                       "sdb_connection_read() did not reset command; "
+                                       "sdb_connection_handle() did not reset command; "
                                        "got %u; expected: %u", conn->cmd, SDB_CONNECTION_IDLE);
                        fail_unless(conn->cmd_len == 0,
-                                       "sdb_connection_read() did not reset command length; "
+                                       "sdb_connection_handle() did not reset command length; "
                                        "got %u; expected: 0", conn->cmd_len);
                }
 
                fail_unless(sdb_strbuf_len(conn->buf) == golden_data[i].buf_len,
-                               "sdb_connection_read() left %zu bytes in the buffer; "
+                               "sdb_connection_handle() left %zu bytes in the buffer; "
                                "expected: %zu", sdb_strbuf_len(conn->buf),
                                golden_data[i].buf_len);
 
                if (golden_data[i].err) {
                        const char *err = sdb_strbuf_string(conn->errbuf);
                        fail_unless(strcmp(err, golden_data[i].err) == 0,
-                                       "sdb_connection_read(): got error '%s'; "
+                                       "sdb_connection_handle(): got error '%s'; "
                                        "expected: '%s'", err, golden_data[i].err);
                }
                else
                        fail_unless(sdb_strbuf_len(conn->errbuf) == 0,
-                                       "sdb_connection_read() left %zu bytes in the error "
+                                       "sdb_connection_handle() left %zu bytes in the error "
                                        "buffer; expected: 0", sdb_strbuf_len(conn->errbuf));
        }