Skip to content

Commit

Permalink
Release global lock while ScgiTask is writing to socket.
Browse files Browse the repository at this point in the history
  • Loading branch information
rakshasa committed Sep 5, 2014
1 parent 7537a3c commit 65dfc46
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/rpc/scgi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ SCgi::receive_call(SCgiTask* task, const char* buffer, uint32_t length) {
slotWrite.set(rak::mem_fn(task, &SCgiTask::receive_write));

torrent::thread_base::acquire_global_lock();
torrent::main_thread()->interrupt();

bool result = xmlrpc.process(buffer, length, slotWrite);

torrent::main_thread()->interrupt();
torrent::thread_base::release_global_lock();

return result;
Expand Down
5 changes: 5 additions & 0 deletions src/rpc/scgi_task.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ SCgiTask::receive_write(const char* buffer, uint32_t length) {
if (buffer == NULL || length > (100 << 20))
throw torrent::internal_error("SCgiTask::receive_write(...) received bad input.");

torrent::thread_base::release_global_lock();

// Need to cast due to a bug in MacOSX gcc-4.0.1.
if (length + 256 > std::max(m_bufferSize, (unsigned int)default_buffer_size))
realloc_buffer(length + 256, NULL, 0);
Expand All @@ -249,6 +251,9 @@ SCgiTask::receive_write(const char* buffer, uint32_t length) {
lt_log_print_dump(torrent::LOG_RPC_DUMP, m_buffer, m_bufferSize, "scgi", "RPC write.", 0);

event_write();

torrent::thread_base::acquire_global_lock();

return true;
}

Expand Down

0 comments on commit 65dfc46

Please sign in to comment.