<HTML>
<HEAD>
<TITLE>Re: [rabbitmq-discuss] Librabbitmq</TITLE>
</HEAD>
<BODY>
<FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>Hey David,<BR>
<BR>
Thanks for the tips. As you could probably tell, I have little knowledge in this area. I will go with option #3 in this case and let you guys know how it work out.<BR>
<BR>
Pieter<BR>
<BR>
<BR>
<BR>
On 5/27/10 7:47 AM, "David Wragg" <<a href="david@rabbitmq.com">david@rabbitmq.com</a>> wrote:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>Hi Pieter,<BR>
<BR>
Pieter de Zwart <<a href="pdezwart@rubiconproject.com">pdezwart@rubiconproject.com</a>> writes:<BR>
> I am having some trouble with the librabbitmq library, and I am hoping you<BR>
> can help me out. We have managed to created a situation whereby a connection<BR>
> gets closed down, but the PHP client does not know about it yet. As a<BR>
> result, when it tries to clean itself up with amqp_channel_close(), a<BR>
> SIGPIPE is thrown and PHP gets all kinds of pissed off.<BR>
><BR>
> I was wondering if you could help me either:<BR>
><BR>
> 1. catch SIGPIPE in the PHP C client somehow. (I am a n00b.)<BR>
><BR>
> 2. pass some sort of flag to the connection to ignore SIGPIPE and return<BR>
> false instead. In case you are as clueless as I am (I am sure you are not,<BR>
> but just in case) I found this:<BR>
> setsockopt(sd, SOL_SOCKET, SO_NOSIGPIPE, (void *)&set, sizeof(int));<BR>
<BR>
I haven't heard of SO_NOSIGPIPE before - it seems to be only available<BR>
on OS X.<BR>
<BR>
There are a couple of other options:<BR>
<BR>
3. If the process sets the handler for SIGPIPE to SIG_IGN, then SIGPIPE<BR>
will not be raised, and the offending write call will fail with EPIPE.<BR>
A lot of UNIX processes do this, I believe; SIGPIPE is often more of a<BR>
nuisance than a feature. librabbitmq will propagate EPIPE, I expect.<BR>
<BR>
4. If, instead of using write(2), we use send(2) and specify the<BR>
MSG_NOSIGNAL flag, then SIGPIPE will not be raised, and the send call<BR>
will fail with EPIPE. It sounds like modifying amqp_channel_close to<BR>
do this might make sense: There's little value in a SIGPIPE<BR>
when we are trying to close the connection anyway. Unfortunately,<BR>
MSG_NOSIGNAL is only supported by some OSes.<BR>
<BR>
I suspect that (3) might be your best option, at least for now. It's<BR>
process wide, but if PHP isn't happy about getting SIGPIPE, that is<BR>
probably quite reasonable.<BR>
<BR>
David<BR>
<BR>
--<BR>
David Wragg<BR>
Staff Engineer, RabbitMQ<BR>
SpringSource, a division of VMware<BR>
<BR>
</SPAN></FONT></BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
-- <BR>
</SPAN></FONT><FONT COLOR="#343434"><FONT SIZE="4"><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:14pt'>the rubicon project<BR>
</SPAN></FONT></FONT></FONT><FONT FACE="Verdana, Helvetica, Arial"><FONT COLOR="#BA0022"><FONT SIZE="1"><SPAN STYLE='font-size:9pt'><BR>
</SPAN><SPAN STYLE='font-size:7pt'>PIETER DE ZWART </SPAN></FONT></FONT><FONT SIZE="1"><SPAN STYLE='font-size:7pt'><FONT COLOR="#404040">| INTERFACES ENGINEER<BR>
</FONT><FONT COLOR="#AC0021"><BR>
</FONT><FONT COLOR="#BB001E">••• P 310 207 0272 | x224<BR>
••• F 323 466 7119<BR>
</FONT><BR>
<FONT COLOR="#3C3C3C"><BR>
1925 S. BUNDY DRIVE<BR>
LOS ANGELES, CALIFORNIA 90025<BR>
</FONT><FONT COLOR="#B60F1D"><BR>
</FONT><FONT COLOR="#0000FF">WWW.RUBICONPROJECT.COM</FONT><FONT COLOR="#B60F1D"> <</FONT><FONT COLOR="#0000FF"><U><a href="http://">http://</a>www.rubiconproject.com/</U></FONT><FONT COLOR="#B60F1D">> <BR>
</FONT></SPAN></FONT></FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
</SPAN></FONT><FONT COLOR="#2F2F2F"><FONT SIZE="4"><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:13pt'><IMG src="cid:3357794251_6331661" ><BR>
</SPAN></FONT></FONT></FONT><FONT FACE="Verdana, Helvetica, Arial"><FONT COLOR="#787878"><FONT SIZE="1"><SPAN STYLE='font-size:7pt'>“COMPANY OF THE YEAR” ALWAYSON ONMEDIA 2009<BR>
#24 ON FAST COMPANY FAST 50 READER FAVORITES<BR>
2008 ALWAYSON 250 GLOBAL WINNER<BR>
2008 ALWAYSON ONMEDIA 100 WINNER<BR>
TWIISTUP3 BEST IN SHOW<BR>
</SPAN></FONT></FONT><FONT SIZE="1"><SPAN STYLE='font-size:7pt'><FONT COLOR="#777777">PRICEWATERHOUSECOOPERS – ENTRETECH BEST STARTUP<BR>
</FONT><FONT COLOR="#787878">AMERICAN BUSINESS AWARDS - STEVIES ‘08 FINALIST BEST NEW COMPANY<BR>
</FONT><FONT COLOR="#777777">AMERICAN BUSINESS AWARDS - STEVIES ‘08 FINALIST MOST INNOVATIVE COMPANY<BR>
AMERICAN BUSINESS AWARDS - STEVIES ‘08 FINALIST NEW PRODUCT OR SERVICE - SERVICES<BR>
<BR>
</FONT></SPAN></FONT></FONT><FONT COLOR="#198000"><FONT SIZE="6"><FONT FACE="Webdings"><SPAN STYLE='font-size:24pt'>P</SPAN></FONT></FONT><FONT SIZE="1"><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:7pt'> </SPAN></FONT><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:8pt'>Please consider the environment before printing this e-mail</SPAN></FONT></FONT></FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
</SPAN></FONT>
</BODY>
</HTML>