mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-16 07:02:30 +00:00
* Created ThreadBase holding poll manager, etc, and added a this_thread global object.
* Cleaned up main initialization, SCGI and polling code. * Fixed a bug that would cause reading of a piece to hang if the incoming data contains only data up to the file boundary, but not the next file's data. The bug did not trigger if the file boundary and piece boundaries were the same. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1101 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+16
-7
@@ -60,9 +60,8 @@ SCgi::~SCgi() {
|
||||
if (itr->is_open())
|
||||
itr->close();
|
||||
|
||||
control->poll()->remove_read(this);
|
||||
control->poll()->remove_error(this);
|
||||
control->poll()->close(this);
|
||||
deactivate();
|
||||
torrent::connection_manager()->dec_socket_count();
|
||||
|
||||
get_fd().close();
|
||||
get_fd().clear();
|
||||
@@ -109,10 +108,6 @@ SCgi::open(void* sa, unsigned int length) {
|
||||
|
||||
torrent::connection_manager()->inc_socket_count();
|
||||
|
||||
control->poll()->open(this);
|
||||
control->poll()->insert_read(this);
|
||||
control->poll()->insert_error(this);
|
||||
|
||||
} catch (torrent::resource_error& e) {
|
||||
get_fd().close();
|
||||
get_fd().clear();
|
||||
@@ -121,6 +116,20 @@ SCgi::open(void* sa, unsigned int length) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SCgi::activate() {
|
||||
this_thread->poll()->open(this);
|
||||
this_thread->poll()->insert_read(this);
|
||||
this_thread->poll()->insert_error(this);
|
||||
}
|
||||
|
||||
void
|
||||
SCgi::deactivate() {
|
||||
this_thread->poll()->remove_read(this);
|
||||
this_thread->poll()->remove_error(this);
|
||||
this_thread->poll()->close(this);
|
||||
}
|
||||
|
||||
void
|
||||
SCgi::event_read() {
|
||||
rak::socket_address sa;
|
||||
|
||||
+4
-1
@@ -62,7 +62,10 @@ public:
|
||||
void open_port(void* sa, unsigned int length, bool dontRoute);
|
||||
void open_named(const std::string& filename);
|
||||
|
||||
const std::string path() const { return m_path; }
|
||||
void activate();
|
||||
void deactivate();
|
||||
|
||||
const std::string& path() const { return m_path; }
|
||||
|
||||
void set_slot_process(slot_process::base_type* s) { m_slotProcess.set(s); }
|
||||
|
||||
|
||||
@@ -75,9 +75,9 @@ SCgiTask::open(SCgi* parent, int fd) {
|
||||
m_position = m_buffer;
|
||||
m_body = NULL;
|
||||
|
||||
control->poll()->open(this);
|
||||
control->poll()->insert_read(this);
|
||||
control->poll()->insert_error(this);
|
||||
this_thread->poll()->open(this);
|
||||
this_thread->poll()->insert_read(this);
|
||||
this_thread->poll()->insert_error(this);
|
||||
|
||||
// scgiTimer = rak::timer::current();
|
||||
}
|
||||
@@ -87,10 +87,10 @@ SCgiTask::close() {
|
||||
if (!get_fd().is_valid())
|
||||
return;
|
||||
|
||||
control->poll()->remove_read(this);
|
||||
control->poll()->remove_write(this);
|
||||
control->poll()->remove_error(this);
|
||||
control->poll()->close(this);
|
||||
this_thread->poll()->remove_read(this);
|
||||
this_thread->poll()->remove_write(this);
|
||||
this_thread->poll()->remove_error(this);
|
||||
this_thread->poll()->close(this);
|
||||
|
||||
get_fd().close();
|
||||
get_fd().clear();
|
||||
@@ -171,8 +171,8 @@ SCgiTask::event_read() {
|
||||
if ((unsigned int)std::distance(m_buffer, m_position) != m_bufferSize)
|
||||
return;
|
||||
|
||||
control->poll()->remove_read(this);
|
||||
control->poll()->insert_write(this);
|
||||
this_thread->poll()->remove_read(this);
|
||||
this_thread->poll()->insert_write(this);
|
||||
|
||||
if (m_parent->log_fd() >= 0) {
|
||||
// Clean up logging, this is just plain ugly...
|
||||
|
||||
Reference in New Issue
Block a user