Better log cat move and free
This commit is contained in:
parent
e720930412
commit
9f4882eb67
1 changed files with 3 additions and 4 deletions
|
@ -65,6 +65,8 @@ void evt_core_add_cat(struct evt_core_ctx* ctx, struct evt_core_cat* cat) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void evt_core_mv_fd(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct evt_core_cat* to_cat) {
|
void evt_core_mv_fd(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct evt_core_cat* to_cat) {
|
||||||
|
printf("Moving fd=%d from cat=%s to cat=%s\n",fdinfo->fd, fdinfo->cat->name, to_cat->name);
|
||||||
|
|
||||||
// 1. Update old category
|
// 1. Update old category
|
||||||
for (int i = 0; i < fdinfo->cat->socklist->len; i++) {
|
for (int i = 0; i < fdinfo->cat->socklist->len; i++) {
|
||||||
if (g_array_index(fdinfo->cat->socklist, struct evt_core_fdinfo*, i) == fdinfo) {
|
if (g_array_index(fdinfo->cat->socklist, struct evt_core_fdinfo*, i) == fdinfo) {
|
||||||
|
@ -143,14 +145,11 @@ struct evt_core_cat* evt_core_rm_fd(struct evt_core_ctx* ctx, int fd) {
|
||||||
struct evt_core_fdinfo* fdinfo = g_hash_table_lookup (ctx->socklist, &fd);
|
struct evt_core_fdinfo* fdinfo = g_hash_table_lookup (ctx->socklist, &fd);
|
||||||
if (fdinfo == NULL) return NULL;
|
if (fdinfo == NULL) return NULL;
|
||||||
cat = fdinfo->cat;
|
cat = fdinfo->cat;
|
||||||
|
printf("Closing fd=%d from cat=%s\n",fdinfo->fd, fdinfo->cat->name);
|
||||||
|
|
||||||
// 2. Update category
|
// 2. Update category
|
||||||
for (int i = 0; i < cat->socklist->len; i++) {
|
for (int i = 0; i < cat->socklist->len; i++) {
|
||||||
if (g_array_index(cat->socklist, struct evt_core_fdinfo*, i) == fdinfo) {
|
if (g_array_index(cat->socklist, struct evt_core_fdinfo*, i) == fdinfo) {
|
||||||
if (fdinfo->fd != fd) {
|
|
||||||
fprintf(stderr, "Logic error in updating file descriptor list\n");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
g_array_remove_index(cat->socklist, i);
|
g_array_remove_index(cat->socklist, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue