SIGPIPE in hiredis

111 views
Skip to first unread message

tianyuan

unread,
Dec 10, 2012, 3:51:18 AM12/10/12
to redi...@googlegroups.com
Hi,
  I got a daemon programm connect to redis at start time, and then check a list repeatly. But this process exit without core dump about once a week. I guess it may beacause of SIGPIPE which I didn't handle in my daemon programm.
  My question is,
  (1) why redis-server will close a connection occasionaly while "timeout 0" is set in redis.conf?
  (2) Should I reconnect to redis after SIGPIPE with redisConnect()?

thanks.
 

Josiah Carlson

unread,
Dec 10, 2012, 10:40:09 AM12/10/12
to redi...@googlegroups.com
On Mon, Dec 10, 2012 at 12:51 AM, tianyuan <iamti...@gmail.com> wrote:
> Hi,
> I got a daemon programm connect to redis at start time, and then check a
> list repeatly. But this process exit without core dump about once a week. I
> guess it may beacause of SIGPIPE which I didn't handle in my daemon
> programm.
> My question is,
> (1) why redis-server will close a connection occasionaly while "timeout 0"
> is set in redis.conf?

It's probably not Redis server unless you are running 2.6 and the
outgoing buffer from the server to this client gets too long.
Otherwise, it could have any one of a number of causes.

> (2) Should I reconnect to redis after SIGPIPE with redisConnect()?

If you are getting SIGPIPE as the result of a read/write from a
connection, then the connection is dead. You will have to reconnect.
But another option is to ignore the signal, and detect errors during
send/recv (a socket that is writable, but send() returns 0, or a
socket that is readable, but recv() returns no bytes).

- Josiah
Reply all
Reply to author
Forward
0 new messages