zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From svk <shreyas...@gmail.com>
Subject Zookeeper client signal handling
Date Sun, 17 Apr 2016 22:22:51 GMT
Hi,
I'm having a problem with signal handling and the Zookeeper C client
library.  In my application, I am masking SIGTERM before calling
zookeeper_init and unmasking it after the call returns. I have registered a
signal handler with the main thread:-

    event_new(ev_base, SIGTERM, EV_SIGNAL, eventCallback, );// this will
register a handler

    sigset_t set;

    sigemptyset(&set);

    sigaddset(&set, SIGTERM);

    pthread_sigmask(SIG_BLOCK, &set, NULL);

    int rc = zookeeper_init(...);

    pthread_sigmask(SIG_UNBLOCK, &set, NULL);
This should prevent Zookeeper threads from getting interrupted by the
signal. I have verified the signal mask by looking at /proc/<PID>/status.
However, it looks like one of the threads is getting interrupted in the
midst of recvmsg. As a result, the client goes into a loop trying to
reconnect to the server, and the session expires after some time.

2016-04-17 19:29:47,353:4107(0xf15f7b40):ZOO_ERROR@handle_socket_error_msg@2352:
Socket [128.0.0.4:61709] zk retcode=-4, errno=32(Broken pipe): failed while
flushing send queue
2016-04-17 19:29:47,354:4107(0xf15f7b40):ZOO_WARN@zookeeper_interest@2163:
Exceeded deadline by 331409ms

I looked at the strace output of the application, and I see rt_sigprocmask
getting called right before recvmsg. Does the client library manipulate its
signal mask? If so, how can I avoid this?

Thanks and regards,
Shreyas

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message