Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fwrite infinite loop - diff provided to fix issue #28

Open
GoogleCodeExporter opened this issue Mar 28, 2015 · 4 comments
Open

fwrite infinite loop - diff provided to fix issue #28

GoogleCodeExporter opened this issue Mar 28, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. start an amqp server
2. start a process which polls the amqp server for messages in a queue
3. shut down the amqp server

What is the expected output? What do you see instead?
I expect to see the "throw new Exception("Error sending data")" get executed, 
but in php 5.3.8 (cli) I get a repeating error which quickly fills up my 
log/disk with this:
Notice: fwrite(): send of 12 bytes failed with errno=32 Broken pipe in 
/var/www/sites/oxygen/library/Lava/Amqp/php-amqplib/amqp.inc on line 481
PHP Notice:  fwrite(): send of 12 bytes failed with errno=32 Broken pipe in 
/var/www/sites/oxygen/library/Lava/Amqp/php-amqplib/amqp.inc on line 481

Notice: fwrite(): send of 12 bytes failed with errno=32 Broken pipe in 
/var/www/sites/oxygen/library/Lava/Amqp/php-amqplib/amqp.inc on line 481
PHP Notice:  fwrite(): send of 12 bytes failed with errno=32 Broken pipe in 
/var/www/sites/oxygen/library/Lava/Amqp/php-amqplib/amqp.inc on line 481

Notice: fwrite(): send of 12 bytes failed with errno=32 Broken pipe in 
/var/www/sites/oxygen/library/Lava/Amqp/php-amqplib/amqp.inc on line 481
PHP Notice:  fwrite(): send of 12 bytes failed with errno=32 Broken pipe in 
/var/www/sites/oxygen/library/Lava/Amqp/php-amqplib/amqp.inc on line 481


What version of the product are you using? On what operating system?
I'm using centos 5.5, php 5.3.8 (cli) and php-amqplib 0.8

Please provide any additional information below.
Here is a diff that I made so that when fwrite returns 0 bytes written an 
exception is thrown and we don't get stuck in the loop.

Index: php-amqplib/amqp.inc
===================================================================
--- php-amqplib/amqp.inc   (revision 13432)
+++ php-amqplib/amqp.inc   (working copy)
@@ -482,6 +482,10 @@
             {
                 throw new Exception ("Error sending data");
             }
+            if($written === 0 ) {
+               throw new Exception("Error sending data");
+            }
             $len = $len - $written;
             if($len>0)
                 $data=substr($data,0-$len);


Original issue reported on code.google.com by [email protected] on 7 Mar 2012 at 11:10

@GoogleCodeExporter
Copy link
Author

I also produce this problem ,like this:"PHP Notice:  fwrite(): send of 19 bytes 
failed with errno=32 Broken pipe ".What's the reason?My god,I've looking for 
this for 2 hours.Waiting for answer!

Original comment by jiangwb2012 on 16 May 2012 at 3:59

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Did this patch made it into SVN?

Original comment by [email protected] on 19 Sep 2012 at 9:05

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

I'm not a a contributor to this project so I don't know what the process is for 
getting a patch into the SVN, but the patch I provided has been in production 
use at my company since I submitted it here.   Seems like a pretty 
straightforward bug and fix.

Original comment by [email protected] on 19 Sep 2012 at 3:06

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Reproduced Michael's bug (and the fix) on Ubuntu Server 12.04.1 LTS with PHP 
5.3.10 (cli) and php-amqplib 0.8

Original comment by greg.krsak on 5 Dec 2012 at 6:06

  • Added labels: ****
  • Removed labels: ****

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant