mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-16 07:02:30 +00:00
Update to use new this_thread::Poll().
This commit is contained in:
+10
-6
@@ -1,5 +1,6 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <rak/error_number.h>
|
||||
#include <rak/socket_address.h>
|
||||
#include <sys/un.h>
|
||||
@@ -13,6 +14,7 @@
|
||||
#include "rpc/scgi_task.h"
|
||||
#include "utils/socket_fd.h"
|
||||
|
||||
// TODO: Figure out why moving this to the top causes a build error.
|
||||
#include "rpc/scgi.h"
|
||||
|
||||
namespace rpc {
|
||||
@@ -90,16 +92,18 @@ SCgi::open(void* sa, unsigned int length) {
|
||||
|
||||
void
|
||||
SCgi::activate() {
|
||||
worker_thread->poll()->open(this);
|
||||
worker_thread->poll()->insert_read(this);
|
||||
worker_thread->poll()->insert_error(this);
|
||||
assert(std::this_thread::get_id() == worker_thread->thread_id() && "SCgi::activate() must be called from the worker thread.");
|
||||
|
||||
torrent::this_thread::poll()->open(this);
|
||||
torrent::this_thread::poll()->insert_read(this);
|
||||
torrent::this_thread::poll()->insert_error(this);
|
||||
}
|
||||
|
||||
void
|
||||
SCgi::deactivate() {
|
||||
worker_thread->poll()->remove_read(this);
|
||||
worker_thread->poll()->remove_error(this);
|
||||
worker_thread->poll()->close(this);
|
||||
assert(std::this_thread::get_id() == worker_thread->thread_id() && "SCgi::deactivate() must be called from the worker thread.");
|
||||
|
||||
torrent::this_thread::poll()->remove_and_close(this);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+5
-5
@@ -18,9 +18,9 @@ public:
|
||||
static const int max_tasks = 100;
|
||||
|
||||
SCgi() : m_logFd(-1) {}
|
||||
virtual ~SCgi();
|
||||
~SCgi() override;
|
||||
|
||||
virtual const char* type_name() const { return "scgi"; }
|
||||
const char* type_name() const override { return "scgi"; }
|
||||
|
||||
void open_port(void* sa, unsigned int length, bool dontRoute);
|
||||
void open_named(const std::string& filename);
|
||||
@@ -33,9 +33,9 @@ public:
|
||||
int log_fd() const { return m_logFd; }
|
||||
void set_log_fd(int fd) { m_logFd = fd; }
|
||||
|
||||
virtual void event_read();
|
||||
virtual void event_write();
|
||||
virtual void event_error();
|
||||
void event_read() override;
|
||||
void event_write() override;
|
||||
void event_error() override;
|
||||
|
||||
utils::SocketFd& get_fd() { return *reinterpret_cast<utils::SocketFd*>(&m_fileDesc); }
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "rpc/scgi_task.h"
|
||||
|
||||
#include <rak/allocators.h>
|
||||
#include <rak/error_number.h>
|
||||
#include <cstdio>
|
||||
@@ -29,9 +31,9 @@ SCgiTask::open(SCgi* parent, int fd) {
|
||||
m_position = m_buffer;
|
||||
m_body = NULL;
|
||||
|
||||
torrent::thread_self()->poll()->open(this);
|
||||
torrent::thread_self()->poll()->insert_read(this);
|
||||
torrent::thread_self()->poll()->insert_error(this);
|
||||
torrent::this_thread::poll()->open(this);
|
||||
torrent::this_thread::poll()->insert_read(this);
|
||||
torrent::this_thread::poll()->insert_error(this);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -42,10 +44,7 @@ SCgiTask::close() {
|
||||
torrent::main_thread()->cancel_callback_and_wait(this);
|
||||
torrent::thread_self()->cancel_callback(this);
|
||||
|
||||
torrent::thread_self()->poll()->remove_read(this);
|
||||
torrent::thread_self()->poll()->remove_write(this);
|
||||
torrent::thread_self()->poll()->remove_error(this);
|
||||
torrent::thread_self()->poll()->close(this);
|
||||
torrent::this_thread::poll()->remove_and_close(this);
|
||||
|
||||
get_fd().close();
|
||||
get_fd().clear();
|
||||
@@ -164,7 +163,7 @@ SCgiTask::event_read() {
|
||||
if ((unsigned int)std::distance(m_buffer, m_position) != m_buffer_size)
|
||||
return;
|
||||
|
||||
torrent::thread_self()->poll()->remove_read(this);
|
||||
torrent::this_thread::poll()->remove_read(this);
|
||||
|
||||
if (m_parent->log_fd() >= 0) {
|
||||
int __UNUSED result;
|
||||
@@ -272,7 +271,7 @@ SCgiTask::receive_call(const char* buffer, uint32_t length) {
|
||||
m_result_mutex.lock();
|
||||
m_result_mutex.unlock();
|
||||
|
||||
torrent::thread_self()->poll()->insert_write(this);
|
||||
torrent::this_thread::poll()->insert_write(this);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user