diff options
author | Samuel Cabrero <scabrero@suse.de> | 2018-06-15 18:15:53 +0200 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2018-08-21 11:47:25 +0200 |
commit | 8c16413f6497615e9deaff0199cc734b679e3b1d (patch) | |
tree | ed6da85018917968a6bdd201151bc6d55906200b /ctdb/utils | |
parent | a18bcf23a265b71fa88e1963ea23dfd26beaaec3 (diff) | |
download | samba-8c16413f6497615e9deaff0199cc734b679e3b1d.tar.gz |
ctdb_mutex_ceph_rados_helper: Set SIGINT signal handler
Set a handler for SIGINT to release the lock.
Signed-off-by: Samuel Cabrero <scabrero@suse.de>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 85706bd27535eaa4ec653f99b1910fbd8f2aab88)
Diffstat (limited to 'ctdb/utils')
-rw-r--r-- | ctdb/utils/ceph/ctdb_mutex_ceph_rados_helper.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/ctdb/utils/ceph/ctdb_mutex_ceph_rados_helper.c b/ctdb/utils/ceph/ctdb_mutex_ceph_rados_helper.c index 326a0b02519..b5cd1ebad12 100644 --- a/ctdb/utils/ceph/ctdb_mutex_ceph_rados_helper.c +++ b/ctdb/utils/ceph/ctdb_mutex_ceph_rados_helper.c @@ -147,7 +147,8 @@ struct ctdb_mutex_rados_state { const char *object; int ppid; struct tevent_context *ev; - struct tevent_signal *sig_ev; + struct tevent_signal *sigterm_ev; + struct tevent_signal *sigint_ev; struct tevent_timer *timer_ev; rados_t ceph_cluster; rados_ioctx_t ioctx; @@ -269,11 +270,21 @@ int main(int argc, char *argv[]) } /* wait for sigterm */ - cmr_state->sig_ev = tevent_add_signal(cmr_state->ev, cmr_state, SIGTERM, 0, + cmr_state->sigterm_ev = tevent_add_signal(cmr_state->ev, cmr_state, SIGTERM, 0, ctdb_mutex_rados_sigterm_cb, cmr_state); - if (cmr_state->sig_ev == NULL) { - fprintf(stderr, "Failed to create signal event\n"); + if (cmr_state->sigterm_ev == NULL) { + fprintf(stderr, "Failed to create term signal event\n"); + fprintf(stdout, CTDB_MUTEX_STATUS_ERROR); + ret = -ENOMEM; + goto err_state_free; + } + + cmr_state->sigint_ev = tevent_add_signal(cmr_state->ev, cmr_state, SIGINT, 0, + ctdb_mutex_rados_sigterm_cb, + cmr_state); + if (cmr_state->sigint_ev == NULL) { + fprintf(stderr, "Failed to create int signal event\n"); fprintf(stdout, CTDB_MUTEX_STATUS_ERROR); ret = -ENOMEM; goto err_state_free; |