diff --git a/src/input/input_event.cc b/src/input/input_event.cc index 530e0ca4..b6126540 100644 --- a/src/input/input_event.cc +++ b/src/input/input_event.cc @@ -13,7 +13,6 @@ void InputEvent::insert() { torrent::this_thread::poll()->open(this); torrent::this_thread::poll()->insert_read(this); - torrent::this_thread::poll()->insert_error(this); } void diff --git a/src/input/input_event.h b/src/input/input_event.h index 945605d9..b98a1d29 100644 --- a/src/input/input_event.h +++ b/src/input/input_event.h @@ -11,7 +11,7 @@ class InputEvent : public torrent::Event { public: typedef std::function slot_int; - InputEvent(int fd) { m_fileDesc = fd; } + InputEvent(int fd) { set_file_descriptor(fd); } const char* type_name() const override { return "input"; } diff --git a/src/rpc/exec_file.cc b/src/rpc/exec_file.cc index d3733885..51f77d37 100644 --- a/src/rpc/exec_file.cc +++ b/src/rpc/exec_file.cc @@ -1,5 +1,6 @@ #include "config.h" +#include #include #include #include @@ -24,6 +25,8 @@ namespace rpc { int ExecFile::execute(const char* file, char* const* argv, int flags) { + assert(!((flags & flag_capture) && (flags & flag_background))); + // Write the executed command and its parameters to the log fd. [[maybe_unused]] int result; diff --git a/src/rpc/scgi.cc b/src/rpc/scgi.cc index 8fc90d11..4f665547 100644 --- a/src/rpc/scgi.cc +++ b/src/rpc/scgi.cc @@ -111,7 +111,6 @@ SCgi::activate() { torrent::this_thread::poll()->open(this); torrent::this_thread::poll()->insert_read(this); - torrent::this_thread::poll()->insert_error(this); } // TODO: This should close the fd to avoid reuse. diff --git a/src/rpc/scgi_task.cc b/src/rpc/scgi_task.cc index f940f95c..f9a05882 100644 --- a/src/rpc/scgi_task.cc +++ b/src/rpc/scgi_task.cc @@ -27,7 +27,7 @@ namespace rpc { SCgiTask::SCgiTask() : m_callback_id(torrent::system::make_callback_id()) { - set_file_descriptor(-1); + reset_file_descriptor(); } void @@ -49,7 +49,6 @@ SCgiTask::open(SCgi* parent, int fd) { torrent::this_thread::poll()->open(this); torrent::this_thread::poll()->insert_read(this); - torrent::this_thread::poll()->insert_error(this); auto lock = std::lock_guard(m_result_mutex); @@ -65,7 +64,7 @@ SCgiTask::cancel_open() { torrent::this_thread::poll()->remove_and_close(this); torrent::fd_close(file_descriptor()); - set_file_descriptor(-1); + reset_file_descriptor(); }; void @@ -79,7 +78,7 @@ SCgiTask::close() { torrent::this_thread::poll()->remove_and_close(this); torrent::fd_close(file_descriptor()); - set_file_descriptor(-1); + reset_file_descriptor(); }); // The callbacks are guaranteed to be finished/canceled at this point. @@ -98,7 +97,7 @@ SCgiTask::event_read() { if (read_length <= 0) throw torrent::internal_error("SCgiTask::event_read() no space in buffer for event_read."); - int bytes = ::recv(m_fileDesc, m_buffer.data() + m_position, read_length, 0); + int bytes = ::recv(file_descriptor(), m_buffer.data() + m_position, read_length, 0); if (bytes <= 0) { if (bytes == 0 || !(errno == EAGAIN || errno == EINTR)) @@ -181,7 +180,7 @@ event_read_failed: void SCgiTask::event_write() { - int bytes = ::send(m_fileDesc, m_buffer.data() + m_position, m_buffer.size() - m_position, 0); + int bytes = ::send(file_descriptor(), m_buffer.data() + m_position, m_buffer.size() - m_position, 0); if (bytes == -1) { if (!(errno == EAGAIN || errno == EINTR)) diff --git a/src/rpc/scgi_task.h b/src/rpc/scgi_task.h index 1b3961b1..8cb30184 100644 --- a/src/rpc/scgi_task.h +++ b/src/rpc/scgi_task.h @@ -22,8 +22,8 @@ public: const char* type_name() const override { return "scgi-task"; } - bool is_open() const { return m_fileDesc != -1; } - bool is_available() const { return m_fileDesc == -1; } + bool is_open() const { return file_descriptor() != -1; } + bool is_available() const { return file_descriptor() == -1; } void open(SCgi* parent, int fd); void cancel_open();