#63 SOAP::Transport::HTTP::Daemon handle() method blocks ...

0.65
open
Transport (26)
5
2005-01-01
2005-01-01
jmzorko
No

Hello, all ...

I needed to have standalong SOAP servers be able to do other
things outside of the context of a SOAP call, yet the SOAP::
Transport::HTTP::Daemon implementation of handle() blocks on
accept(), even if there is nothing to accept. I subclassed SOAP::
Transport::HTTP::Daemon and made my implementation use IO::
Select to make sure the handle() call didn't block if there was
nothing to do. This allows me to write code like this in my SOAP
server:

while ( $server->handle )
{
do_other_stuff();
}

I'm including my subclass here ... perhaps it can form the basis of
a fix for this problem in a future version of SOAP::Lite. BTW, I had
help from Duncan Cameron (duncan_cameron2002@yahoo.co.uk)
who assisted me with the proper usage of IO::Select.

Regards,

John

Falling You - exploring the beauty of voice and sound
http://www.magnatune.com/artists/falling_you

***

package SOAPDaemon;

use strict;
use vars qw(@ISA);
use IO::Select;
use SOAP::Transport::HTTP;

@ISA = qw(SOAP::Transport::HTTP::Daemon);

sub handle
{
my $self = shift->new;

my $read_set = new IO::Select();
$read_set->add( $self->{_daemon} );

my @rh_set = $read_set->can_read( 1 );
my $rh;

foreach $rh ( @rh_set )
{
if ( $rh == $self->{_daemon} )
{
my $c = $self->accept;

while (my $r = $c->get_request)
{
$self->request($r);
$self->SOAP::Transport::HTTP::Server::handle;
$c->send_response($self->response);
}
# replaced ->close, thanks to Sean Meisner
<Sean.Meisner@VerizonWireless.com>
# shutdown() doesn't work on AIX. close() is used in this case.
Thanks to Jos Clijmans <jos.clijmans@recyfin.be>
UNIVERSAL::isa($c, 'shutdown') ? $c->shutdown(2) : $c-
>close();
undef $c;
}
}

return 1;
}

1;

Discussion


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks