From 189d81a1b2913c9ce3a83dbe07a5c05de6a7be7c Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 8 Mar 2011 16:50:35 -0600 Subject: [PATCH] Bugfix: FreeSWITCH::Client::sendmsg was returning the first FSES packet it received, which caused a race condition when an event was in transit; now it waits for Content-Type: command/reply --- scripts/perl/FreeSWITCH/Client.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/perl/FreeSWITCH/Client.pm b/scripts/perl/FreeSWITCH/Client.pm index 9e97218580..01748a8180 100644 --- a/scripts/perl/FreeSWITCH/Client.pm +++ b/scripts/perl/FreeSWITCH/Client.pm @@ -143,7 +143,13 @@ sub sendmsg($$$) { } $self->output("\n"); - return $self->readhash($to); + for(;;) { + $e = $self->readhash(undef); + last if $e->{socketerror} or $e->{'content-type'} eq 'command/reply'; + push @{$self->{events}}, $e; + } + + return $e; } sub command($$) {