From: Sebastian Harl Date: Mon, 15 Dec 2014 08:12:10 +0000 (+0100) Subject: connection: Renamed sdb_connection_read to sdb_connection_handle. X-Git-Tag: sysdb-0.7.0~110 X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=commitdiff_plain;h=330d8bc42e2577a01288f8a7bd606f2efafa9aa6 connection: Renamed sdb_connection_read to sdb_connection_handle. The function does more than read from the connection, so the old name was a bad choice. --- diff --git a/src/frontend/connection.c b/src/frontend/connection.c index 66ccfd4..ea2970f 100644 --- a/src/frontend/connection.c +++ b/src/frontend/connection.c @@ -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, diff --git a/src/frontend/sock.c b/src/frontend/sock.c index 96bc04b..cb6b9fc 100644 --- a/src/frontend/sock.c +++ b/src/frontend/sock.c @@ -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)); diff --git a/src/include/frontend/connection.h b/src/include/frontend/connection.h index 5dc2b1a..20cc6c2 100644 --- a/src/include/frontend/connection.h +++ b/src/include/frontend/connection.h @@ -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: diff --git a/t/unit/frontend/connection_test.c b/t/unit/frontend/connection_test.c index 13ae221..de5b010 100644 --- a/t/unit/frontend/connection_test.c +++ b/t/unit/frontend/connection_test.c @@ -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)); }