]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_signal.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
5 * Ceph - scalable distributed file system
7 * Copyright (C) 2022 Red Hat, Inc
9 * This is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License version 2.1, as published by the Free Software
12 * Foundation. See file COPYING.
16 #include "rgw_signal.h"
17 #include "global/signal_handler.h"
18 #include "common/safe_io.h"
19 #include "common/errno.h"
23 #ifdef HAVE_SYS_PRCTL_H
24 #include <sys/prctl.h>
27 #define dout_subsys ceph_subsys_rgw
28 #define dout_context g_ceph_context
31 static int signal_fd
[2] = {0, 0};
36 void sighup_handler(int signum
) {
37 if (rgw::AppMain::ops_log_file
!= nullptr) {
38 rgw::AppMain::ops_log_file
->reopen();
40 g_ceph_context
->reopen_logs();
41 } /* sighup_handler */
43 void signal_shutdown()
46 int ret
= write(signal_fd
[0], (char *)&val
, sizeof(val
));
48 derr
<< "ERROR: " << __func__
<< ": write() returned "
49 << cpp_strerror(errno
) << dendl
;
51 } /* signal_shutdown */
56 int r
= safe_read_exact(signal_fd
[1], &val
, sizeof(val
));
58 derr
<< "safe_read_exact returned with error" << dendl
;
64 return socketpair(AF_UNIX
, SOCK_STREAM
, 0, signal_fd
);
65 } /* signal_fd_init */
67 void signal_fd_finalize()
71 } /* signal_fd_finalize */
73 void handle_sigterm(int signum
)
75 dout(1) << __func__
<< dendl
;
77 // send a signal to make fcgi's accept(2) wake up. unfortunately the
78 // initial signal often isn't sufficient because we race with accept's
79 // check of the flag wet by ShutdownPending() above.
80 if (signum
!= SIGUSR1
) {
83 // safety net in case we get stuck doing an orderly shutdown.
84 uint64_t secs
= g_ceph_context
->_conf
->rgw_exit_timeout_secs
;
87 dout(1) << __func__
<< " set alarm for " << secs
<< dendl
;
89 } /* handle_sigterm */
91 }} /* namespace rgw::signal */