Unverified Commit 568c2e03 authored by Ozan Tezcan's avatar Ozan Tezcan Committed by GitHub
Browse files

Set errno to EEXIST in redisFork() if child process exists (#10059)

Callers of redisFork() are logging `strerror(errno)` on failure.
`errno` is not set when there is already a child process, causing printing
current value of errno which was set before `redisFork()` call. 

Setting errno to EEXIST on this failure to provide more meaningful error message. 
parent 5dd15443
...@@ -5937,8 +5937,10 @@ void closeChildUnusedResourceAfterFork() { ...@@ -5937,8 +5937,10 @@ void closeChildUnusedResourceAfterFork() {
/* purpose is one of CHILD_TYPE_ types */ /* purpose is one of CHILD_TYPE_ types */
int redisFork(int purpose) { int redisFork(int purpose) {
if (isMutuallyExclusiveChildType(purpose)) { if (isMutuallyExclusiveChildType(purpose)) {
if (hasActiveChildProcess()) if (hasActiveChildProcess()) {
errno = EEXIST;
return -1; return -1;
}
openChildInfoPipe(); openChildInfoPipe();
} }
......
...@@ -32,4 +32,11 @@ start_server {tags {"modules"}} { ...@@ -32,4 +32,11 @@ start_server {tags {"modules"}} {
assert {[count_log_message "fork child exiting"] eq "1"} assert {[count_log_message "fork child exiting"] eq "1"}
} }
test {Module fork twice} {
r fork.create 0
after 250
catch {r fork.create 0}
assert {[count_log_message "Can't fork for module: File exists"] eq "1"}
}
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment