Thread-safe improvements to dht/tracker code and reorganized thread objects.

This commit is contained in:
Jari Sundell
2025-03-13 14:15:12 +01:00
committed by GitHub
parent 47af28aecd
commit f33fc331ce
6 changed files with 23 additions and 160 deletions
+5 -39
View File
@@ -1,39 +1,3 @@
// rTorrent - BitTorrent client
// Copyright (C) 2005-2011, Jari Sundell
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// In addition, as a special exception, the copyright holders give
// permission to link the code of portions of this program with the
// OpenSSL library under certain conditions as described in each
// individual source file, and distribute linked combinations
// including the two.
//
// You must obey the GNU General Public License in all respects for
// all of the code used other than OpenSSL. If you modify file(s)
// with this exception, you may extend this exception to your version
// of the file(s), but you are not obligated to do so. If you do not
// wish to do so, delete this exception statement from your version.
// If you delete this exception statement from all source files in the
// program, then also delete it here.
//
// Contact: Jari Sundell <jaris@ifi.uio.no>
//
// Skomakerveien 33
// 3185 Skoppum, NORWAY
#include "config.h"
#include "rpc/scgi_task.h"
@@ -150,7 +114,7 @@ SCgi::event_read() {
fd.close();
continue;
}
task->open(this, fd.get_fd());
}
}
@@ -168,7 +132,8 @@ SCgi::event_error() {
bool
SCgi::receive_call(SCgiTask* task, const char* buffer, uint32_t length) {
bool result = false;
torrent::thread_base::acquire_global_lock();
torrent::utils::Thread::acquire_global_lock();
torrent::main_thread()->interrupt();
switch (task->content_type()) {
@@ -178,8 +143,9 @@ SCgi::receive_call(SCgiTask* task, const char* buffer, uint32_t length) {
case rpc::SCgiTask::ContentType::XML:
result = rpc.process(RpcManager::RPCType::XML, buffer, length, [task](const char* b, uint32_t l) { return task->receive_write(b, l); });
break;
}
torrent::thread_base::release_global_lock();
torrent::utils::Thread::release_global_lock();
return result;
}