Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:39642 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60004 invoked from network); 4 Aug 2008 20:43:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Aug 2008 20:43:33 -0000 Authentication-Results: pb1.pair.com smtp.mail=ian@digg.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ian@digg.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain digg.com designates 64.191.203.36 as permitted sender) X-PHP-List-Original-Sender: ian@digg.com X-Host-Fingerprint: 64.191.203.36 mail.digg.com Linux 2.6 Received: from [64.191.203.36] ([64.191.203.36:34059] helo=mail.digg.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B5/86-22351-3F967984 for ; Mon, 04 Aug 2008 16:43:32 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.digg.com (Postfix) with ESMTP id 83975A858DC for ; Mon, 4 Aug 2008 13:43:29 -0700 (PDT) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.325 X-Spam-Level: X-Spam-Status: No, score=-4.325 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, AWL=0.074, BAYES_00=-2.599] Received: from mail.digg.com ([127.0.0.1]) by localhost (mail.digg.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DrW+IzYINQJn for ; Mon, 4 Aug 2008 13:43:29 -0700 (PDT) Received: from [192.168.244.74] (unknown [192.168.244.74]) by mail.digg.com (Postfix) with ESMTP id 172B8A858D2 for ; Mon, 4 Aug 2008 13:43:29 -0700 (PDT) Message-ID: To: internals@lists.php.net Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v928.1) Date: Mon, 4 Aug 2008 13:43:28 -0700 X-Mailer: Apple Mail (2.928.1) Subject: socket_select() problem From: ian@digg.com (Ian Eure) Hi, I have a problem with socket_select(). I hope someone here can point me in the right direction, because I'm stumped. Basically, I'm getting this error: Warning: socket_select() [function.socket-select]: no resource arrays were passed to select in Net/Gearman/Client.php on line 197 This is using the Net_Gearman PEAR package to submit a Gearman job. The job is submitted and runs to completion; this message is displayed by the caller. The relevant code is here: http://code.google.com/p/netgearman/source/browse/trunk/Net/Gearman/Client.php#197 $write = null; $except = null; $read = $this->conn; socket_select($read, $write, $except, 10); If I add var_dump($read) on the line above socket_select(), I get: array(2) { [0]=> resource(141) of type (Socket) [1]=> resource(142) of type (Socket) } The error message appears to be spurious. This is where the socket is created: $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); @socket_connect($socket, $host, $port); $errorCode = socket_last_error($socket); socket_set_nonblock($socket); socket_set_option($socket, SOL_TCP, 1, 1); I removed the @, and there were no errors being hidden. I resorted to examining the socket extension code, and these are my findings: socket_select() calls php_sock_array_to_fd_set() on $read / $write / $except: http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/sockets.c?revision=1.199&view=markup#l788 If the result of all three of those operations is zero, the error message is displayed. php_sock_array_to_fd_set() checks to see if the argument it got is an array: http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/sockets.c?revision=1.199&view=markup#l710 If not, it returns zero. php_sock_array_to_fd_set() calls zend_fetch_resource(): http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/sockets.c?revision=1.199&view=markup#l716 If that returns zero for every element in the array, php_sock_array_to_fd_set() also returns zero. Since I'm dumping $read directly before the socket_select() call, it seems that the zend_fetch_resource() call is what's failing. I wrote a simple testcase that submits a single job to Gearman. If I run it under Apache2, I get the socket_select() warning. If I run it from the CLI, I don't. I'm also pointing the CLI at the Apache2 php.ini file. At this point, I don't know how to track this any further. If I was getting the same error on the CLI, I could trace it with gdb. I don't know how I'd go about doing something like that for an Apache extension. I'm running PHP 5.2.0 under Debian Etch, installed from the vanilla Debian packages (5.2.0-8+etch1). I have APC and Memcache extensions installed from PECL. I disabled both, and there was no change in what I'm seeing. I also emailed everyone listed in socket.c, but I got no response. I'm at a loss. Where do I go from here? - Ian