Skip to content

Commit

Permalink
move readonly_command unordered_set to namespace rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
Young-Flash committed Aug 24, 2022
1 parent 670f6b9 commit 2ad4395
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion include/command_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ cleanup_commands();
#define CMD2_ANY(key, slot, is_readonly) \
do \
{ \
if (is_readonly) readonly_command.insert(key); \
if (is_readonly) rpc::readonly_command.insert(key); \
CMD2_A_FUNCTION(key, command_base_call<rpc::target_type>, slot, "i:", "") \
} while (0) \

Expand Down
3 changes: 0 additions & 3 deletions include/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#ifndef TORRENT_GLOBALS_H
#define TORRENT_GLOBALS_H

#include <unordered_set>
#include <torrent/utils/priority_queue_default.h>
#include <torrent/utils/timer.h>

Expand All @@ -25,6 +24,4 @@ extern torrent::utils::timer cachedTime;
extern Control* control;
extern RpcThreadManager* worker_thread;

extern std::unordered_set<std::string> readonly_command;

#endif
3 changes: 3 additions & 0 deletions include/rpc/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <functional>
#include <limits>
#include <tuple>
#include <unordered_set>

#include <torrent/data/file_list_iterator.h>
#include <torrent/object.h>
Expand All @@ -25,6 +26,8 @@ class Tracker;

namespace rpc {

extern std::unordered_set<std::string> readonly_command;

template<typename Target>
struct target_wrapper {
using target_type = Target;
Expand Down
4 changes: 1 addition & 3 deletions src/globals.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@ torrent::utils::priority_queue_default taskScheduler;
torrent::utils::timer cachedTime;

Control* control = nullptr;
RpcThreadManager* worker_thread = nullptr;

std::unordered_set<std::string> readonly_command = {};
RpcThreadManager* worker_thread = nullptr;
2 changes: 2 additions & 0 deletions src/rpc/command.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

namespace rpc {

std::unordered_set<std::string> readonly_command = {};

template<typename T>
const torrent::Object
command_base_call(command_base* rawCommand,
Expand Down
1 change: 0 additions & 1 deletion src/rpc/rpc_json.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "rpc/parse_commands.h"
#include "thread_base.h"
#include "utils/jsonrpc/common.h"
#include "globals.h"

using jsonrpccxx::JsonRpcException;
using nlohmann::json;
Expand Down

0 comments on commit 2ad4395

Please sign in to comment.