MINOR: fd: Move (de)allocation of fdtab and fdinfo in (de)init_pollers
This will be useful for the threads support integration.
This commit is contained in:
parent
d82b180d6b
commit
63fe65277a
23
src/fd.c
23
src/fd.c
|
@ -270,10 +270,16 @@ int init_pollers()
|
||||||
int p;
|
int p;
|
||||||
struct poller *bp;
|
struct poller *bp;
|
||||||
|
|
||||||
if ((fd_cache = calloc(1, sizeof(uint32_t) * global.maxsock)) == NULL)
|
if ((fdtab = calloc(global.maxsock, sizeof(struct fdtab))) == NULL)
|
||||||
|
goto fail_tab;
|
||||||
|
|
||||||
|
if ((fdinfo = calloc(global.maxsock, sizeof(struct fdinfo))) == NULL)
|
||||||
|
goto fail_info;
|
||||||
|
|
||||||
|
if ((fd_cache = calloc(global.maxsock, sizeof(*fd_cache))) == NULL)
|
||||||
goto fail_cache;
|
goto fail_cache;
|
||||||
|
|
||||||
if ((fd_updt = calloc(1, sizeof(uint32_t) * global.maxsock)) == NULL)
|
if ((fd_updt = calloc(global.maxsock, sizeof(*fd_updt))) == NULL)
|
||||||
goto fail_updt;
|
goto fail_updt;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
@ -295,6 +301,10 @@ int init_pollers()
|
||||||
fail_updt:
|
fail_updt:
|
||||||
free(fd_cache);
|
free(fd_cache);
|
||||||
fail_cache:
|
fail_cache:
|
||||||
|
free(fdinfo);
|
||||||
|
fail_info:
|
||||||
|
free(fdtab);
|
||||||
|
fail_tab:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,11 +322,10 @@ void deinit_pollers() {
|
||||||
if (bp && bp->pref)
|
if (bp && bp->pref)
|
||||||
bp->term(bp);
|
bp->term(bp);
|
||||||
}
|
}
|
||||||
|
free(fd_updt); fd_updt = NULL;
|
||||||
free(fd_updt);
|
free(fd_cache); fd_cache = NULL;
|
||||||
free(fd_cache);
|
free(fdinfo); fdinfo = NULL;
|
||||||
fd_updt = NULL;
|
free(fdtab); fdtab = NULL;
|
||||||
fd_cache = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1718,9 +1718,6 @@ static void init(int argc, char **argv)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fdinfo = calloc(1, sizeof(struct fdinfo) * (global.maxsock));
|
|
||||||
fdtab = calloc(1, sizeof(struct fdtab) * (global.maxsock));
|
|
||||||
/*
|
/*
|
||||||
* Note: we could register external pollers here.
|
* Note: we could register external pollers here.
|
||||||
* Built-in pollers have been registered before main().
|
* Built-in pollers have been registered before main().
|
||||||
|
@ -2118,8 +2115,6 @@ void deinit(void)
|
||||||
free(global.pidfile); global.pidfile = NULL;
|
free(global.pidfile); global.pidfile = NULL;
|
||||||
free(global.node); global.node = NULL;
|
free(global.node); global.node = NULL;
|
||||||
free(global.desc); global.desc = NULL;
|
free(global.desc); global.desc = NULL;
|
||||||
free(fdinfo); fdinfo = NULL;
|
|
||||||
free(fdtab); fdtab = NULL;
|
|
||||||
free(oldpids); oldpids = NULL;
|
free(oldpids); oldpids = NULL;
|
||||||
free(global_listener_queue_task); global_listener_queue_task = NULL;
|
free(global_listener_queue_task); global_listener_queue_task = NULL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue