From fcb4d681b802aedacd16dcedc1cbaae4f5f43337 Mon Sep 17 00:00:00 2001 From: Dmitry Simonenko Date: Tue, 13 Jun 2017 14:49:50 +0300 Subject: [PATCH] machinarium: rework io api using opaque objects --- src/machinarium.h | 49 ++++++++++++++++++------------------ src/mm_accept.c | 8 +++--- src/mm_bind.c | 6 ++--- src/mm_close.c | 6 ++--- src/mm_connect.c | 10 ++++---- src/mm_dns.c | 8 +++--- src/mm_io.c | 32 +++++++++++------------ src/mm_read.c | 8 +++--- src/mm_tls_io.c | 4 +-- src/mm_write.c | 4 +-- tests/test_accept_cancel.c | 4 +-- tests/test_accept_timeout.c | 4 +-- tests/test_client_server0.c | 6 ++--- tests/test_client_server1.c | 6 ++--- tests/test_connect.c | 2 +- tests/test_connect_cancel0.c | 2 +- tests/test_connect_cancel1.c | 2 +- tests/test_connect_timeout.c | 2 +- tests/test_io_new.c | 2 +- tests/test_read_10mb.c | 6 ++--- tests/test_read_cancel.c | 6 ++--- tests/test_read_timeout.c | 6 ++--- tests/test_tls0.c | 6 ++--- tests/test_tls_read_10mb.c | 6 ++--- 24 files changed, 97 insertions(+), 98 deletions(-) diff --git a/src/machinarium.h b/src/machinarium.h index 66adc065..6a471a52 100644 --- a/src/machinarium.h +++ b/src/machinarium.h @@ -26,12 +26,11 @@ typedef void (*machine_coroutine_t)(void *arg); /* library handles */ -typedef struct machine_channel_ref machine_channel_t; -typedef struct machine_queue_ref machine_queue_t; -typedef struct machine_msg_ref machine_msg_t; -typedef struct machine_tls_ref machine_tls_t; - -typedef void* machine_io_t; +typedef struct machine_msg_private machine_msg_t; +typedef struct machine_channel_private machine_channel_t; +typedef struct machine_queue_private machine_queue_t; +typedef struct machine_tls_private machine_tls_t; +typedef struct machine_io_private machine_io_t; /* main */ @@ -160,43 +159,43 @@ machine_tls_set_key_file(machine_tls_t*, char*); /* io control */ -MACHINE_API machine_io_t +MACHINE_API machine_io_t* machine_io_create(void); MACHINE_API void -machine_io_free(machine_io_t); +machine_io_free(machine_io_t*); MACHINE_API int -machine_io_attach(machine_io_t); +machine_io_attach(machine_io_t*); MACHINE_API int -machine_io_detach(machine_io_t); +machine_io_detach(machine_io_t*); MACHINE_API char* -machine_error(machine_io_t); +machine_error(machine_io_t*); MACHINE_API int -machine_fd(machine_io_t); +machine_fd(machine_io_t*); MACHINE_API int -machine_set_nodelay(machine_io_t, int enable); +machine_set_nodelay(machine_io_t*, int enable); MACHINE_API int -machine_set_keepalive(machine_io_t, int enable, int delay); +machine_set_keepalive(machine_io_t*, int enable, int delay); MACHINE_API int -machine_set_readahead(machine_io_t, int size); +machine_set_readahead(machine_io_t*, int size); MACHINE_API int -machine_set_tls(machine_io_t, machine_tls_t*); +machine_set_tls(machine_io_t*, machine_tls_t*); /* dns */ MACHINE_API int -machine_getsockname(machine_io_t, struct sockaddr*, int*); +machine_getsockname(machine_io_t*, struct sockaddr*, int*); MACHINE_API int -machine_getpeername(machine_io_t, struct sockaddr*, int*); +machine_getpeername(machine_io_t*, struct sockaddr*, int*); MACHINE_API int machine_getaddrinfo(char *addr, char *service, @@ -207,24 +206,24 @@ machine_getaddrinfo(char *addr, char *service, /* io */ MACHINE_API int -machine_connect(machine_io_t, struct sockaddr*, uint32_t time_ms); +machine_connect(machine_io_t*, struct sockaddr*, uint32_t time_ms); MACHINE_API int -machine_connected(machine_io_t); +machine_connected(machine_io_t*); MACHINE_API int -machine_bind(machine_io_t, struct sockaddr*); +machine_bind(machine_io_t*, struct sockaddr*); MACHINE_API int -machine_accept(machine_io_t, machine_io_t*, int backlog, uint32_t time_ms); +machine_accept(machine_io_t*, machine_io_t**, int backlog, uint32_t time_ms); MACHINE_API int -machine_read(machine_io_t, char *buf, int size, uint32_t time_ms); +machine_read(machine_io_t*, char *buf, int size, uint32_t time_ms); MACHINE_API int -machine_write(machine_io_t, char *buf, int size, uint32_t time_ms); +machine_write(machine_io_t*, char *buf, int size, uint32_t time_ms); MACHINE_API int -machine_close(machine_io_t); +machine_close(machine_io_t*); #endif diff --git a/src/mm_accept.c b/src/mm_accept.c index 1b29ccf7..4b4f37b5 100644 --- a/src/mm_accept.c +++ b/src/mm_accept.c @@ -20,7 +20,7 @@ mm_accept_on_read_cb(mm_fd_t *handle) } static int -mm_accept(mm_io_t *io, int backlog, machine_io_t *client, uint32_t time_ms) +mm_accept(mm_io_t *io, int backlog, machine_io_t **client, uint32_t time_ms) { mm_machine_t *machine = mm_self; mm_errno_set(0); @@ -100,7 +100,7 @@ mm_accept(mm_io_t *io, int backlog, machine_io_t *client, uint32_t time_ms) *client = NULL; return -1; } - rc = machine_io_attach(client_io); + rc = machine_io_attach((machine_io_t*)client_io); if (rc == -1) { machine_close(*client); machine_io_free(*client); @@ -111,10 +111,10 @@ mm_accept(mm_io_t *io, int backlog, machine_io_t *client, uint32_t time_ms) } MACHINE_API int -machine_accept(machine_io_t obj, machine_io_t *client, +machine_accept(machine_io_t *obj, machine_io_t **client, int backlog, uint32_t time_ms) { - mm_io_t *io = obj; + mm_io_t *io = mm_cast(mm_io_t*, obj); int rc; rc = mm_accept(io, backlog, client, time_ms); if (rc == -1) diff --git a/src/mm_bind.c b/src/mm_bind.c index 2b380b62..65b5b666 100644 --- a/src/mm_bind.c +++ b/src/mm_bind.c @@ -9,9 +9,9 @@ #include MACHINE_API int -machine_bind(machine_io_t obj, struct sockaddr *sa) +machine_bind(machine_io_t *obj, struct sockaddr *sa) { - mm_io_t *io = obj; + mm_io_t *io = mm_cast(mm_io_t*, obj); mm_errno_set(0); if (io->connected) { mm_errno_set(EINPROGRESS); @@ -31,7 +31,7 @@ machine_bind(machine_io_t obj, struct sockaddr *sa) mm_errno_set(errno); goto error; } - rc = machine_io_attach(io); + rc = machine_io_attach(obj); if (rc == -1) goto error; return 0; diff --git a/src/mm_close.c b/src/mm_close.c index 27c43314..20bf4bce 100644 --- a/src/mm_close.c +++ b/src/mm_close.c @@ -9,15 +9,15 @@ #include MACHINE_API int -machine_close(machine_io_t obj) +machine_close(machine_io_t *obj) { - mm_io_t *io = obj; + mm_io_t *io = mm_cast(mm_io_t*, obj); if (io->fd == -1) { mm_errno_set(EBADF); return -1; } if (io->attached) - machine_io_detach(io); + machine_io_detach(obj); int rc; rc = close(io->fd); if (rc == -1) diff --git a/src/mm_connect.c b/src/mm_connect.c index 9afd7acc..ecb5704f 100644 --- a/src/mm_connect.c +++ b/src/mm_connect.c @@ -52,7 +52,7 @@ mm_connect(mm_io_t *io, struct sockaddr *sa, uint32_t time_ms) } /* add socket to event loop */ - rc = machine_io_attach(io); + rc = machine_io_attach((machine_io_t*)io); if (rc == -1) goto error; @@ -97,9 +97,9 @@ error: } MACHINE_API int -machine_connect(machine_io_t obj, struct sockaddr *sa, uint32_t time_ms) +machine_connect(machine_io_t *obj, struct sockaddr *sa, uint32_t time_ms) { - mm_io_t *io = obj; + mm_io_t *io = mm_cast(mm_io_t*, obj); int rc = mm_connect(io, sa, time_ms); if (rc == -1) return -1; @@ -107,8 +107,8 @@ machine_connect(machine_io_t obj, struct sockaddr *sa, uint32_t time_ms) } MACHINE_API int -machine_connected(machine_io_t obj) +machine_connected(machine_io_t *obj) { - mm_io_t *io = obj; + mm_io_t *io = mm_cast(mm_io_t*, obj); return io->connected; } diff --git a/src/mm_dns.c b/src/mm_dns.c index 23db1e33..48b024f4 100644 --- a/src/mm_dns.c +++ b/src/mm_dns.c @@ -44,9 +44,9 @@ machine_getaddrinfo(char *addr, char *service, } MACHINE_API int -machine_getsockname(machine_io_t obj, struct sockaddr *sa, int *salen) +machine_getsockname(machine_io_t *obj, struct sockaddr *sa, int *salen) { - mm_io_t *io = obj; + mm_io_t *io = mm_cast(mm_io_t*, obj); mm_errno_set(0); socklen_t slen = *salen; int rc = mm_socket_getsockname(io->fd, sa, &slen); @@ -59,9 +59,9 @@ machine_getsockname(machine_io_t obj, struct sockaddr *sa, int *salen) } MACHINE_API int -machine_getpeername(machine_io_t obj, struct sockaddr *sa, int *salen) +machine_getpeername(machine_io_t *obj, struct sockaddr *sa, int *salen) { - mm_io_t *io = obj; + mm_io_t *io = mm_cast(mm_io_t*, obj); mm_errno_set(0); socklen_t slen = *salen; int rc = mm_socket_getpeername(io->fd, sa, &slen); diff --git a/src/mm_io.c b/src/mm_io.c index 80ed3f2d..7d67f99d 100644 --- a/src/mm_io.c +++ b/src/mm_io.c @@ -8,7 +8,7 @@ #include #include -MACHINE_API machine_io_t +MACHINE_API machine_io_t* machine_io_create(void) { mm_errno_set(0); @@ -26,13 +26,13 @@ machine_io_create(void) /* read */ io->readahead_size = 8192; mm_buf_init(&io->readahead_buf); - return io; + return (machine_io_t*)io; } MACHINE_API void -machine_io_free(machine_io_t obj) +machine_io_free(machine_io_t *obj) { - mm_io_t *io = obj; + mm_io_t *io = mm_cast(mm_io_t*, obj); mm_errno_set(0); mm_buf_free(&io->readahead_buf); mm_tlsio_free(&io->tls); @@ -40,9 +40,9 @@ machine_io_free(machine_io_t obj) } MACHINE_API char* -machine_error(machine_io_t obj) +machine_error(machine_io_t *obj) { - mm_io_t *io = obj; + mm_io_t *io = mm_cast(mm_io_t*, obj); if (io->tls.error) return io->tls.error_msg; int errno_ = mm_errno_get(); @@ -52,16 +52,16 @@ machine_error(machine_io_t obj) } MACHINE_API int -machine_fd(machine_io_t obj) +machine_fd(machine_io_t *obj) { - mm_io_t *io = obj; + mm_io_t *io = mm_cast(mm_io_t*, obj); return io->fd; } MACHINE_API int -machine_set_nodelay(machine_io_t obj, int enable) +machine_set_nodelay(machine_io_t *obj, int enable) { - mm_io_t *io = obj; + mm_io_t *io = mm_cast(mm_io_t*, obj); mm_errno_set(0); io->opt_nodelay = enable; if (io->fd != -1) { @@ -76,9 +76,9 @@ machine_set_nodelay(machine_io_t obj, int enable) } MACHINE_API int -machine_set_keepalive(machine_io_t obj, int enable, int delay) +machine_set_keepalive(machine_io_t *obj, int enable, int delay) { - mm_io_t *io = obj; + mm_io_t *io = mm_cast(mm_io_t*, obj); mm_errno_set(0); io->opt_keepalive = enable; io->opt_keepalive_delay = delay; @@ -94,9 +94,9 @@ machine_set_keepalive(machine_io_t obj, int enable, int delay) } MACHINE_API int -machine_io_attach(machine_io_t obj) +machine_io_attach(machine_io_t *obj) { - mm_io_t *io = obj; + mm_io_t *io = mm_cast(mm_io_t*, obj); mm_errno_set(0); if (io->attached) { mm_errno_set(EINPROGRESS); @@ -113,9 +113,9 @@ machine_io_attach(machine_io_t obj) } MACHINE_API int -machine_io_detach(machine_io_t obj) +machine_io_detach(machine_io_t *obj) { - mm_io_t *io = obj; + mm_io_t *io = mm_cast(mm_io_t*, obj); mm_errno_set(0); if (! io->attached) { mm_errno_set(ENOTCONN); diff --git a/src/mm_read.c b/src/mm_read.c index 21ec77be..8de1911d 100644 --- a/src/mm_read.c +++ b/src/mm_read.c @@ -180,18 +180,18 @@ int mm_read(mm_io_t *io, char *buf, int size, uint32_t time_ms) } MACHINE_API int -machine_read(machine_io_t obj, char *buf, int size, uint32_t time_ms) +machine_read(machine_io_t *obj, char *buf, int size, uint32_t time_ms) { - mm_io_t *io = obj; + mm_io_t *io = mm_cast(mm_io_t*, obj); if (mm_tls_is_active(&io->tls)) return mm_tlsio_read(&io->tls, buf, size, time_ms); return mm_read(io, buf, size, time_ms); } MACHINE_API int -machine_set_readahead(machine_io_t obj, int size) +machine_set_readahead(machine_io_t *obj, int size) { - mm_io_t *io = obj; + mm_io_t *io = mm_cast(mm_io_t*, obj); mm_errno_set(0); int rc; rc = mm_buf_ensure(&io->readahead_buf, size); diff --git a/src/mm_tls_io.c b/src/mm_tls_io.c index 14c8df7b..64facf40 100644 --- a/src/mm_tls_io.c +++ b/src/mm_tls_io.c @@ -462,9 +462,9 @@ int mm_tlsio_read(mm_tlsio_t *io, char *buf, int size, uint32_t time_ms) } MACHINE_API int -machine_set_tls(machine_io_t obj, machine_tls_t *tls_obj) +machine_set_tls(machine_io_t *obj, machine_tls_t *tls_obj) { - mm_io_t *io = obj; + mm_io_t *io = mm_cast(mm_io_t*, obj); mm_tlsio_error_reset(&io->tls); if (io->tls_obj) { mm_errno_set(EINPROGRESS); diff --git a/src/mm_write.c b/src/mm_write.c index 115e5a81..457ae60c 100644 --- a/src/mm_write.c +++ b/src/mm_write.c @@ -107,9 +107,9 @@ int mm_write(mm_io_t *io, char *buf, int size, uint32_t time_ms) } MACHINE_API int -machine_write(machine_io_t obj, char *buf, int size, uint32_t time_ms) +machine_write(machine_io_t *obj, char *buf, int size, uint32_t time_ms) { - mm_io_t *io = obj; + mm_io_t *io = mm_cast(mm_io_t*, obj); if (mm_tls_is_active(&io->tls)) return mm_tlsio_write(&io->tls, buf, size, time_ms); return mm_write(io, buf, size, time_ms); diff --git a/tests/test_accept_cancel.c b/tests/test_accept_cancel.c index b7fa2a11..6e8ece42 100644 --- a/tests/test_accept_cancel.c +++ b/tests/test_accept_cancel.c @@ -13,7 +13,7 @@ static void test_server(void *arg) { - machine_io_t server = machine_io_create(); + machine_io_t *server = machine_io_create(); test(server != NULL); struct sockaddr_in sa; @@ -24,7 +24,7 @@ test_server(void *arg) rc = machine_bind(server, (struct sockaddr*)&sa); test(rc == 0); - machine_io_t client; + machine_io_t *client; rc = machine_accept(server, &client, 16, 100); test(rc == -1); test(machine_cancelled()); diff --git a/tests/test_accept_timeout.c b/tests/test_accept_timeout.c index 60ba46ed..f875a67a 100644 --- a/tests/test_accept_timeout.c +++ b/tests/test_accept_timeout.c @@ -13,7 +13,7 @@ static void test_server(void *arg) { - machine_io_t server = machine_io_create(); + machine_io_t *server = machine_io_create(); test(server != NULL); struct sockaddr_in sa; @@ -24,7 +24,7 @@ test_server(void *arg) rc = machine_bind(server, (struct sockaddr*)&sa); test(rc == 0); - machine_io_t client; + machine_io_t *client; rc = machine_accept(server, &client, 16, 100); test(rc == -1); test(machine_timedout()); diff --git a/tests/test_client_server0.c b/tests/test_client_server0.c index 98631035..e2ea1f92 100644 --- a/tests/test_client_server0.c +++ b/tests/test_client_server0.c @@ -14,7 +14,7 @@ static void server(void *arg) { - machine_io_t server = machine_io_create(); + machine_io_t *server = machine_io_create(); test(server != NULL); struct sockaddr_in sa; @@ -25,7 +25,7 @@ server(void *arg) rc = machine_bind(server, (struct sockaddr*)&sa); test(rc == 0); - machine_io_t client; + machine_io_t *client; rc = machine_accept(server, &client, 16, UINT32_MAX); test(rc == 0); @@ -45,7 +45,7 @@ server(void *arg) static void client(void *arg) { - machine_io_t client = machine_io_create(); + machine_io_t *client = machine_io_create(); test(client != NULL); struct sockaddr_in sa; diff --git a/tests/test_client_server1.c b/tests/test_client_server1.c index 5a46bb0c..4c8671fe 100644 --- a/tests/test_client_server1.c +++ b/tests/test_client_server1.c @@ -14,7 +14,7 @@ static void server(void *arg) { - machine_io_t server = machine_io_create(); + machine_io_t *server = machine_io_create(); test(server != NULL); struct sockaddr_in sa; @@ -25,7 +25,7 @@ server(void *arg) rc = machine_bind(server, (struct sockaddr*)&sa); test(rc == 0); - machine_io_t client; + machine_io_t *client; rc = machine_accept(server, &client, 16, UINT32_MAX); test(rc == 0); @@ -45,7 +45,7 @@ server(void *arg) static void client(void *arg) { - machine_io_t client = machine_io_create(); + machine_io_t *client = machine_io_create(); test(client != NULL); struct sockaddr_in sa; diff --git a/tests/test_connect.c b/tests/test_connect.c index 4dd72672..812ca43a 100644 --- a/tests/test_connect.c +++ b/tests/test_connect.c @@ -13,7 +13,7 @@ static void test_connect_coroutine(void *arg) { - machine_io_t client = machine_io_create(); + machine_io_t *client = machine_io_create(); test(client != NULL); struct sockaddr_in sa; diff --git a/tests/test_connect_cancel0.c b/tests/test_connect_cancel0.c index 78c8a1a0..3a14d5ce 100644 --- a/tests/test_connect_cancel0.c +++ b/tests/test_connect_cancel0.c @@ -13,7 +13,7 @@ static void test_connect_coroutine(void *arg) { - machine_io_t client = machine_io_create(); + machine_io_t *client = machine_io_create(); test(client != NULL); struct sockaddr_in sa; diff --git a/tests/test_connect_cancel1.c b/tests/test_connect_cancel1.c index 85b38133..b03533f3 100644 --- a/tests/test_connect_cancel1.c +++ b/tests/test_connect_cancel1.c @@ -13,7 +13,7 @@ static void test_connect_coroutine(void *arg) { - machine_io_t client = machine_io_create(); + machine_io_t *client = machine_io_create(); test(client != NULL); struct sockaddr_in sa; diff --git a/tests/test_connect_timeout.c b/tests/test_connect_timeout.c index 469de564..be360fe5 100644 --- a/tests/test_connect_timeout.c +++ b/tests/test_connect_timeout.c @@ -13,7 +13,7 @@ static void test_connect_coroutine(void *arg) { - machine_io_t client = machine_io_create(); + machine_io_t *client = machine_io_create(); test(client != NULL); struct sockaddr_in sa; diff --git a/tests/test_io_new.c b/tests/test_io_new.c index dbde0d88..6f8ef42d 100644 --- a/tests/test_io_new.c +++ b/tests/test_io_new.c @@ -11,7 +11,7 @@ static void coroutine(void *arg) { - machine_io_t io = machine_io_create(); + machine_io_t *io = machine_io_create(); test(io != NULL); machine_io_free(io); diff --git a/tests/test_read_10mb.c b/tests/test_read_10mb.c index 0eafbeb5..c92842e4 100644 --- a/tests/test_read_10mb.c +++ b/tests/test_read_10mb.c @@ -14,7 +14,7 @@ static void server(void *arg) { - machine_io_t server = machine_io_create(); + machine_io_t *server = machine_io_create(); test(server != NULL); struct sockaddr_in sa; @@ -25,7 +25,7 @@ server(void *arg) rc = machine_bind(server, (struct sockaddr*)&sa); test(rc == 0); - machine_io_t client; + machine_io_t *client; rc = machine_accept(server, &client, 16, UINT32_MAX); test(rc == 0); @@ -55,7 +55,7 @@ server(void *arg) static void client(void *arg) { - machine_io_t client = machine_io_create(); + machine_io_t *client = machine_io_create(); test(client != NULL); struct sockaddr_in sa; diff --git a/tests/test_read_cancel.c b/tests/test_read_cancel.c index cf82228e..91cfe972 100644 --- a/tests/test_read_cancel.c +++ b/tests/test_read_cancel.c @@ -16,7 +16,7 @@ static int client_id; static void server(void *arg) { - machine_io_t server = machine_io_create(); + machine_io_t *server = machine_io_create(); test(server != NULL); struct sockaddr_in sa; @@ -27,7 +27,7 @@ server(void *arg) rc = machine_bind(server, (struct sockaddr*)&sa); test(rc == 0); - machine_io_t client; + machine_io_t *client; rc = machine_accept(server, &client, 16, UINT32_MAX); test(rc == 0); @@ -47,7 +47,7 @@ server(void *arg) static void client(void *arg) { - machine_io_t client = machine_io_create(); + machine_io_t *client = machine_io_create(); test(client != NULL); struct sockaddr_in sa; diff --git a/tests/test_read_timeout.c b/tests/test_read_timeout.c index 51669d9f..8af2e236 100644 --- a/tests/test_read_timeout.c +++ b/tests/test_read_timeout.c @@ -14,7 +14,7 @@ static void server(void *arg) { - machine_io_t server = machine_io_create(); + machine_io_t *server = machine_io_create(); test(server != NULL); struct sockaddr_in sa; @@ -25,7 +25,7 @@ server(void *arg) rc = machine_bind(server, (struct sockaddr*)&sa); test(rc == 0); - machine_io_t client; + machine_io_t *client; rc = machine_accept(server, &client, 16, UINT32_MAX); test(rc == 0); @@ -41,7 +41,7 @@ server(void *arg) static void client(void *arg) { - machine_io_t client = machine_io_create(); + machine_io_t *client = machine_io_create(); test(client != NULL); struct sockaddr_in sa; diff --git a/tests/test_tls0.c b/tests/test_tls0.c index 3fdcf3a2..a4f07c0c 100644 --- a/tests/test_tls0.c +++ b/tests/test_tls0.c @@ -14,7 +14,7 @@ static void server(void *arg) { - machine_io_t server = machine_io_create(); + machine_io_t *server = machine_io_create(); test(server != NULL); struct sockaddr_in sa; @@ -25,7 +25,7 @@ server(void *arg) rc = machine_bind(server, (struct sockaddr*)&sa); test(rc == 0); - machine_io_t client = NULL; + machine_io_t *client = NULL; rc = machine_accept(server, &client, 16, UINT32_MAX); test(rc == 0); test(client != NULL); @@ -64,7 +64,7 @@ server(void *arg) static void client(void *arg) { - machine_io_t client = machine_io_create(); + machine_io_t *client = machine_io_create(); test(client != NULL); struct sockaddr_in sa; diff --git a/tests/test_tls_read_10mb.c b/tests/test_tls_read_10mb.c index 2f37dbb8..78857b06 100644 --- a/tests/test_tls_read_10mb.c +++ b/tests/test_tls_read_10mb.c @@ -14,7 +14,7 @@ static void server(void *arg) { - machine_io_t server = machine_io_create(); + machine_io_t *server = machine_io_create(); test(server != NULL); int rc; @@ -28,7 +28,7 @@ server(void *arg) rc = machine_bind(server, (struct sockaddr*)&sa); test(rc == 0); - machine_io_t client; + machine_io_t *client; rc = machine_accept(server, &client, 16, UINT32_MAX); test(rc == 0); @@ -76,7 +76,7 @@ server(void *arg) static void client(void *arg) { - machine_io_t client = machine_io_create(); + machine_io_t *client = machine_io_create(); test(client != NULL); int rc;