mirror of
https://github.com/fluencelabs/redis
synced 2025-04-25 10:32:14 +00:00
Modlue fork is killed when the parent exists
This commit is contained in:
parent
56258c6b7d
commit
78bbb9b58d
26
src/module.c
26
src/module.c
@ -5086,20 +5086,11 @@ int RM_ExitFromChild(int retcode)
|
|||||||
return REDISMODULE_OK;
|
return REDISMODULE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Can be used to kill the forked child process from the parent process.
|
void TerminateModuleForkChild(int wait) {
|
||||||
* child_pid whould be the return value of RedisModule_Fork. */
|
|
||||||
int RM_KillForkChild(int child_pid)
|
|
||||||
{
|
|
||||||
int statloc;
|
int statloc;
|
||||||
/* No module child? return. */
|
|
||||||
if (server.module_child_pid == -1) return REDISMODULE_ERR;
|
|
||||||
/* Make sure the module knows the pid it wants to kill (not trying to
|
|
||||||
* randomly kill other module's forks) */
|
|
||||||
if (server.module_child_pid != child_pid) return REDISMODULE_ERR;
|
|
||||||
/* Kill module child, wait for child exit. */
|
|
||||||
serverLog(LL_NOTICE,"Killing running module fork child: %ld",
|
serverLog(LL_NOTICE,"Killing running module fork child: %ld",
|
||||||
(long) server.module_child_pid);
|
(long) server.module_child_pid);
|
||||||
if (kill(server.module_child_pid,SIGUSR1) != -1) {
|
if (kill(server.module_child_pid,SIGUSR1) != -1 && wait) {
|
||||||
while(wait3(&statloc,0,NULL) != server.module_child_pid);
|
while(wait3(&statloc,0,NULL) != server.module_child_pid);
|
||||||
}
|
}
|
||||||
/* Reset the buffer accumulating changes while the child saves. */
|
/* Reset the buffer accumulating changes while the child saves. */
|
||||||
@ -5108,6 +5099,19 @@ int RM_KillForkChild(int child_pid)
|
|||||||
moduleForkInfo.done_handler_user_data = NULL;
|
moduleForkInfo.done_handler_user_data = NULL;
|
||||||
closeChildInfoPipe();
|
closeChildInfoPipe();
|
||||||
updateDictResizePolicy();
|
updateDictResizePolicy();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Can be used to kill the forked child process from the parent process.
|
||||||
|
* child_pid whould be the return value of RedisModule_Fork. */
|
||||||
|
int RM_KillForkChild(int child_pid)
|
||||||
|
{
|
||||||
|
/* No module child? return. */
|
||||||
|
if (server.module_child_pid == -1) return REDISMODULE_ERR;
|
||||||
|
/* Make sure the module knows the pid it wants to kill (not trying to
|
||||||
|
* randomly kill other module's forks) */
|
||||||
|
if (server.module_child_pid != child_pid) return REDISMODULE_ERR;
|
||||||
|
/* Kill module child, wait for child exit. */
|
||||||
|
TerminateModuleForkChild(1);
|
||||||
return REDISMODULE_OK;
|
return REDISMODULE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3551,6 +3551,12 @@ int prepareForShutdown(int flags) {
|
|||||||
killRDBChild();
|
killRDBChild();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Kill module child if there is one. */
|
||||||
|
if (server.module_child_pid != -1) {
|
||||||
|
serverLog(LL_WARNING,"There is a module fork child. Killing it!");
|
||||||
|
TerminateModuleForkChild(0);
|
||||||
|
}
|
||||||
|
|
||||||
if (server.aof_state != AOF_OFF) {
|
if (server.aof_state != AOF_OFF) {
|
||||||
/* Kill the AOF saving child as the AOF we already have may be longer
|
/* Kill the AOF saving child as the AOF we already have may be longer
|
||||||
* but contains the full dataset anyway. */
|
* but contains the full dataset anyway. */
|
||||||
|
@ -1532,6 +1532,7 @@ void moduleReleaseGIL(void);
|
|||||||
void moduleNotifyKeyspaceEvent(int type, const char *event, robj *key, int dbid);
|
void moduleNotifyKeyspaceEvent(int type, const char *event, robj *key, int dbid);
|
||||||
void moduleCallCommandFilters(client *c);
|
void moduleCallCommandFilters(client *c);
|
||||||
void ModuleForkDoneHandler(int exitcode, int bysignal);
|
void ModuleForkDoneHandler(int exitcode, int bysignal);
|
||||||
|
void TerminateModuleForkChild(int wait);
|
||||||
|
|
||||||
/* Utils */
|
/* Utils */
|
||||||
long long ustime(void);
|
long long ustime(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user