From owner-svn-ports-head@FreeBSD.ORG Fri Nov 22 19:11:56 2013 Return-Path: Delivered-To: svn-ports-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3CAB121F; Fri, 22 Nov 2013 19:11:56 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 2B0AB286F; Fri, 22 Nov 2013 19:11:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rAMJBuol013002; Fri, 22 Nov 2013 19:11:56 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id rAMJBts4013000; Fri, 22 Nov 2013 19:11:55 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201311221911.rAMJBts4013000@svn.freebsd.org> From: Mikolaj Golub Date: Fri, 22 Nov 2013 19:11:55 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r334606 - in head/sysutils/p5-MogileFS-Server: . files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Nov 2013 19:11:56 -0000 Author: trociny Date: Fri Nov 22 19:11:55 2013 New Revision: 334606 URL: http://svnweb.freebsd.org/changeset/ports/334606 Log: Fix a regression introduce in 2.70 when the mogilefs server was rewritten to be non-blocking: immediate write after connect may fail if the connection is not ready yet. Approved by: bdrewery (mentor) Added: head/sysutils/p5-MogileFS-Server/files/patch-Poolable.pm (contents, props changed) Modified: head/sysutils/p5-MogileFS-Server/Makefile Modified: head/sysutils/p5-MogileFS-Server/Makefile ============================================================================== --- head/sysutils/p5-MogileFS-Server/Makefile Fri Nov 22 19:07:32 2013 (r334605) +++ head/sysutils/p5-MogileFS-Server/Makefile Fri Nov 22 19:11:55 2013 (r334606) @@ -3,6 +3,7 @@ PORTNAME= MogileFS-Server PORTVERSION= 2.70 +PORTREVISION= 1 CATEGORIES= sysutils perl5 MASTER_SITES= CPAN MASTER_SITE_SUBDIR= CPAN:DORMANDO Added: head/sysutils/p5-MogileFS-Server/files/patch-Poolable.pm ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/p5-MogileFS-Server/files/patch-Poolable.pm Fri Nov 22 19:11:55 2013 (r334606) @@ -0,0 +1,73 @@ +Eric Wong: connection/poolable: do not write before event_write + +Blindly attempting to write to a socket before a TCP connection can be +established returns EAGAIN on Linux, but not on FreeBSD 8/9. This +causes Danga::Socket to error out, as it won't attempt to buffer on +anything but EAGAIN on write() attempts. + +Now, we buffer writes explicitly after the initial socket creation and +connect(), and only call Danga::Socket::write when we've established +writability. This works on Linux, too, and avoids an unnecessary +syscall in most cases. + +Reported-by: Alex Yakovenko + +--- lib/MogileFS/Connection/Poolable.pm.orig 2013-08-19 05:52:33.000000000 +0300 ++++ lib/MogileFS/Connection/Poolable.pm 2013-11-20 22:57:31.000000000 +0200 +@@ -13,6 +13,7 @@ use fields ( + 'mfs_expire_cb', # Danga::Socket::Timer callback + 'mfs_requests', # number of requests made on this object + 'mfs_err', # used to propagate an error to start() ++ 'mfs_writeq', # arrayref if connecting, undef otherwise + ); + use Socket qw(SO_KEEPALIVE); + use Time::HiRes; +@@ -27,6 +28,9 @@ sub new { + $self->{mfs_hostport} = [ $ip, $port ]; + $self->{mfs_requests} = 0; + ++ # newly-created socket, we buffer writes until event_write is triggered ++ $self->{mfs_writeq} = []; ++ + return $self; + } + +@@ -53,6 +57,38 @@ sub mark_idle { + $self->{mfs_requests}++; + } + ++sub write { ++ my ($self, $arg) = @_; ++ my $writeq = $self->{mfs_writeq}; ++ ++ if (ref($writeq) eq "ARRAY") { ++ # if we're still connecting, we must buffer explicitly for *BSD ++ # and not attempt a real write() until event_write is triggered ++ push @$writeq, $arg; ++ $self->watch_write(1); # enable event_write triggering ++ 0; # match Danga::Socket::write return value ++ } else { ++ $self->SUPER::write($arg); ++ } ++} ++ ++# Danga::Socket will trigger this when a socket is writable ++sub event_write { ++ my ($self) = @_; ++ ++ # we may have buffered writes in mfs_writeq during non-blocking connect(), ++ # this is needed on *BSD but unnecessary (but harmless) on Linux. ++ my $writeq = delete $self->{mfs_writeq}; ++ if ($writeq) { ++ $self->watch_write(0); # ->write will re-enable if needed ++ foreach my $queued (@$writeq) { ++ $self->write($queued); ++ } ++ } else { ++ $self->SUPER::event_write(); ++ } ++} ++ + # the request running on this connection is retryable if this socket + # has ever been marked idle. The connection pool can never be 100% + # reliable for detecting dead sockets, and all HTTP requests made by