Fix SCGI threading and added missing header.

This commit is contained in:
Jari Sundell
2025-03-31 18:26:07 +02:00
committed by GitHub
parent 2a998df4f1
commit 2ab7460cbc
9 changed files with 135 additions and 258 deletions
+4 -27
View File
@@ -1,6 +1,5 @@
#include "config.h"
#include "rpc/scgi_task.h"
#include <rak/error_number.h>
#include <rak/socket_address.h>
#include <sys/un.h>
@@ -9,12 +8,12 @@
#include <torrent/torrent.h>
#include <torrent/exceptions.h>
#include "utils/socket_fd.h"
#include "control.h"
#include "globals.h"
#include "scgi.h"
#include "parse_commands.h"
#include "rpc/scgi_task.h"
#include "utils/socket_fd.h"
#include "rpc/scgi.h"
namespace rpc {
@@ -110,7 +109,6 @@ SCgi::event_read() {
SCgiTask* task = std::find_if(m_task, m_task + max_tasks, std::mem_fn(&SCgiTask::is_available));
if (task == m_task + max_tasks) {
// Ergh... just closing for now.
fd.close();
continue;
}
@@ -129,25 +127,4 @@ SCgi::event_error() {
throw torrent::internal_error("SCGI listener port received an error event.");
}
bool
SCgi::receive_call(SCgiTask* task, const char* buffer, uint32_t length) {
bool result = false;
torrent::utils::Thread::acquire_global_lock();
torrent::main_thread()->interrupt();
switch (task->content_type()) {
case rpc::SCgiTask::ContentType::JSON:
result = rpc.process(RpcManager::RPCType::JSON, buffer, length, [task](const char* b, uint32_t l) { return task->receive_write(b, l); });
break;
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::utils::Thread::release_global_lock();
return result;
}
}