switching ok
parent
6243b818f1
commit
f1790cf314
|
@ -249,7 +249,7 @@ void exit_program (int signal)
|
||||||
|
|
||||||
// Close then free remaining ctx.
|
// Close then free remaining ctx.
|
||||||
ipc_close_all (ctx);
|
ipc_close_all (ctx);
|
||||||
// ipc_ctx_free (ctx);
|
ipc_ctx_free (ctx);
|
||||||
|
|
||||||
// free, free everything!
|
// free, free everything!
|
||||||
free (ctx);
|
free (ctx);
|
||||||
|
|
|
@ -394,7 +394,7 @@ struct ipc_error handle_new_message (struct ipc_event *event, struct ipc_ctx *ct
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
IPC_EVENT_SET (event, IPC_EVENT_TYPE_DISCONNECTION, index, ctx->pollfd[index].fd, NULL);
|
IPC_EVENT_SET (event, IPC_EVENT_TYPE_DISCONNECTION, index, talkingfd, NULL);
|
||||||
IPC_RETURN_ERROR (IPC_ERROR_CLOSED_RECIPIENT);
|
IPC_RETURN_ERROR (IPC_ERROR_CLOSED_RECIPIENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,5 +42,7 @@ void ipc_ctx_free (struct ipc_ctx *ctx)
|
||||||
}
|
}
|
||||||
ctx->size = 0;
|
ctx->size = 0;
|
||||||
|
|
||||||
|
ipc_switching_free(&ctx->switchdb);
|
||||||
|
|
||||||
ipc_messages_free (&ctx->tx);
|
ipc_messages_free (&ctx->tx);
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,13 @@ struct ipc_error ipc_provide_fd (int sock, int fd)
|
||||||
|
|
||||||
void ipc_switching_add (struct ipc_switchings *is, int orig, int dest)
|
void ipc_switching_add (struct ipc_switchings *is, int orig, int dest)
|
||||||
{
|
{
|
||||||
|
if (is->collection == NULL) {
|
||||||
|
is->collection = malloc (sizeof (struct ipc_switching) * (is->size + 1));
|
||||||
|
}
|
||||||
|
else {
|
||||||
is->collection = realloc (is->collection, sizeof (struct ipc_switching) * (is->size + 1));
|
is->collection = realloc (is->collection, sizeof (struct ipc_switching) * (is->size + 1));
|
||||||
|
}
|
||||||
|
|
||||||
if (is->collection == NULL) {
|
if (is->collection == NULL) {
|
||||||
fprintf (stderr, __FILE__ " error realloc line %d", __LINE__);
|
fprintf (stderr, __FILE__ " error realloc line %d", __LINE__);
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
|
@ -110,13 +116,12 @@ int ipc_switching_del (struct ipc_switchings *is, int fd)
|
||||||
is->collection[i].orig = is->collection[is->size - 1].orig;
|
is->collection[i].orig = is->collection[is->size - 1].orig;
|
||||||
is->collection[i].dest = is->collection[is->size - 1].dest;
|
is->collection[i].dest = is->collection[is->size - 1].dest;
|
||||||
|
|
||||||
size_t s = (is->size - 1) > 0 ? (is->size - 1) : 1;
|
if (is->size == 1) {
|
||||||
|
free(is->collection);
|
||||||
is->collection = realloc (is->collection, sizeof (struct ipc_switching) * s);
|
is->collection = NULL;
|
||||||
if (is->collection == NULL) {
|
}
|
||||||
/** TODO: not sure we want this behavior */
|
else {
|
||||||
fprintf (stderr, __FILE__ " error realloc line %d", __LINE__);
|
is->collection = realloc (is->collection, sizeof (struct ipc_switching) * (is->size-1));
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is->size--;
|
is->size--;
|
||||||
|
|
Reference in New Issue