Skip to content

wrong check for sent bytes in AMQPConnection #10

@marcelog

Description

@marcelog

diff --git a/amqp.inc b/amqp.inc
the actual code only checks for false as the return value of fwrite in AMQPConnection::write($data). sometimes, fwrite() does not return false but 0 bytes, and the while(true) makes php hang forever. this is the main concern here. the main loop and that fwrite is not returning false when an errno=32 happens. my solution (others may exist.. ):

index 1bf03b3..3607afe 100644
--- a/amqp.inc
+++ b/amqp.inc
@@ -436,7 +436,7 @@ class AMQPConnection extends AbstractChannel
$len = strlen($data);
while(true)
{

  •        if(false === ($written = fwrite($this->sock, $data)))
    
  •        if(false === ($written = fwrite($this->sock, $data)) || $written === 0)
         {
             throw new Exception ("Error sending data");
         }
    

thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions