Obsolete
/
libipc-old
Archived
3
0
Fork 0

corrections

pollfd
Karchnu 2020-07-04 19:03:21 +02:00
parent bef3b28656
commit 6243b818f1
3 changed files with 15 additions and 14 deletions

View File

@ -296,8 +296,8 @@ struct ipc_error ipc_add_fd (struct ipc_ctx *ctx, int fd)
// remove a connection from its file descriptor // remove a connection from its file descriptor
struct ipc_error ipc_del_fd (struct ipc_ctx *ctx, int fd) 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 == NULL), IPC_ERROR_DEL_FD__NO_PARAM_CINFOS);
T_R ((ctx->cinfos == NULL || ctx->pollfd), IPC_ERROR_DEL_FD__EMPTY_LIST); T_R ((ctx->cinfos == NULL || ctx->pollfd == NULL), IPC_ERROR_DEL_FD__EMPTY_LIST);
for (size_t i = 0; i < ctx->size; i++) { for (size_t i = 0; i < ctx->size; i++) {
if (ctx->pollfd[i].fd == fd) { 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: // If the socket is associated to another one for ipcd:
// read and write automatically and provide a new IPC_EVENT_TYPE indicating the switch. // 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 talkingfd = ctx->pollfd[index].fd;
int correspondingfd = ipc_switching_get (&ctx->switchdb, talkingfd); int correspondingfd = ipc_switching_get (&ctx->switchdb, talkingfd);
if (correspondingfd != -1) { if (correspondingfd != -1) {

View File

@ -367,17 +367,6 @@ struct ipc_error service_path (char *path, const char *sname);
* ipcd enumerations, structures and functions * 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); 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_del (struct ipc_switchings *is, int fd);
int ipc_switching_get (struct ipc_switchings *is, int fd); int ipc_switching_get (struct ipc_switchings *is, int fd);

View File

@ -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) void ipc_message_print (const struct ipc_message *m)