Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed sigabort when quitting feathers #163

Merged
merged 1 commit into from
Dec 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/IpcServer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class IpcServer
{
public:
IpcServer(std::string const& socket, Server *server);
~IpcServer() = default;
~IpcServer();

private:
void acceptClients();
Expand All @@ -31,4 +31,5 @@ class IpcServer
std::thread acceptThread;
std::thread processThread;
std::mutex mutex;
bool shutdown;
};
20 changes: 16 additions & 4 deletions source/IpcServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,41 @@
#include <signal.h>

IpcServer::IpcServer(std::string const& socket, Server *server)
: ipcServer(socket)
: ipcServer(socket, SOCK_NONBLOCK)
, socket(socket)
, server(server)
, clients()
, acceptThread(&IpcServer::acceptClients, this)
, processThread(&IpcServer::processClients, this)
, mutex()
, shutdown(false)
{
// Ignore broken pipe
signal(SIGPIPE, SIG_IGN);
}

IpcServer::~IpcServer()
{
shutdown = true;
acceptThread.join();
processThread.join();
}

void IpcServer::acceptClients()
{
while (1)
{
try {
std::unique_ptr<libsocket::unix_stream_client> client = ipcServer.accept2();
usleep(10000);
if (shutdown)
break;
std::unique_ptr<libsocket::unix_stream_client> client = ipcServer.accept2(SOCK_NONBLOCK);
std::cout << "New ipc client" << std::endl;
mutex.lock();
clients.emplace_back(std::move(client));
mutex.unlock();

} catch (const libsocket::socket_exception& e) {
std::cerr << e.mesg;
}
}
}
Expand All @@ -43,7 +53,9 @@ void IpcServer::processClients()
unsigned int clientSize = -1;
while (1)
{
usleep(100);
usleep(10000);
if (shutdown)
break;
if (clients.empty())
continue;
int newSize = server->outputManager.workspaceCount;
Expand Down