static sighandler_t sighandler_alrm;
static sighandler_t sighandler_term;
+class RGWProcess;
-#define SOCKET_BACKLOG 1024
+static RGWProcess *pprocess = NULL;
-static void godown_handler(int signum)
-{
- FCGX_ShutdownPending();
- signal(signum, sighandler_usr1);
- alarm(5);
-}
-static void godown_alarm(int signum)
-{
- _exit(0);
-}
+#define SOCKET_BACKLOG 1024
struct RGWRequest
{
ThreadPool m_tp;
Throttle req_throttle;
RGWREST *rest;
+ int sock_fd;
struct RGWWQ : public ThreadPool::WorkQueue<RGWRequest> {
RGWProcess *process;
RGWProcess(CephContext *cct, RGWRados *rgwstore, int num_threads, RGWREST *_rest)
: store(rgwstore), m_tp(cct, "RGWProcess::m_tp", num_threads),
req_throttle(cct, "rgw_ops", num_threads * 2),
- rest(_rest),
+ rest(_rest), sock_fd(-1),
req_wq(this, g_conf->rgw_op_thread_timeout,
g_conf->rgw_op_thread_suicide_timeout, &m_tp),
max_req_id(0) {}
void run();
void handle_request(RGWRequest *req);
+
+ void close_fd() {
+ if (sock_fd >= 0)
+ close(sock_fd);
+ }
};
void RGWProcess::run()
{
- int s = 0;
+ sock_fd = 0;
if (!g_conf->rgw_socket_path.empty()) {
string path_str = g_conf->rgw_socket_path;
}
const char *path = path_str.c_str();
- s = FCGX_OpenSocket(path, SOCKET_BACKLOG);
- if (s < 0) {
- dout(0) << "ERROR: FCGX_OpenSocket (" << path << ") returned " << s << dendl;
+ sock_fd = FCGX_OpenSocket(path, SOCKET_BACKLOG);
+ if (sock_fd < 0) {
+ dout(0) << "ERROR: FCGX_OpenSocket (" << path << ") returned " << sock_fd << dendl;
return;
}
if (chmod(path, 0777) < 0) {
RGWRequest *req = new RGWRequest;
req->id = ++max_req_id;
dout(10) << "allocated request req=" << hex << req << dec << dendl;
- FCGX_InitRequest(&req->fcgx, s, 0);
+ FCGX_InitRequest(&req->fcgx, sock_fd, 0);
req_throttle.get(1);
int ret = FCGX_Accept_r(&req->fcgx);
if (ret < 0) {
m_tp.stop();
}
+static void godown_handler(int signum)
+{
+ FCGX_ShutdownPending();
+ pprocess->close_fd();
+ signal(signum, sighandler_usr1);
+ alarm(5);
+}
+
+static void godown_alarm(int signum)
+{
+ _exit(0);
+}
+
static int call_log_intent(RGWRados *store, void *ctx, rgw_obj& obj, RGWIntentEvent intent)
{
struct req_state *s = (struct req_state *)ctx;
}
RGWProcess process(g_ceph_context, store, g_conf->rgw_thread_pool_size, &rest);
+
+ pprocess = &process;
+
process.run();
if (do_swift) {
RGWStoreManager::close_storage(store);
+ rgw_tools_cleanup();
curl_global_cleanup();
g_ceph_context->put();