From owner-freebsd-current@FreeBSD.ORG Tue Dec 23 14:18:09 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D31D616A4CE for ; Tue, 23 Dec 2003 14:18:09 -0800 (PST) Received: from mail.paymentonline.com (mail.paymentonline.com [63.236.114.6]) by mx1.FreeBSD.org (Postfix) with SMTP id E710643D64 for ; Tue, 23 Dec 2003 14:18:04 -0800 (PST) (envelope-from freebsd-current@paymentonline.net) Received: (qmail 37718 invoked from network); 23 Dec 2003 22:14:56 -0000 Received: from evrtwa1-ar16-4-40-004-158.evrtwa1.dsl-verizon.net (HELO chris2) (4.40.4.158) by mail.paymentonline.com with SMTP; 23 Dec 2003 22:14:56 -0000 Message-ID: <107101c3c9a2$ea92a5b0$9e042804@chris2> From: "Chris Ochs" To: Date: Tue, 23 Dec 2003 14:20:04 -0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Subject: Perl IO::Handle/Socket behavior 5.2 vs 4.9 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Dec 2003 22:18:09 -0000 This code is in the Memcached.pm module that connects to the memcached deamon (memcached is in ports). On 5.2 the connect returns null unless I comment out the lines calling IO::Handle::blocking. On 4.9 it works fine. Any ideas why? Chris sub _connect_sock { # sock, sin, timeout my ($sock, $sin, $timeout) = @_; $timeout ||= 0.25; my $block = IO::Handle::blocking($sock, 0) if $timeout; my $ret = connect($sock, $sin); if (!$ret && $timeout && $!{'EINPROGRESS'}) { my $win=''; vec($win, fileno($sock), 1) = 1; if (select(undef, $win, undef, $timeout) > 0) { $ret = connect($sock, $sin); # EISCONN means connected & won't re-connect, so success $ret = 1 if !$ret && $!{'EISCONN'}; } } IO::Handle::blocking($sock, $block) if $timeout; return $ret; }