ID: 24066 User updated by: jason at superlink dot net Reported By: jason at superlink dot net Status: Open -Bug Type: Reproducible crash +Bug Type: Sockets related Operating System: FreeBSD 4.8 PHP Version: 4.3.2 New Comment:
Okay, a few things to add to my post... I wanted to add that my initial assessment that binary_read did not suffer from this issue is false. In my inital test with binary read, I thought that simply watching the socket download data was enough to validate if the issue was with normal_read. There was one glaring diff between normal_read and binary_read -- my software was only able to properly process input data from normal_read. After a bit of tweaking, I made binary_read also function and properly parse input. Once it was processing input, it too had socket disconnects. Without processing input, it's simply reading in data, with processing, it has to check data with a RDBMs, which causes a slight delay between reads. Perhaps this bit of info can help narrow down the problem. Also, I wanted to add that I read the bug report about socket_read() returning an infinate number of "\n" ... (http://bugs.php.net/bug.php?id=21760), that bug is still present in 4.3.2. I had to write a shell script to watch for cpu use over 40% and kill the process. It seems to happen around ~5% of the time. Previous Comments: ------------------------------------------------------------------------ [2003-06-06 14:36:06] jason at superlink dot net I'm running a socket connection that needs NORMAL_READ mode enabled. Here is a sample of the socket connection: <?php while(1){ $r = array($socket); if(socket_select($r, $w, $except = NULL, 0)) { if($buffer = socket_read($socket, 2048, PHP_NORMAL_READ)) { $data=trim($buffer); dostuff($data);// do something with the data. } else { // for some reason my socket connection FAILS a lot. die("ERROR: failed to read socket to $remotehost"); } } else { sleep(1); } } ?> In the event of an error, I've been logging the error: socket_strerror(socket_last_error()) The error for the last 5 attempts has returned: uptime: 211 Unknown error: 0 uptime: 439 Unknown error: 0 uptime: 275 Unknown error: 0 uptime: 279 Unknown error: 0 uptime: 395 Unknown error: 0 The socket connection doesn't seem to want to stay alive for long. The error message seems.... very unfriendly. I've tried the program in binary mode (while my program doesn't function with binary mode on, it can still download and read from the socket). In binary mode, the problem does not occur. I've tried NORMAL_READ with and without socket blocking, with the same results (unexplained socket error). this problem seems to have been happening in php 4.3.1 too. Configure Command './configure' '--prefix=/usr/local' '--with-apache=/home/jason/apache_1.3.27' '--enable-exif' '--enable-track-vars' '--with-calendar=shared' '--enable-magic-quotes' '--enable-trans-sid' '--enable-wddx' '--enable-sockets' '--disable-debug' '--enable-gd-native-tt' '--with-zlib' '--enable-inline-optimization' '--enable-memory-limit' '--with-mysql=/usr/local' ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=24066&edit=1