[Bps-public-commit] Net-Server-Coro branch, master, updated. 0.6-2-g851ec93

Alex M Vandiver alexmv at bestpractical.com
Tue Dec 15 01:13:02 EST 2009


The branch, master has been updated
       via  851ec93edb6bd73203745e64e39a48b5dacfab50 (commit)
       via  2ccfaa62b1701df0e3c65d9a36249f3b922917b9 (commit)
      from  3e27f291687c99cbab971e91ed54ed5c8ee3f940 (commit)

Summary of changes:
 lib/Net/Server/Coro.pm |   29 +++++++++++++++++++++--------
 1 files changed, 21 insertions(+), 8 deletions(-)

- Log -----------------------------------------------------------------
commit 2ccfaa62b1701df0e3c65d9a36249f3b922917b9
Author: 山村 英貴 <hideki.yamamura at gmail.com>
Date:   Tue Dec 15 00:19:42 2009 -0500

    Use Coro::Specific variables for client filehandle, socket, and peer info

diff --git a/lib/Net/Server/Coro.pm b/lib/Net/Server/Coro.pm
index 20b95dd..6f1297c 100644
--- a/lib/Net/Server/Coro.pm
+++ b/lib/Net/Server/Coro.pm
@@ -6,6 +6,7 @@ package Net::Server::Coro;
 use vars qw($VERSION);
 use EV;
 use Coro;
+use Coro::Specific;
 use base qw(Net::Server);
 use Net::Server::Proto::Coro;
 
@@ -79,6 +80,11 @@ sub post_bind_hook {
     delete $prop->{select};
 
     $prop->{sock} = [ map { $self->make_coro_socket($_) } @{ $prop->{sock} } ];
+
+    # set up coro::specific variables
+    foreach my $key (qw(client sockaddr sockport peeraddr peerport)) {
+        tie $prop->{$key}, Coro::Specific::;
+    }
 }
 
 =head2 make_coro_socket SOCKET
@@ -115,14 +121,16 @@ sub coro_instance {
     $Coro::current->desc("Active connection");
     $prop->{client} = $fh;
     $self->run_client_connection;
-    close $fh;
 }
 
-# We override this to do nothing, or Net::Server closes
-# $self->{server}{client} -- which is he most recent connection, not
-# necessarily the current connection.  We also don't want the
-# STDERR/STDOUT redirection.
-sub post_process_request {}
+sub post_accept_hook {
+    my $self = shift;
+    my $prop = $self->{server};
+    my $sock = $prop->{client};
+
+    ($prop->{sockaddr}, $prop->{sockport}) = ($sock->sockhost, $sock->sockport);
+    ($prop->{peeraddr}, $prop->{peerport}) = ($sock->peerhost, $sock->peerport);
+}
 
 =head2 loop
 
@@ -219,6 +227,11 @@ L<Coro>, L<EV>, L<Net::Server>
 
 =head1 BUGS AND LIMITATIONS
 
+The client filehandle, socket, and peer information all use
+L<Coro::Specific> in order to constrain their information to their
+coroutine.  Attempting to access them from a different coroutine will
+yield possibly unexpected results.
+
 Generally, all those of L<Coro>.  Please report any bugs or feature
 requests specific to L<Net::Server::Coro> to
 C<bug-net-server-coro at rt.cpan.org>, or through the web interface at

commit 851ec93edb6bd73203745e64e39a48b5dacfab50
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Dec 15 00:20:43 2009 -0500

    Fix two minor documentation typos

diff --git a/lib/Net/Server/Coro.pm b/lib/Net/Server/Coro.pm
index 6f1297c..27c606f 100644
--- a/lib/Net/Server/Coro.pm
+++ b/lib/Net/Server/Coro.pm
@@ -191,7 +191,7 @@ sub loop {
 
 =head2 server_cert [PATH]
 
-Gets or sets the path fo the SSL certificate used by the server.
+Gets or sets the path of the SSL certificate used by the server.
 
 =cut
 
@@ -207,7 +207,7 @@ sub server_cert {
 
 =head2 server_key [PATH]
 
-Gets or sets the path fo the SSL key file used by the server.
+Gets or sets the path of the SSL key file used by the server.
 
 =cut
 

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list