Skip to content

Commit

Permalink
Merge pull request #21481 from vespa-engine/balder/gc-unused-code-1
Browse files Browse the repository at this point in the history
GC unused code.
  • Loading branch information
baldersheim authored Mar 1, 2022
2 parents 470b59d + 5c079f8 commit 6dd5ec3
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 178 deletions.
4 changes: 2 additions & 2 deletions fastos/src/tests/processtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class ProcessTest : public BaseTest
{
TestHeader("PollWait Test");

FastOS_Process *xproc = new FastOS_Process("sort", true);
FastOS_Process *xproc = new FastOS_Process("sort");

if(xproc->Create())
{
Expand Down Expand Up @@ -168,7 +168,7 @@ class ProcessTest : public BaseTest
for(j=0; j<numEachTime; j++)
{
FastOS_ProcessInterface *xproc =
new FastOS_Process("sort", true,
new FastOS_Process("sort",
new MyListener("STDOUT"),
new MyListener("STDERR"));

Expand Down
6 changes: 1 addition & 5 deletions fastos/src/vespa/fastos/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@
#include "process.h"

FastOS_ProcessInterface::FastOS_ProcessInterface (const char *cmdLine,
bool pipeStdin,
FastOS_ProcessRedirectListener *stdoutListener,
FastOS_ProcessRedirectListener *stderrListener,
int bufferSize) :
FastOS_ProcessRedirectListener *stderrListener) :
_cmdLine(cmdLine),
_pipeStdin(pipeStdin),
_stdoutListener(stdoutListener),
_stderrListener(stderrListener),
_bufferSize(bufferSize),
_next(nullptr),
_prev(nullptr)
{
Expand Down
14 changes: 3 additions & 11 deletions fastos/src/vespa/fastos/process.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,12 @@ class FastOS_ApplicationInterface;
*/
class FastOS_ProcessInterface
{
private:
FastOS_ProcessInterface(const FastOS_ProcessInterface&);
FastOS_ProcessInterface &operator=(const FastOS_ProcessInterface &);

protected:

std::string _cmdLine;
bool _pipeStdin;

FastOS_ProcessRedirectListener *_stdoutListener;
FastOS_ProcessRedirectListener *_stderrListener;

int _bufferSize;
public:
FastOS_ProcessInterface *_next, *_prev;
static FastOS_ApplicationInterface *_app;
Expand All @@ -74,17 +67,16 @@ class FastOS_ProcessInterface
* Constructor. Does not start the process, use @ref Create or
* @ref CreateWithShell to actually start the process.
* @param cmdLine Command line
* @param pipeStdin set to true in order to redirect stdin
* @param stdoutListener non-nullptr to redirect stdout
* @param stderrListener non-nullptr to redirect stderr
* @param bufferSize Size of redirect buffers
*/
FastOS_ProcessInterface (const char *cmdLine,
bool pipeStdin = false,
FastOS_ProcessRedirectListener *stdoutListener = nullptr,
FastOS_ProcessRedirectListener *stderrListener = nullptr,
int bufferSize = 65535);
FastOS_ProcessRedirectListener *stderrListener = nullptr);

FastOS_ProcessInterface(const FastOS_ProcessInterface&) = delete;
FastOS_ProcessInterface &operator=(const FastOS_ProcessInterface &) = delete;
/**
* Destructor.
* If @ref Wait has not been called yet, it is called here.
Expand Down
15 changes: 7 additions & 8 deletions fastos/src/vespa/fastos/unix_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


FastOS_UNIX_Application::FastOS_UNIX_Application ()
: _processStarter(nullptr),
: _processStarter(),
_ipcHelper(nullptr)
{
}
Expand All @@ -31,8 +31,8 @@ extern char **environ;

int
FastOS_UNIX_Application::GetOpt (const char *optionsString,
const char* &optionArgument,
int &optionIndex)
const char* &optionArgument,
int &optionIndex)
{
int rc = getopt(_argc, _argv, optionsString);
optionArgument = optarg;
Expand Down Expand Up @@ -74,7 +74,7 @@ bool FastOS_UNIX_Application::PreThreadInit ()
sigaction(SIGPIPE, &act, nullptr);

if (useProcessStarter()) {
_processStarter = new FastOS_UNIX_ProcessStarter(this);
_processStarter = std::make_unique<FastOS_UNIX_ProcessStarter>(this);
}
} else {
rc = false;
Expand Down Expand Up @@ -107,15 +107,14 @@ void FastOS_UNIX_Application::Cleanup ()
if(_ipcHelper != nullptr)
_ipcHelper->Exit();

if (_processStarter != nullptr) {
if (_processStarter) {
{
std::unique_lock<std::mutex> guard;
if (_processListMutex) {
guard = getProcessGuard();
}
}
delete _processStarter;
_processStarter = nullptr;
_processStarter.reset();
}

FastOS_ApplicationInterface::Cleanup();
Expand All @@ -124,7 +123,7 @@ void FastOS_UNIX_Application::Cleanup ()
FastOS_UNIX_ProcessStarter *
FastOS_UNIX_Application::GetProcessStarter ()
{
return _processStarter;
return _processStarter.get();
}

void FastOS_UNIX_Application::
Expand Down
3 changes: 2 additions & 1 deletion fastos/src/vespa/fastos/unix_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "types.h"
#include "app.h"
#include <memory>

class FastOS_UNIX_ProcessStarter;
class FastOS_UNIX_IPCHelper;
Expand All @@ -25,7 +26,7 @@ class FastOS_UNIX_Application : public FastOS_ApplicationInterface
FastOS_UNIX_Application(const FastOS_UNIX_Application&);
FastOS_UNIX_Application& operator=(const FastOS_UNIX_Application&);

FastOS_UNIX_ProcessStarter *_processStarter;
std::unique_ptr<FastOS_UNIX_ProcessStarter> _processStarter;
FastOS_UNIX_IPCHelper *_ipcHelper;

protected:
Expand Down
Loading

0 comments on commit 6dd5ec3

Please sign in to comment.