diff options
Diffstat (limited to 'fastos')
-rw-r--r-- | fastos/src/vespa/fastos/unix_app.cpp | 26 | ||||
-rw-r--r-- | fastos/src/vespa/fastos/unix_ipc.cpp | 96 | ||||
-rw-r--r-- | fastos/src/vespa/fastos/unix_ipc.h | 3 | ||||
-rw-r--r-- | fastos/src/vespa/fastos/unix_process.cpp | 42 | ||||
-rw-r--r-- | fastos/src/vespa/fastos/unix_process.h | 1 |
5 files changed, 8 insertions, 160 deletions
diff --git a/fastos/src/vespa/fastos/unix_app.cpp b/fastos/src/vespa/fastos/unix_app.cpp index 565cf6e57ff..e862d65b00b 100644 --- a/fastos/src/vespa/fastos/unix_app.cpp +++ b/fastos/src/vespa/fastos/unix_app.cpp @@ -91,32 +91,6 @@ bool FastOS_UNIX_Application::Init () { int ipcDescriptor = -1; - char *env = getenv("FASTOS_IPC_PARENT"); - if(env != nullptr) - { - int commaCount=0; - int notDigitCount=0; - char *p = env; - while(*p != '\0') - { - if(*p == ',') - commaCount++; - else if((*p < '0') || (*p > '9')) - notDigitCount++; - p++; - } - - if((commaCount == 2) && (notDigitCount == 0)) - { - int ppid, gppid, descriptor; - sscanf(env, "%d,%d,%d", &ppid, &gppid, &descriptor); - - if(ppid == getppid() && (descriptor != -1)) - { - ipcDescriptor = descriptor; - } - } - } if (useIPCHelper()) { _ipcHelper = new FastOS_UNIX_IPCHelper(this, ipcDescriptor); GetThreadPool()->NewThread(_ipcHelper); diff --git a/fastos/src/vespa/fastos/unix_ipc.cpp b/fastos/src/vespa/fastos/unix_ipc.cpp index 09f8e6162f7..976dd39f5bf 100644 --- a/fastos/src/vespa/fastos/unix_ipc.cpp +++ b/fastos/src/vespa/fastos/unix_ipc.cpp @@ -10,13 +10,11 @@ #include <future> FastOS_UNIX_IPCHelper:: -FastOS_UNIX_IPCHelper (FastOS_ApplicationInterface *app, int descriptor) +FastOS_UNIX_IPCHelper (FastOS_ApplicationInterface *app, int) : _lock(), _exitFlag(false), - _app(app), - _appParentIPCDescriptor() + _app(app) { - _appParentIPCDescriptor._fd = descriptor; _wakeupPipe[0] = -1; _wakeupPipe[1] = -1; @@ -27,13 +25,6 @@ FastOS_UNIX_IPCHelper (FastOS_ApplicationInterface *app, int descriptor) SetBlocking(_wakeupPipe[0], false); SetBlocking(_wakeupPipe[1], true); } - - if(_appParentIPCDescriptor._fd != -1) { - _appParentIPCDescriptor._readBuffer.reset(new FastOS_RingBuffer(16384)); - _appParentIPCDescriptor._writeBuffer.reset(new FastOS_RingBuffer(16384)); - - SetBlocking(_appParentIPCDescriptor._fd, false); - } } FastOS_UNIX_IPCHelper::~FastOS_UNIX_IPCHelper () @@ -44,11 +35,6 @@ FastOS_UNIX_IPCHelper::~FastOS_UNIX_IPCHelper () if(_wakeupPipe[1] != -1) { close(_wakeupPipe[1]); } - if(_appParentIPCDescriptor._fd != -1) { - close(_appParentIPCDescriptor._fd); - } - _appParentIPCDescriptor._readBuffer.reset(); - _appParentIPCDescriptor._writeBuffer.reset(); } @@ -172,16 +158,6 @@ PerformAsyncIO() } } -void FastOS_UNIX_IPCHelper:: -PerformAsyncIPCIO() -{ - FastOS_UNIX_Process::DescriptorHandle &desc = _appParentIPCDescriptor; - if (desc._canRead) - (void) DoRead(desc); - if (desc._canWrite) - (void) DoWrite(desc); -} - void FastOS_UNIX_IPCHelper:: BuildPollChecks() @@ -201,15 +177,6 @@ BuildPollChecks() BuildPollCheck(true, desc._fd, desc._readBuffer.get(), &desc._wantRead); } } - - if(_appParentIPCDescriptor._writeBuffer.get() != nullptr) - BuildPollCheck(false, _appParentIPCDescriptor._fd, - _appParentIPCDescriptor._writeBuffer.get(), - &_appParentIPCDescriptor._wantWrite); - if(_appParentIPCDescriptor._readBuffer.get() != nullptr) - BuildPollCheck(true, _appParentIPCDescriptor._fd, - _appParentIPCDescriptor._readBuffer.get(), - &_appParentIPCDescriptor._wantRead); } @@ -297,30 +264,6 @@ BuildPollArray(pollfd **fds, unsigned int *nfds, unsigned int *allocnfds) } } - FastOS_UNIX_Process::DescriptorHandle &desc2 = _appParentIPCDescriptor; - - if (desc2._fd >= 0 && - (desc2._wantRead || desc2._wantWrite)) { - if (rfds >= rfdsEnd) { - rfds = ResizePollArray(fds, - allocnfds); - rfdsEnd = *fds + *allocnfds; - } - rfds->fd = desc2._fd; - rfds->events = 0; - if (desc2._wantRead) - rfds->events |= POLLRDNORM; - if (desc2._wantWrite) - rfds->events |= POLLWRNORM; - rfds->revents = 0; - desc2._pollIdx = pollIdx; - rfds++; - pollIdx++; - } else { - desc2._pollIdx = -1; - desc2._canRead = false; - desc2._canWrite = false; - } *nfds = rfds - *fds; } @@ -363,25 +306,6 @@ SavePollArray(pollfd *fds, unsigned int nfds) } } - FastOS_UNIX_Process::DescriptorHandle &desc2 = _appParentIPCDescriptor; - - if (desc2._fd >= 0 && - static_cast<unsigned int>(desc2._pollIdx) < nfds) { - int revents = fds[desc2._pollIdx].revents; - - if ((revents & - (POLLIN | POLLRDNORM | POLLERR | POLLHUP | POLLNVAL)) != 0) - desc2._canRead = true; - else - desc2._canRead = false; - if ((revents & - (POLLOUT | POLLWRNORM | POLLWRBAND | POLLERR | POLLHUP | - POLLNVAL)) != 0) - desc2._canWrite = true; - else - desc2._canWrite = false; - } - if ((fds[0].revents & (POLLIN | POLLERR | POLLHUP)) != 0) return true; else @@ -498,20 +422,7 @@ Run(FastOS_ThreadInterface *thisThread, void *arg) } if (exitFlag) { - if (_appParentIPCDescriptor._fd != -1) - { - if(_appParentIPCDescriptor._wantWrite) - { - // printf("still data to write\n"); - } - else - { - // printf("no more data to write, exitting\n"); - break; - } - } - else - break; + break; } for (;;) @@ -550,7 +461,6 @@ Run(FastOS_ThreadInterface *thisThread, void *arg) // Do actual IO (based on file descriptor sets and buffer contents) PerformAsyncIO(); } - PerformAsyncIPCIO(); // Did someone want to wake us up from the poll() call? if (woken) { diff --git a/fastos/src/vespa/fastos/unix_ipc.h b/fastos/src/vespa/fastos/unix_ipc.h index 62272856295..b0015e4315b 100644 --- a/fastos/src/vespa/fastos/unix_ipc.h +++ b/fastos/src/vespa/fastos/unix_ipc.h @@ -17,8 +17,6 @@ protected: volatile bool _exitFlag; FastOS_ApplicationInterface *_app; - FastOS_UNIX_Process::DescriptorHandle _appParentIPCDescriptor; - int _wakeupPipe[2]; bool DoWrite (FastOS_UNIX_Process::DescriptorHandle &desc); @@ -28,7 +26,6 @@ protected: void BuildPollArray(pollfd **fds, unsigned int *nfds, unsigned int *allocnfds); bool SavePollArray(pollfd *fds, unsigned int nfds); void PerformAsyncIO (); - void PerformAsyncIPCIO (); void BuildPollChecks(); void PipeData (FastOS_UNIX_Process *process, FastOS_UNIX_Process::DescriptorType type); void RemoveClosingProcesses(); diff --git a/fastos/src/vespa/fastos/unix_process.cpp b/fastos/src/vespa/fastos/unix_process.cpp index 7b2d158a26b..a67d47d58bd 100644 --- a/fastos/src/vespa/fastos/unix_process.cpp +++ b/fastos/src/vespa/fastos/unix_process.cpp @@ -14,10 +14,6 @@ #endif #include <thread> -#ifndef AF_LOCAL -#define AF_LOCAL AF_UNIX -#endif - extern "C" { @@ -74,7 +70,6 @@ private: int _stdinDes[2]; int _stdoutDes[2]; int _stderrDes[2]; - int _ipcSockPair[2]; int _handshakeDes[2]; std::string _runDir; std::string _stdoutRedirName; @@ -88,15 +83,10 @@ private: public: void SetRunDir(const char * runDir) { _runDir = runDir; } - int GetIPCDescriptor() const { return _ipcSockPair[0]; } + int GetStdinDescriptor() const { return _stdinDes[1]; } int GetStdoutDescriptor() const { return _stdoutDes[0]; } int GetStderrDescriptor() const { return _stderrDes[0]; } - int HandoverIPCDescriptor() { - int ret = _ipcSockPair[0]; - _ipcSockPair[0] = -1; - return ret; - } int HandoverStdinDescriptor() { int ret = _stdinDes[1]; @@ -116,7 +106,6 @@ public: return ret; } - void CloseIPCDescriptor(); void CloseStdinDescriptor(); void CloseStdoutDescriptor(); void CloseStderrDescriptor(); @@ -212,21 +201,12 @@ FastOS_UNIX_RealProcess::CloseDescriptors() CloseAndResetDescriptor(&_stdoutDes[1]); CloseAndResetDescriptor(&_stderrDes[0]); CloseAndResetDescriptor(&_stderrDes[1]); - CloseAndResetDescriptor(&_ipcSockPair[0]); - CloseAndResetDescriptor(&_ipcSockPair[1]); CloseAndResetDescriptor(&_handshakeDes[0]); CloseAndResetDescriptor(&_handshakeDes[1]); } void -FastOS_UNIX_RealProcess::CloseIPCDescriptor() -{ - CloseAndResetDescriptor(&_ipcSockPair[0]); -} - - -void FastOS_UNIX_RealProcess::CloseStdinDescriptor() { CloseAndResetDescriptor(&_stdinDes[1]); @@ -263,7 +243,6 @@ FastOS_UNIX_RealProcess::FastOS_UNIX_RealProcess(int streamMask) _stdinDes[0] = _stdinDes[1] = -1; _stdoutDes[0] = _stdoutDes[1] = -1; _stderrDes[0] = _stderrDes[1] = -1; - _ipcSockPair[0] = _ipcSockPair[1] = -1; _handshakeDes[0] = _handshakeDes[1] = -1; } @@ -457,7 +436,7 @@ ForkAndExec(const char *command, sprintf(environmentVariables[0], "%s=%d,%d,%d", "FASTOS_IPC_PARENT", - int(starterPid), int(starterPPid), _ipcSockPair[1]); + int(starterPid), int(starterPPid), -1); int numArguments = 0; @@ -492,7 +471,7 @@ ForkAndExec(const char *command, processStarter->CloseProxyDescs(IsStdinPiped() ? _stdinDes[0] : -1, IsStdoutPiped() ? _stdoutDes[1] : -1, IsStderrPiped() ? _stderrDes[1] : -1, - _ipcSockPair[1], + -1, _handshakeDes[0], _handshakeDes[1]); } @@ -539,8 +518,7 @@ ForkAndExec(const char *command, // printf("fdlimit = %d\n", fdlimit); for(int fd = STDERR_FILENO + 1; fd < fdlimit; fd++) { - if (fd != _ipcSockPair[1] && - fd != _handshakeDes[1]) + if (fd != _handshakeDes[1]) CloseDescriptor(fd); } } else { @@ -609,8 +587,6 @@ ForkAndExec(const char *command, CloseAndResetDescriptor(&_stderrDes[1]); } - CloseAndResetDescriptor(&_ipcSockPair[1]); - CloseAndResetDescriptor(&_handshakeDes[1]); int flags = fcntl(_handshakeDes[0], F_GETFL, 0); @@ -756,8 +732,6 @@ FastOS_UNIX_RealProcess::Setup() if (IsStdinPiped()) rc = rc && (pipe(_stdinDes) == 0); if (IsStdoutPiped()) rc = rc && (pipe(_stdoutDes) == 0); if (IsStderrPiped()) rc = rc && (pipe(_stderrDes) == 0); - if (!IsUsingShell()) rc = rc && (socketpair(AF_LOCAL, SOCK_STREAM, - 0, _ipcSockPair) == 0); rc = rc && (pipe(_handshakeDes) == 0); return rc; } @@ -780,9 +754,6 @@ FastOS_UNIX_Process (const char *cmdLine, bool pipeStdin, _killed(false), _closing(nullptr) { - _descriptor[TYPE_IPC]._readBuffer.reset(new FastOS_RingBuffer(bufferSize)); - _descriptor[TYPE_IPC]._writeBuffer.reset(new FastOS_RingBuffer(bufferSize)); - if (stdoutListener != nullptr) _descriptor[TYPE_STDOUT]._readBuffer.reset(new FastOS_RingBuffer(bufferSize)); if (stderrListener != nullptr) @@ -800,8 +771,7 @@ FastOS_UNIX_Process::~FastOS_UNIX_Process () { Kill(); // Kill if not dead or detached. - if ((GetDescriptorHandle(TYPE_IPC)._fd != -1) || - (GetDescriptorHandle(TYPE_STDOUT)._fd != -1) || + if ((GetDescriptorHandle(TYPE_STDOUT)._fd != -1) || (GetDescriptorHandle(TYPE_STDERR)._fd != -1)) { // Let the IPC helper flush write queues and remove us from the @@ -1057,8 +1027,6 @@ CreateProcess (FastOS_UNIX_Process *process, char **env = CopyEnvironmentVariables(); rprocess->SetTerse(); rprocess->Setup(); - if (!useShell) - process->SetDescriptor(FastOS_UNIX_Process::TYPE_IPC, rprocess->HandoverIPCDescriptor()); if (pipeStdin) process->SetDescriptor(FastOS_UNIX_Process::TYPE_STDIN, rprocess->HandoverStdinDescriptor()); if (pipeStdout) diff --git a/fastos/src/vespa/fastos/unix_process.h b/fastos/src/vespa/fastos/unix_process.h index 1feac863297..bce3813a161 100644 --- a/fastos/src/vespa/fastos/unix_process.h +++ b/fastos/src/vespa/fastos/unix_process.h @@ -64,7 +64,6 @@ public: { TYPE_STDOUT, TYPE_STDERR, - TYPE_IPC, TYPE_STDIN, TYPE_COUNT }; |