fixed pipe mapping for modules

This commit is contained in:
Tomasz Poradowski
2019-09-23 10:49:24 +02:00
parent 97221cd488
commit aec03b32d9
4 changed files with 18 additions and 4 deletions
+14 -2
View File
@@ -474,8 +474,20 @@ int FDAPI_pipe(int *pfds) {
// Not passing _O_NOINHERIT, the underlying handles are inheritable by default
result = crt_pipe(pfds, 8192, _O_BINARY);
if (result == 0) {
//pfds[0] = RFDMap::getInstance().addCrtFD(pfds[0]);
//pfds[1] = RFDMap::getInstance().addCrtFD(pfds[1]);
pfds[0] = RFDMap::getInstance().addCrtFD(pfds[0]);
pfds[1] = RFDMap::getInstance().addCrtFD(pfds[1]);
}
} CATCH_AND_REPORT();
return result;
}
int FDAPI_pipe_for_modules(int* pfds) {
int result = -1;
try {
// Not passing _O_NOINHERIT, the underlying handles are inheritable by default
result = crt_pipe(pfds, 8192, _O_BINARY);
if (result == 0) {
//[tporadowski] when pipe is created for communication with modules - pretend it is a socket to
// get proper SocketInfo instance created and added in RFDMap; it is later needed
// when creating AE events in server.c/initServer()
+2
View File
@@ -220,6 +220,8 @@ extern int FDAPI_setmode(int fd, int mode);
extern size_t FDAPI_fwrite(const void *buffer, size_t size, size_t count, FILE *file);
extern int FDAPI_fileno(FILE *file);
int FDAPI_pipe_for_modules(int* pfds);
// Macroize CRT definitions to point to our own
#ifndef FDAPI_NOCRTREDEFS
#define close(fd) FDAPI_close(fd)
+1 -1
View File
@@ -223,7 +223,7 @@ static void killAppendOnlyChild(void) {
POSIX_ONLY(int statloc;)
/* No AOFRW child? return. */
if (server.aof_child_pid != -1)return;
if (server.aof_child_pid == -1)return;
/* Kill AOFRW child, wait for child exit. */
+1 -1
View File
@@ -3902,7 +3902,7 @@ void moduleInitModulesSystem(void) {
moduleKeyspaceSubscribersClient->flags |= CLIENT_MODULE;
moduleRegisterCoreAPI();
if (pipe(server.module_blocked_pipe) == -1) {
if (IF_WIN32(FDAPI_pipe_for_modules,pipe)(server.module_blocked_pipe) == -1) {
serverLog(LL_WARNING,
"Can't create the pipe for module blocking commands: %s",
IF_WIN32(wsa_strerror(errno), strerror(errno)));