Obsolete
/
libipc-old
Archived
3
0
Fork 0

WIP: connection OK, timer OK

pollfd
Karchnu 2020-06-29 19:35:52 +02:00
parent 9cdf868755
commit 2a8e9a3707
2 changed files with 12 additions and 10 deletions

View File

@ -295,6 +295,8 @@ enum ipc_connection_types {
* main public functions * main public functions
**/ **/
struct ipc_error ipc_events_loop (struct ipc_ctx *, struct ipc_event *, int *timer);
struct ipc_error ipc_server_init (struct ipc_ctx *ctx, const char *sname); struct ipc_error ipc_server_init (struct ipc_ctx *ctx, const char *sname);
struct ipc_error ipc_connection (struct ipc_ctx *ctx, const char *sname); struct ipc_error ipc_connection (struct ipc_ctx *ctx, const char *sname);

View File

@ -12,7 +12,7 @@ int main(int argc, char * argv[], char **env)
argv = (char **) argv; argv = (char **) argv;
SECURE_DECLARATION(struct ipc_ctx, ctx); SECURE_DECLARATION(struct ipc_ctx, ctx);
long timer = 10; int timer = 10000; // 10 seconds timer
printf ("func 01 - server init...\n"); printf ("func 01 - server init...\n");
TEST_IPC_Q(ipc_server_init (&ctx, SERVICE_NAME), EXIT_FAILURE); TEST_IPC_Q(ipc_server_init (&ctx, SERVICE_NAME), EXIT_FAILURE);
@ -23,13 +23,13 @@ int main(int argc, char * argv[], char **env)
printf ("func 01 - service polling...\n"); printf ("func 01 - service polling...\n");
// listen only for a single client // listen only for a single client
TEST_IPC_Q(ipc_wait_event (&clients, &srv, &event, &timer), EXIT_FAILURE); TEST_IPC_Q(ipc_events_loop (&ctx, &event, &timer), EXIT_FAILURE);
switch (event.type) { switch (event.type) {
case IPC_EVENT_TYPE_TIMER : { case IPC_EVENT_TYPE_TIMER : {
fprintf(stderr, "time up!\n"); fprintf(stderr, "time up!\n");
timer = 10; timer = 10000;
}; };
break; break;
case IPC_EVENT_TYPE_CONNECTION : case IPC_EVENT_TYPE_CONNECTION :
@ -48,11 +48,11 @@ int main(int argc, char * argv[], char **env)
break; break;
} }
printf ("func 01 - closing clients...\n");
ipc_connections_free (&clients);
printf ("func 01 - closing server...\n"); printf ("func 01 - closing server...\n");
TEST_IPC_Q(ipc_server_close(&srv), EXIT_FAILURE); TEST_IPC_Q(ipc_close_all(&ctx), EXIT_FAILURE);
printf ("func 01 - closing ctx...\n");
ipc_connections_free (&ctx);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }