php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30121 timeouts don't work on non-blocking sockets
Submitted: 2004-09-16 17:42 UTC Modified: 2004-10-22 01:00 UTC
From: abhishek dot ratani at gmail dot com Assigned:
Status: No Feedback Package: Sockets related
PHP Version: 5.0.1 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2004-09-16 17:42 UTC] abhishek dot ratani at gmail dot com
Description:
------------
Note that if you set the socket non-blocking via socket_set_blocking() you cannot check if the socket has timed out with this function.

Example:

$status = socket_get_status($fp);

if ($status['timed_out']) {
   echo "socket timed out\n";
}

The above condition will never be true even if the socket has timed out.

Is this a bug?

Expected result:
----------------
I except the socket to time out, if the timeout period has passed. But the socket never timesout. Forces me to keep track of time now.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-14 03:43 UTC] bchesneau at gmail dot com
confirm this bug with php 5.0.2. I have the same bug while using Net_SMTP pear class.

some of my strace :

open("/usr/lib/php/PEAR.php", O_RDONLY) = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=30146, ...}) = 0
lseek(4, 0, SEEK_CUR)                   = 0
close(4)                                = 0
gettimeofday({1097717169, 231500}, NULL) = 0
getpid()                                = 2346
open("/etc/resolv.conf", O_RDONLY)      = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=118, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x411ef000
read(4, "domain metavers.net\nnameserver 2"..., 4096) = 118
read(4, "", 4096)                       = 0
close(4)                                = 0
munmap(0x411ef000, 4096)                = 0
socket(PF_UNIX, SOCK_STREAM, 0)         = 4
connect(4, {sa_family=AF_UNIX, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
close(4)                                = 0
open("/etc/host.conf", O_RDONLY)        = -1 ENOENT (No such file or directory)
open("/etc/hosts", O_RDONLY)            = 4
fcntl64(4, F_GETFD)                     = 0
fcntl64(4, F_SETFD, FD_CLOEXEC)         = 0
fstat64(4, {st_mode=S_IFREG|0644, st_size=716, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x411ef000
read(4, "# /etc/hosts:  This file describ"..., 4096) = 716
close(4)                                = 0
munmap(0x411ef000, 4096)                = 0
socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP) = -1 EAFNOSUPPORT (Address family not supported by protocol)gettimeofday({1097717169, 268504}, NULL) = 0
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 4
fcntl64(4, F_GETFL)                     = 0x2 (flags O_RDWR)
fcntl64(4, F_SETFL, O_RDWR|O_NONBLOCK)  = 0
connect(4, {sa_family=AF_INET, sin_port=htons(25), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in progress)
select(5, [4], [4], [4], {60, 0})       = 1 (out [4], left {60, 0})
getsockopt(4, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
fcntl64(4, F_SETFL, O_RDWR)             = 0
time(NULL)                              = 1097717169
select(5, [4], NULL, NULL, {60, 0} <unfinished ...>
 [2004-10-14 08:07 UTC] derick@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip
 [2004-10-22 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Jan 26 09:03:33 2022 UTC