From owner-freebsd-current@FreeBSD.ORG Sun Feb 22 15:33:27 2004 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 087E016A4CE for ; Sun, 22 Feb 2004 15:33:27 -0800 (PST) Received: from mail.paymentonline.com (mail.paymentonline.com [63.236.114.6]) by mx1.FreeBSD.org (Postfix) with SMTP id C44D543D1D for ; Sun, 22 Feb 2004 15:33:26 -0800 (PST) (envelope-from freebsd@paymentonline.net) Received: (qmail 2117 invoked from network); 22 Feb 2004 23:33:21 -0000 Received: from evrtwa1-ar16-4-40-004-185.evrtwa1.dsl-verizon.net (HELO chris2) (4.40.4.185) by mail.paymentonline.com with SMTP; 22 Feb 2004 23:33:21 -0000 Message-ID: <00f201c3f99c$b58a4ce0$b9042804@chris2> From: "Chris Ochs" To: Date: Sun, 22 Feb 2004 15:36:34 -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 non blocking sockets on 5.2 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: Sun, 22 Feb 2004 23:33:27 -0000 This code is from Cache::Memcached which is a perl interface to memcached. It works as is on 4.9, but on 5.2-RC the connect returns undef unless I comment out the calls to IO::Handle::blocking. Seems like there is some socket behavior which is different in 5.x then 4.x that would cause this. Anyone have any ideas? 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; }