Edit report at http://pear.php.net/bugs/bug.php?id=18618&edit=1
ID: 18618
Updated by: [email protected]
Reported By: andy at fud dot org dot nz
Summary: Incorrect CHUNK_SIZE
Status: Open
Type: Bug
Package: Crypt_GPG
Operating System: BSD/Linux
Package Version: SVN
PHP Version: Irrelevant
-Assigned To:
+Assigned To: gauthierm
Roadmap Versions:
New Comment:
-: [email protected]
+: andy at fud dot org dot nz
-Assigned To:
+Assigned To: gauthierm
Previous Comments:
------------------------------------------------------------------------
[2011-06-20 17:19:09] gauthierm
Description:
------------
"POSIX.1-2001 says that write(2)s of less than PIPE_BUF bytes must be
atomic: the output data is written to the pipe as a contiguous
sequence.
Writes of more than PIPE_BUF bytes may be non-atomic: the kernel may
interleave the data with data written by other processes."
Most operating systems have PIPE_BUF as 4096 bytes. Setting CHUNK_SIZE
to
8192 may cause php to do two 4k writes which can cause Crypt_GPG to
hang
forever.
It hangs because $fdInput is returned as writable by stream_select(),
the
first 4k write succeeds (fully or partially) but because php will try
to
write the next 4k chunk it hangs as the fd is full and hasn't beed
re-selected to test if it can be written.
The other option is to set all file descriptors as non-blocking using
stream_set_blocking(), the code correctly increments the buffers for
the
actual amount written/read.
This will also fix bug 18526
------------------------------------------------------------------------
--
Edit this bug report at http://pear.php.net/bugs/bug.php?id=18618&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.