Don't leak AE control pipes to fork children
Former-commit-id: 1ed2e8b5bcb485f7d1e073545a190bb95405a7d6
This commit is contained in:
parent
7069fcc695
commit
4f690c1f81
@ -808,3 +808,11 @@ int aeThreadOwnsLock()
|
||||
{
|
||||
return g_lock.fOwnLock();
|
||||
}
|
||||
|
||||
void aeClosePipesForForkChild(aeEventLoop *el)
|
||||
{
|
||||
close(el->fdCmdRead);
|
||||
el->fdCmdRead = -1;
|
||||
close(el->fdCmdWrite);
|
||||
el->fdCmdWrite = -1;
|
||||
}
|
1
src/ae.h
1
src/ae.h
@ -161,6 +161,7 @@ int aeGetSetSize(aeEventLoop *eventLoop);
|
||||
aeEventLoop *aeGetCurrentEventLoop();
|
||||
int aeResizeSetSize(aeEventLoop *eventLoop, int setsize);
|
||||
void aeSetDontWait(aeEventLoop *eventLoop, int noWait);
|
||||
void aeClosePipesForForkChild(aeEventLoop *eventLoop);
|
||||
|
||||
void setAeLockSetThreadSpinWorker(spin_worker worker);
|
||||
void aeAcquireLock();
|
||||
|
@ -878,6 +878,10 @@ void sentinelRunPendingScripts(void) {
|
||||
} else if (pid == 0) {
|
||||
/* Child */
|
||||
tlsCleanup();
|
||||
for (int iel = 0; iel < cserver.cthreads; ++iel) {
|
||||
aeClosePipesForForkChild(g_pserver->rgthreadvar[iel].el);
|
||||
}
|
||||
aeClosePipesForForkChild(g_pserver->modulethreadvar.el);
|
||||
execve(sj->argv[0],sj->argv,environ);
|
||||
/* If we are here an error occurred. */
|
||||
_exit(2); /* Don't retry execution. */
|
||||
|
@ -6192,6 +6192,11 @@ void closeChildUnusedResourceAfterFork() {
|
||||
if (g_pserver->cluster_enabled && g_pserver->cluster_config_file_lock_fd != -1)
|
||||
close(g_pserver->cluster_config_file_lock_fd); /* don't care if this fails */
|
||||
|
||||
for (int iel = 0; iel < cserver.cthreads; ++iel) {
|
||||
aeClosePipesForForkChild(g_pserver->rgthreadvar[iel].el);
|
||||
}
|
||||
aeClosePipesForForkChild(g_pserver->modulethreadvar.el);
|
||||
|
||||
/* Clear cserver.pidfile, this is the parent pidfile which should not
|
||||
* be touched (or deleted) by the child (on exit / crash) */
|
||||
zfree(cserver.pidfile);
|
||||
|
Loading…
x
Reference in New Issue
Block a user