diff --git a/src/communication.c b/src/communication.c index aac0dc7..39d1877 100644 --- a/src/communication.c +++ b/src/communication.c @@ -296,8 +296,8 @@ struct ipc_error ipc_add_fd (struct ipc_ctx *ctx, int fd) // remove a connection from its file descriptor struct ipc_error ipc_del_fd (struct ipc_ctx *ctx, int fd) { - T_R ((ctx == NULL), IPC_ERROR_DEL_FD__NO_PARAM_CINFOS); - T_R ((ctx->cinfos == NULL || ctx->pollfd), IPC_ERROR_DEL_FD__EMPTY_LIST); + T_R ((ctx == NULL), IPC_ERROR_DEL_FD__NO_PARAM_CINFOS); + T_R ((ctx->cinfos == NULL || ctx->pollfd == NULL), IPC_ERROR_DEL_FD__EMPTY_LIST); for (size_t i = 0; i < ctx->size; i++) { if (ctx->pollfd[i].fd == fd) { @@ -339,7 +339,7 @@ struct ipc_error handle_new_message (struct ipc_event *event, struct ipc_ctx *ct // If the socket is associated to another one for ipcd: // read and write automatically and provide a new IPC_EVENT_TYPE indicating the switch. - if (ctx->switchdb.collection != NULL) { + if (ctx->switchdb.size > 0) { int talkingfd = ctx->pollfd[index].fd; int correspondingfd = ipc_switching_get (&ctx->switchdb, talkingfd); if (correspondingfd != -1) { diff --git a/src/ipc.h b/src/ipc.h index dc811a7..523b871 100644 --- a/src/ipc.h +++ b/src/ipc.h @@ -367,17 +367,6 @@ struct ipc_error service_path (char *path, const char *sname); * ipcd enumerations, structures and functions **/ -struct ipcd { - int cpt; - struct ipc_ctx ctx; - struct ipc_switchings TCP_TO_IPCFD; -}; - -struct ipc_error -ipc_wait_event_ipcd (struct ipc_ctx *ctx - , struct ipc_connection_info *cinfo // cinfo is NULL for clients - , struct ipc_event *event, struct ipc_switchings *switchdb, int *timer); - void ipc_switching_add (struct ipc_switchings *is, int orig, int dest); int ipc_switching_del (struct ipc_switchings *is, int fd); int ipc_switching_get (struct ipc_switchings *is, int fd); diff --git a/src/print.c b/src/print.c index f838322..6052073 100644 --- a/src/print.c +++ b/src/print.c @@ -21,6 +21,18 @@ void ipc_ctx_print (struct ipc_ctx *ctx) } } } + + if (ctx->switchdb.size > 0) { + printf ("Context.switchdb contains:\n"); + for (size_t i = 0; i < ctx->switchdb.size; i++) { + printf ("- %d <-> %d\n" + , ctx->switchdb.collection[i].orig + , ctx->switchdb.collection[i].dest); + } + } + else { + printf ("Context.switchdb is empty\n"); + } } void ipc_message_print (const struct ipc_message *m)