Skip to content

fwrite infinite loop - diff provided to fix issue #28

@GoogleCodeExporter

Description

@GoogleCodeExporter
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 mich...@riesd.com on 7 Mar 2012 at 11:10

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions