2016-03-27 14:22:24 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
2017-12-20 07:06:26 -06:00
|
|
|
#include <config.h>
|
loolwsd: include cleanup and organization
A source file (.cpp) must include its own header first.
This insures that the header is self-contained and
doesn't depend on arbitrary (and accidental) includes
before it to compile.
Furthermore, system headers should go next, followed by
C then C++ headers, then libraries (Poco, etc) and, finally,
project headers come last.
This makes sure that headers and included in the same dependency
order to avoid side-effects. For example, Poco should never rely on
anything from our project in the same way that a C header should
never rely on anything in C++, Poco, or project headers.
Also, includes ought to be sorted where possible, to improve
readability and avoid accidental duplicates (of which there
were a few).
Change-Id: I62cc1343e4a091d69195e37ed659dba20cfcb1ef
Reviewed-on: https://gerrit.libreoffice.org/25262
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-21 09:23:07 -05:00
|
|
|
|
2017-03-08 10:38:22 -06:00
|
|
|
#include "IoUtil.hpp"
|
|
|
|
|
2016-03-27 14:22:24 -05:00
|
|
|
#include <sys/poll.h>
|
|
|
|
|
|
|
|
#include <cassert>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstring>
|
|
|
|
#include <iomanip>
|
|
|
|
#include <mutex>
|
|
|
|
#include <sstream>
|
|
|
|
#include <string>
|
|
|
|
|
loolwsd: include cleanup and organization
A source file (.cpp) must include its own header first.
This insures that the header is self-contained and
doesn't depend on arbitrary (and accidental) includes
before it to compile.
Furthermore, system headers should go next, followed by
C then C++ headers, then libraries (Poco, etc) and, finally,
project headers come last.
This makes sure that headers and included in the same dependency
order to avoid side-effects. For example, Poco should never rely on
anything from our project in the same way that a C header should
never rely on anything in C++, Poco, or project headers.
Also, includes ought to be sorted where possible, to improve
readability and avoid accidental duplicates (of which there
were a few).
Change-Id: I62cc1343e4a091d69195e37ed659dba20cfcb1ef
Reviewed-on: https://gerrit.libreoffice.org/25262
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-21 09:23:07 -05:00
|
|
|
#include <Poco/Net/NetException.h>
|
2016-04-12 15:13:19 -05:00
|
|
|
#include <Poco/Net/Socket.h>
|
loolwsd: include cleanup and organization
A source file (.cpp) must include its own header first.
This insures that the header is self-contained and
doesn't depend on arbitrary (and accidental) includes
before it to compile.
Furthermore, system headers should go next, followed by
C then C++ headers, then libraries (Poco, etc) and, finally,
project headers come last.
This makes sure that headers and included in the same dependency
order to avoid side-effects. For example, Poco should never rely on
anything from our project in the same way that a C header should
never rely on anything in C++, Poco, or project headers.
Also, includes ought to be sorted where possible, to improve
readability and avoid accidental duplicates (of which there
were a few).
Change-Id: I62cc1343e4a091d69195e37ed659dba20cfcb1ef
Reviewed-on: https://gerrit.libreoffice.org/25262
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-21 09:23:07 -05:00
|
|
|
#include <Poco/StringTokenizer.h>
|
2016-03-27 14:22:24 -05:00
|
|
|
#include <Poco/Thread.h>
|
2016-04-10 12:13:05 -05:00
|
|
|
#include <Poco/URI.h>
|
2016-03-27 14:22:24 -05:00
|
|
|
|
|
|
|
#include "Common.hpp"
|
2016-11-24 08:56:06 -06:00
|
|
|
#include "Protocol.hpp"
|
2017-12-20 07:06:26 -06:00
|
|
|
#include "LOOLWebSocket.hpp"
|
loolwsd: include cleanup and organization
A source file (.cpp) must include its own header first.
This insures that the header is self-contained and
doesn't depend on arbitrary (and accidental) includes
before it to compile.
Furthermore, system headers should go next, followed by
C then C++ headers, then libraries (Poco, etc) and, finally,
project headers come last.
This makes sure that headers and included in the same dependency
order to avoid side-effects. For example, Poco should never rely on
anything from our project in the same way that a C header should
never rely on anything in C++, Poco, or project headers.
Also, includes ought to be sorted where possible, to improve
readability and avoid accidental duplicates (of which there
were a few).
Change-Id: I62cc1343e4a091d69195e37ed659dba20cfcb1ef
Reviewed-on: https://gerrit.libreoffice.org/25262
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-21 09:23:07 -05:00
|
|
|
#include "Log.hpp"
|
2016-03-27 14:22:24 -05:00
|
|
|
#include "Util.hpp"
|
|
|
|
|
2019-05-27 02:09:49 -05:00
|
|
|
using Poco::Net::Socket;
|
2016-03-27 15:06:22 -05:00
|
|
|
using Poco::Net::WebSocket;
|
|
|
|
|
2016-04-04 06:21:04 -05:00
|
|
|
namespace IoUtil
|
|
|
|
{
|
|
|
|
|
2016-11-10 02:47:25 -06:00
|
|
|
// Synchronously process LOOLWebSocket requests and dispatch to handler.
|
2016-03-27 15:06:22 -05:00
|
|
|
// Handler returns false to end.
|
2016-11-10 02:47:25 -06:00
|
|
|
void SocketProcessor(const std::shared_ptr<LOOLWebSocket>& ws,
|
2016-11-13 21:23:04 -06:00
|
|
|
const std::string& name,
|
2016-04-27 07:58:33 -05:00
|
|
|
const std::function<bool(const std::vector<char>&)>& handler,
|
|
|
|
const std::function<void()>& closeFrame,
|
|
|
|
const std::function<bool()>& stopPredicate)
|
2016-03-27 15:06:22 -05:00
|
|
|
{
|
2016-11-13 21:23:04 -06:00
|
|
|
LOG_INF("SocketProcessor [" << name << "] starting.");
|
2016-03-27 15:06:22 -05:00
|
|
|
|
|
|
|
// Timeout given is in microseconds.
|
2016-05-07 08:45:57 -05:00
|
|
|
static const Poco::Timespan waitTime(POLL_TIMEOUT_MS * 1000);
|
2016-11-13 20:52:02 -06:00
|
|
|
int flags = 0;
|
|
|
|
int n = -1;
|
|
|
|
bool stop = false;
|
2016-11-26 21:28:48 -06:00
|
|
|
std::vector<char> payload(READ_BUFFER_SIZE);
|
2016-11-26 21:39:48 -06:00
|
|
|
payload.resize(0);
|
2016-03-27 15:06:22 -05:00
|
|
|
try
|
|
|
|
{
|
2016-11-26 21:39:48 -06:00
|
|
|
// We poll, no need for timeout.
|
2016-03-27 15:06:22 -05:00
|
|
|
ws->setReceiveTimeout(0);
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
stop = stopPredicate();
|
|
|
|
if (stop)
|
|
|
|
{
|
2016-11-13 21:23:04 -06:00
|
|
|
LOG_INF("SocketProcessor [" << name << "]: Stop flagged.");
|
2016-03-27 15:06:22 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-05-02 18:53:13 -05:00
|
|
|
if (!ws->poll(waitTime, Poco::Net::Socket::SELECT_READ) ||
|
|
|
|
stopPredicate())
|
2016-03-27 15:06:22 -05:00
|
|
|
{
|
2016-12-12 20:48:42 -06:00
|
|
|
// If SELECT_READ fails, it might mean the socket is in error.
|
|
|
|
if (ws->poll(Poco::Timespan(0), Poco::Net::Socket::SELECT_ERROR))
|
|
|
|
{
|
|
|
|
LOG_WRN("SocketProcessor [" << name << "]: Socket error.");
|
|
|
|
closeFrame();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-03-27 15:06:22 -05:00
|
|
|
// Wait some more.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-09-01 11:44:51 -05:00
|
|
|
try
|
|
|
|
{
|
2016-11-25 03:48:59 -06:00
|
|
|
payload.resize(payload.capacity());
|
2016-12-12 20:48:42 -06:00
|
|
|
n = -1; // In case receiveFrame throws we log dropped data below.
|
2016-12-01 11:15:46 -06:00
|
|
|
(void)n;
|
2016-11-26 21:28:48 -06:00
|
|
|
n = ws->receiveFrame(payload.data(), payload.size(), flags);
|
|
|
|
payload.resize(std::max(n, 0));
|
2016-09-01 11:44:51 -05:00
|
|
|
}
|
2016-09-01 14:11:41 -05:00
|
|
|
catch (const Poco::TimeoutException&)
|
2016-09-01 11:44:51 -05:00
|
|
|
{
|
2016-11-13 21:23:04 -06:00
|
|
|
LOG_DBG("SocketProcessor [" << name << "]: Spurious TimeoutException, ignored");
|
2016-09-01 11:44:51 -05:00
|
|
|
continue;
|
|
|
|
}
|
2016-03-27 15:06:22 -05:00
|
|
|
|
2016-12-12 20:48:42 -06:00
|
|
|
if (n == 0 || ((flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_CLOSE))
|
2016-03-27 15:06:22 -05:00
|
|
|
{
|
2016-11-13 21:23:04 -06:00
|
|
|
LOG_WRN("SocketProcessor [" << name << "]: Connection closed.");
|
2016-11-13 20:52:02 -06:00
|
|
|
closeFrame();
|
2016-03-27 15:06:22 -05:00
|
|
|
break;
|
|
|
|
}
|
2016-12-12 20:48:42 -06:00
|
|
|
else if (n < 0)
|
|
|
|
{
|
|
|
|
LOG_DBG("SocketProcessor [" << name << "]: was not an interesting frame, nothing to do here");
|
|
|
|
continue;
|
|
|
|
}
|
2016-03-27 15:06:22 -05:00
|
|
|
|
2016-12-12 22:31:00 -06:00
|
|
|
LOG_CHECK(n > 0);
|
2016-03-27 15:06:22 -05:00
|
|
|
|
|
|
|
if ((flags & WebSocket::FrameFlags::FRAME_FLAG_FIN) != WebSocket::FrameFlags::FRAME_FLAG_FIN)
|
|
|
|
{
|
|
|
|
// One WS message split into multiple frames.
|
2016-11-13 20:52:02 -06:00
|
|
|
// TODO: Is this even possible with Poco if we never construct such messages outselves?
|
2016-12-12 20:48:42 -06:00
|
|
|
LOG_WRN("SocketProcessor [" << name << "]: Receiving multi-part frame.");
|
2016-03-27 15:06:22 -05:00
|
|
|
while (true)
|
|
|
|
{
|
2016-11-26 21:28:48 -06:00
|
|
|
char buffer[READ_BUFFER_SIZE];
|
2016-11-25 03:48:59 -06:00
|
|
|
n = ws->receiveFrame(buffer, sizeof(buffer), flags);
|
2016-12-12 20:48:42 -06:00
|
|
|
if (n == 0 || (flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_CLOSE)
|
2016-03-27 15:06:22 -05:00
|
|
|
{
|
2016-11-13 21:23:04 -06:00
|
|
|
LOG_WRN("SocketProcessor [" << name << "]: Connection closed while reading multiframe message.");
|
2016-11-13 20:52:02 -06:00
|
|
|
closeFrame();
|
2016-03-27 15:06:22 -05:00
|
|
|
break;
|
|
|
|
}
|
2016-12-12 20:48:42 -06:00
|
|
|
else if (n < 0)
|
|
|
|
{
|
|
|
|
LOG_DBG("SocketProcessor [" << name << "]: was not an interesting frame, nothing to do here");
|
|
|
|
continue;
|
|
|
|
}
|
2016-03-27 15:06:22 -05:00
|
|
|
|
2016-11-25 03:48:59 -06:00
|
|
|
payload.insert(payload.end(), buffer, buffer + n);
|
2016-03-27 15:06:22 -05:00
|
|
|
if ((flags & WebSocket::FrameFlags::FRAME_FLAG_FIN) == WebSocket::FrameFlags::FRAME_FLAG_FIN)
|
|
|
|
{
|
|
|
|
// No more frames.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-12 22:31:00 -06:00
|
|
|
LOG_CHECK(n > 0);
|
2016-03-27 15:06:22 -05:00
|
|
|
|
|
|
|
// Call the handler.
|
2018-02-07 03:17:19 -06:00
|
|
|
const bool success = handler(payload);
|
2016-04-09 14:41:32 -05:00
|
|
|
payload.resize(0);
|
|
|
|
|
|
|
|
if (!success)
|
2016-03-27 15:06:22 -05:00
|
|
|
{
|
2016-11-13 21:23:04 -06:00
|
|
|
LOG_INF("SocketProcessor [" << name << "]: Handler flagged to finish.");
|
2016-03-27 15:06:22 -05:00
|
|
|
break;
|
|
|
|
}
|
2016-11-26 21:39:48 -06:00
|
|
|
|
|
|
|
if (payload.capacity() > READ_BUFFER_SIZE * 4)
|
|
|
|
{
|
|
|
|
LOG_INF("Compacting buffer of SocketProcessor [" << name << "] from " <<
|
|
|
|
payload.capacity() / 1024 << "KB to " << READ_BUFFER_SIZE / 1024 << "KB.");
|
|
|
|
payload = std::vector<char>(READ_BUFFER_SIZE);
|
|
|
|
payload.resize(0);
|
|
|
|
}
|
2016-03-27 15:06:22 -05:00
|
|
|
}
|
|
|
|
}
|
2016-04-09 14:41:32 -05:00
|
|
|
catch (const std::exception& exc)
|
2016-04-04 06:21:04 -05:00
|
|
|
{
|
2016-11-13 21:23:04 -06:00
|
|
|
LOG_ERR("SocketProcessor [" << name << "]: Exception: " << exc.what());
|
2016-04-04 06:21:04 -05:00
|
|
|
}
|
2016-03-27 15:06:22 -05:00
|
|
|
|
2016-11-13 20:52:02 -06:00
|
|
|
if ((flags & WebSocket::FRAME_OP_BITMASK) != WebSocket::FRAME_OP_CLOSE && n > 0 && payload.size() > 0)
|
|
|
|
{
|
|
|
|
std::string msg;
|
|
|
|
Poco::URI::encode(std::string(payload.data(), payload.size()), "", msg);
|
2016-11-13 21:23:04 -06:00
|
|
|
LOG_WRN("SocketProcessor [" << name << "]: Last message (" << payload.size() <<
|
2016-11-13 20:52:02 -06:00
|
|
|
" bytes) will not be processed: [" << msg << "].");
|
|
|
|
}
|
|
|
|
|
2016-11-13 21:23:04 -06:00
|
|
|
LOG_INF("SocketProcessor [" << name << "] finished. stop: " << (stop ? "true" : "false") <<
|
2016-11-13 20:52:02 -06:00
|
|
|
", n: " << n << ", payload size: " << payload.size() <<
|
|
|
|
", flags: " << std::hex << flags);
|
2016-03-27 15:06:22 -05:00
|
|
|
}
|
2016-03-27 14:22:24 -05:00
|
|
|
|
2016-10-12 11:07:54 -05:00
|
|
|
ssize_t writeToPipe(int pipe, const char* buffer, ssize_t size)
|
2016-03-27 14:22:24 -05:00
|
|
|
{
|
|
|
|
ssize_t count = 0;
|
2017-01-15 11:32:20 -06:00
|
|
|
for (;;)
|
2016-03-27 14:22:24 -05:00
|
|
|
{
|
2016-11-09 22:27:17 -06:00
|
|
|
LOG_TRC("Writing to pipe. Data: [" << Util::formatLinesForLog(std::string(buffer, size)) << "].");
|
2018-02-07 03:17:19 -06:00
|
|
|
const ssize_t bytes = write(pipe, buffer + count, size - count);
|
2016-03-27 14:22:24 -05:00
|
|
|
if (bytes < 0)
|
|
|
|
{
|
|
|
|
if (errno == EINTR || errno == EAGAIN)
|
2017-01-15 11:32:20 -06:00
|
|
|
{
|
2016-03-27 14:22:24 -05:00
|
|
|
continue;
|
2017-01-15 11:32:20 -06:00
|
|
|
}
|
2016-03-27 14:22:24 -05:00
|
|
|
|
2016-11-13 10:59:34 -06:00
|
|
|
LOG_SYS("Failed to write to pipe. Data: [" << std::string(buffer, size) << "].");
|
2016-03-27 14:22:24 -05:00
|
|
|
count = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (count + bytes < size)
|
|
|
|
{
|
|
|
|
count += bytes;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
count += bytes;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2016-10-12 11:07:54 -05:00
|
|
|
ssize_t readFromPipe(int pipe, char* buffer, ssize_t size)
|
2016-03-27 14:22:24 -05:00
|
|
|
{
|
|
|
|
ssize_t bytes;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
bytes = read(pipe, buffer, size);
|
|
|
|
}
|
|
|
|
while (bytes < 0 && errno == EINTR);
|
|
|
|
|
|
|
|
return bytes;
|
|
|
|
}
|
|
|
|
|
2016-03-28 13:22:18 -05:00
|
|
|
/// Reads a single line from a pipe.
|
|
|
|
/// Returns 0 for timeout, <0 for error, and >0 on success.
|
|
|
|
/// On success, line will contain the read message.
|
|
|
|
int PipeReader::readLine(std::string& line,
|
2016-04-27 07:58:33 -05:00
|
|
|
const std::function<bool()>& stopPredicate)
|
2016-03-27 14:22:24 -05:00
|
|
|
{
|
2016-03-28 13:22:18 -05:00
|
|
|
const char *endOfLine = static_cast<const char *>(std::memchr(_data.data(), '\n', _data.size()));
|
|
|
|
if (endOfLine != nullptr)
|
|
|
|
{
|
|
|
|
// We have a line cached, return it.
|
|
|
|
line += std::string(_data.data(), endOfLine);
|
|
|
|
_data.erase(0, endOfLine - _data.data() + 1); // Including the '\n'.
|
2016-11-09 22:27:17 -06:00
|
|
|
LOG_TRC("Read existing line from pipe: " << _name << ", line: [" <<
|
|
|
|
line << "], data: [" << Util::formatLinesForLog(_data) << "].");
|
2016-03-28 13:22:18 -05:00
|
|
|
return 1;
|
|
|
|
}
|
2016-03-27 14:22:24 -05:00
|
|
|
|
2016-03-28 13:22:18 -05:00
|
|
|
// Poll in short intervals to check for stop condition.
|
2018-02-07 03:17:19 -06:00
|
|
|
const int pollTimeoutMs = 500;
|
|
|
|
int maxPollCount = std::max<int>(POLL_TIMEOUT_MS / pollTimeoutMs, 1);
|
2016-03-28 13:22:18 -05:00
|
|
|
while (maxPollCount-- > 0)
|
2016-03-27 14:22:24 -05:00
|
|
|
{
|
2016-03-28 13:22:18 -05:00
|
|
|
if (stopPredicate())
|
|
|
|
{
|
2016-11-09 22:27:17 -06:00
|
|
|
LOG_INF("Stop requested for pipe: " << _name << '.');
|
2016-03-28 13:22:18 -05:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct pollfd pipe;
|
|
|
|
pipe.fd = _pipe;
|
|
|
|
pipe.events = POLLIN;
|
|
|
|
pipe.revents = 0;
|
|
|
|
const int ready = poll(&pipe, 1, pollTimeoutMs);
|
|
|
|
if (ready == 0)
|
|
|
|
{
|
|
|
|
// Timeout.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (ready < 0)
|
|
|
|
{
|
|
|
|
// error.
|
2016-11-15 07:00:07 -06:00
|
|
|
if (errno != EINTR)
|
|
|
|
{
|
|
|
|
LOG_SYS("Pipe polling failed.");
|
|
|
|
}
|
|
|
|
|
2016-03-28 13:22:18 -05:00
|
|
|
return ready;
|
|
|
|
}
|
|
|
|
else if (pipe.revents & (POLLIN | POLLPRI))
|
2016-03-27 14:22:24 -05:00
|
|
|
{
|
2016-03-28 13:22:18 -05:00
|
|
|
char buffer[READ_BUFFER_SIZE];
|
2018-02-07 03:17:19 -06:00
|
|
|
const ssize_t bytes = readFromPipe(_pipe, buffer, sizeof(buffer));
|
2016-11-09 22:27:17 -06:00
|
|
|
LOG_TRC("readFromPipe for pipe: " << _name << " returned: " << bytes);
|
2016-03-28 13:22:18 -05:00
|
|
|
if (bytes < 0)
|
2016-03-27 14:22:24 -05:00
|
|
|
{
|
2016-03-28 13:22:18 -05:00
|
|
|
return -1;
|
2016-03-27 14:22:24 -05:00
|
|
|
}
|
2016-03-28 13:22:18 -05:00
|
|
|
|
2016-03-30 02:39:48 -05:00
|
|
|
endOfLine = static_cast<const char *>(std::memchr(buffer, '\n', bytes));
|
2016-03-28 13:22:18 -05:00
|
|
|
if (endOfLine != nullptr)
|
2016-03-27 14:22:24 -05:00
|
|
|
{
|
2016-03-28 13:22:18 -05:00
|
|
|
// Got end of line.
|
|
|
|
line = _data;
|
2018-02-07 03:17:19 -06:00
|
|
|
const std::string tail(static_cast<const char*>(buffer), endOfLine);
|
2016-03-28 13:22:18 -05:00
|
|
|
line += tail;
|
2016-03-28 15:07:02 -05:00
|
|
|
_data = std::string(endOfLine + 1, bytes - tail.size() - 1); // Exclude the '\n'.
|
2016-11-09 22:27:17 -06:00
|
|
|
LOG_TRC("Read line from pipe: " << _name << ", line: [" << line <<
|
|
|
|
"], data: [" << Util::formatLinesForLog(_data) << "].");
|
2016-03-28 13:22:18 -05:00
|
|
|
return 1;
|
2016-03-27 14:22:24 -05:00
|
|
|
}
|
2016-03-28 13:22:18 -05:00
|
|
|
else
|
2016-03-27 14:22:24 -05:00
|
|
|
{
|
2016-03-28 13:22:18 -05:00
|
|
|
// More data, keep going.
|
|
|
|
_data += std::string(buffer, bytes);
|
2016-11-09 22:27:17 -06:00
|
|
|
LOG_TRC("data appended to pipe: " << _name << ", data: " << _data);
|
2016-03-27 14:22:24 -05:00
|
|
|
}
|
|
|
|
}
|
2016-03-28 13:22:18 -05:00
|
|
|
else if (pipe.revents & (POLLERR | POLLHUP | POLLNVAL))
|
2016-03-27 14:22:24 -05:00
|
|
|
{
|
2016-11-28 19:34:18 -06:00
|
|
|
LOG_FTL("Pipe closed.");
|
2016-03-28 13:22:18 -05:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
2016-03-27 14:22:24 -05:00
|
|
|
|
2016-03-28 13:22:18 -05:00
|
|
|
// Timeout.
|
|
|
|
return 0;
|
|
|
|
}
|
2016-03-27 14:22:24 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|