[PEAR-BUG] Bug #18262 [Opn->Csd]: Incomplete buffer sent with fwrite after bugfix #14619

[email protected]
Newsgroups php.pear.bugs
Message-ID <[email protected]>
Edit report at https://pear.php.net/bugs/bug.php?id=18262&edit=1

 ID:               18262
 Updated by:       [email protected]
 Reported By:      sberthelot at emisfr dot com
 Summary:          Incomplete buffer sent with fwrite after bugfix
                    #14619
-Status:           Open
+Status:           Closed
 Type:             Bug
 Package:          Net_Socket
 Operating System: Linux 2.6.33.3
 Package Version:  1.0.10
 PHP Version:      5.2.11
-Assigned To:      
+Assigned To:      doconnor
 Roadmap Versions: 
 New Comment:

-Status:      Open
+Status:      Closed
-Assigned To:
+Assigned To: doconnor
This bug has been fixed in SVN.

If this was a documentation problem, the fix will appear on pear.php.net
by the end of next Sunday (CET).

If this was a problem with the pear.php.net website, the change should
be live shortly.

Otherwise, the fix will appear in the package's next release.

Thank you for the report and for helping us make PEAR better.




Previous Comments:
------------------------------------------------------------------------

[2014-08-08 12:03:45] doconnor

https://github.com/pear/Net_Socket/pull/3 likely sorted it.

------------------------------------------------------------------------

[2013-05-15 12:09:30] alec

This is not so simple. Manual  says "FALSE on error", but some comments
in the manual point that it's not true and sometimes 0 is returned on
error. Maybe it's not the case for recent PHP version, I don't know.

http://php.net/manual/en/function.fwrite.php

------------------------------------------------------------------------

[2011-02-10 21:16:45] sberthelot

-Summary: Incomplete fwrites upon bugfix #14619
+Summary: Incomplete buffer sent with fwrite after bugfix
          #14619


------------------------------------------------------------------------

[2011-02-10 21:15:38] sberthelot

Description:
------------
The #14619 bug changed the way fwrite operates as a return value of 0 to
a fwrite call would return immediately with the number of bytes
written.

But when testing I found out that writing to an SMTP socket to a "slow"
server (using PEAR Mail) makes the socket "full" at 65536 bytes.
Following attempts to fwrite return 0 until the socket has free "space"
again and then following fwrites occur succesfuly until the last one.

If I understand well the problem (socket closed before first fwrite)
then the comparison fwrite result == 0 should be done only on first
call.

For my scenario I have 64x1024 bytes written, then 0 for some time then
512x1024 more and so on...

Test script:
---------------
Mail -> send() with an attachment > 65KB on my test machine.

Expected result:
----------------
fwrite should complete until the last byte is sent  or a real error
condition occurs.
It is not working and even unclear if a return of "0" means error or no
byte could be sent (if this is the second then I'll file a bug request
to PEAR Mail because it doesn't attempt to send again if fwrite result
!= buffer size)

Actual result:
--------------
Only first 65536 bytes are sent then fwrite returns

------------------------------------------------------------------------


-- 
Edit this bug report at https://pear.php.net/bugs/bug.php?id=18262&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.