[Freeswitch-users] Server Disconnected when SIGINT occured

Anthony Minessale anthony.minessale at gmail.com
Tue Jan 19 08:04:45 PST 2010


Its nothing we can fix, that is what you must do on a failed read syscall.
you can do a non blocking read instead and take your chances.


On Tue, Jan 19, 2010 at 3:07 AM, lakshmanan ganapathy
<lakindia89 at gmail.com>wrote:

> I tried with SIGUSR1, but no progress. I got SERVER_DISCONNECTED.
> Output:
>
> CHILD 3814: Received USR1
> EVENT [SERVER_DISCONNECTED]
>
> In esl.c, in esl_recv_event() function, line no: 824
> if (rrval < 0) {
>                         strerror_r(handle->errnum, handle->err,
> sizeof(handle->err));
>                         goto fail;
> }
> When the program is blocked under receive, I passed the signal. So recv
> returns -1, and in fail: it call esl_disconnect(handle).
>
> Is it because of this??? If so, whether it should be fixed or not???
>
>
>
>
> On Mon, Jan 18, 2010 at 9:54 PM, Anthony Minessale <
> anthony.minessale at gmail.com> wrote:
>
>> try a less famous signal like SIGUSR1 it's possible something in perl
>> still reacts to SIGINT
>>
>>
>>
>> On Mon, Jan 18, 2010 at 5:22 AM, lakshmanan ganapathy <
>> lakindia89 at gmail.com> wrote:
>>
>>> Here is the result
>>>
>>> Program:
>>>
>>> require ESL;
>>> use IO::Socket::INET;
>>> use Data::Dumper;
>>>
>>> my $ip = "192.168.1.222";
>>> my $sock = new IO::Socket::INET ( LocalHost => $ip,  LocalPort =>
>>> '8447',  Proto => 'tcp',  Listen => 1,  Reuse => 1 );
>>> die "Could not create socket: $!\n" unless $sock;
>>>
>>>
>>> for(;;) {
>>>     my $new_sock = $sock->accept();
>>>     next if (not defined ($new_sock));
>>>     my $pid = fork();
>>>     if ($pid) {
>>>         close($new_sock);
>>>         next;
>>>     }
>>>     print "CHILD PID: $$\n";
>>>     &register_Signals_Child();
>>>     sub register_Signals_Child() {
>>>         foreach ( keys %SIG ) {
>>>             $SIG{$_} = 'Handler';
>>>         }
>>>     }
>>>
>>>     sub Handler() {
>>>
>>>         my $handle=$_[0];
>>>         if($handle eq "INT") {
>>>             print "CHILD $$: SIGNAL SIG$handle is generated\n";
>>>         }
>>>         else
>>>         {
>>>             print "CHILD $$: Received $handle\n";
>>>
>>>         }
>>>     }
>>>     my $host = $new_sock->sockhost();
>>>     my $fd = fileno($new_sock);
>>>
>>>     my $con = new ESL::ESLconnection($fd);
>>>     my $info = $con->getInfo();
>>>
>>>     my $uuid = $info->getHeader("unique-id");
>>>
>>>     printf "Connected call %s, from %s\n", $uuid,
>>> $info->getHeader("caller-caller-id-number");
>>>     my $r=$con->execute("answer");
>>>     print Dumper $r;
>>>     $con->events("plain","all");
>>>     my
>>> $re=$con->execute("playback","/usr/local/freeswitch1/sounds/en/us/callie/ivr/8000/ivr-welcome_to_freeswitch.wav");
>>>     while($con->connected()) {
>>>         my $e = $con->recvEvent();
>>>
>>>         if ($e) {
>>>             my $name = $e->getHeader("event-name");
>>>             print "EVENT [$name]\n";
>>>             if ($name eq "DTMF") {
>>>                 my $digit = $e->getHeader("dtmf-digit");
>>>                 print "$digit\n";
>>>             }
>>>         }
>>>     }
>>>     close($new_sock);
>>> }
>>>
>>> I executed the program and the following things were printed
>>>
>>> CHILD PID: 6778
>>> Connected call e0d1001a-03f4-11df-b002-db488337e0ea, from 1001
>>> $VAR1 = 0;
>>> EVENT [CHANNEL_EXECUTE]
>>> EVENT [CHANNEL_ANSWER]
>>> EVENT [CHANNEL_EXECUTE_COMPLETE]
>>> EVENT [COMMAND]
>>> EVENT [CHANNEL_EXECUTE]
>>> EVENT [HEARTBEAT]
>>> EVENT [RE_SCHEDULE]
>>> EVENT [CHANNEL_EXECUTE_COMPLETE]
>>>
>>> Then from another shell I executed kill -2 6778, the result is follows
>>> CHILD 6778: SIGNAL SIGINT is generated
>>> EVENT [SERVER_DISCONNECTED]
>>>
>>> But the child process is still running as expected.
>>> But  I don't know why I received SERVER_DISCONNECTED from freeswitch???
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Thu, Jan 14, 2010 at 1:27 PM, lakshmanan ganapathy <
>>> lakindia89 at gmail.com> wrote:
>>>
>>>> I taught the signal handler will be inherited by the child process. It
>>>> also does like that.
>>>> After making a call, If I press ctrl + c, the above program printed
>>>> PARENT PID: Signal SIGINT is generated
>>>> CHILD PID: Signal SIGINT is generated.
>>>>
>>>> So I think the sigal handlers will be inherited to the child.
>>>> Anyway I'll also try registering signal handlers in child also, and then
>>>> I'll come back with that result.
>>>>
>>>> Thanks....
>>>> On Wed, Jan 13, 2010 at 9:48 PM, Anthony Minessale <
>>>> anthony.minessale at gmail.com> wrote:
>>>>
>>>>> you would have to register signals in your child process too
>>>>>
>>>>>   On Wed, Jan 13, 2010 at 3:13 AM, lakshmanan ganapathy <
>>>>> lakindia89 at gmail.com> wrote:
>>>>>
>>>>>>  Hi all,
>>>>>>
>>>>>> I've done a sample program (In perl ESL) , which play a file to the
>>>>>> caller and then it will call recvEvent() and print the event name. I've
>>>>>> handled signals also.
>>>>>>
>>>>>> When I send SIGINT to my program (Perl), the signal handler is called
>>>>>> and I can see the print output. But in the same time,  I received
>>>>>> SERVER_DISCONNECTED from freeswitch as event.
>>>>>>
>>>>>> I don't know why I received SERVER_DISCONNECTED from freeswitch. Is it
>>>>>> because, the recvEvent() from perl internally  calls the recvevent function
>>>>>> in the Esl.c and when it waits to receive the information from socket, the
>>>>>> signal occurred???
>>>>>>
>>>>>> Please clarify me!!
>>>>>>
>>>>>> Here is my program
>>>>>> require ESL;
>>>>>> use IO::Socket::INET;
>>>>>> use Data::Dumper;
>>>>>>
>>>>>> my $ip = "192.168.1.222";
>>>>>> my $sock = new IO::Socket::INET ( LocalHost => $ip,  LocalPort =>
>>>>>> '8447',  Proto => 'tcp',  Listen => 1,  Reuse => 1 );
>>>>>> die "Could not create socket: $!\n" unless $sock;
>>>>>> &register_Signals();
>>>>>>
>>>>>> for(;;) {
>>>>>>     my $new_sock = $sock->accept();
>>>>>>     next if (not defined ($new_sock));
>>>>>>     my $pid = fork();
>>>>>>     if ($pid) {
>>>>>>         close($new_sock);
>>>>>>         next;
>>>>>>     }
>>>>>>     print "CHILD PID: $$\n";
>>>>>>     my $host = $new_sock->sockhost();
>>>>>>     my $fd = fileno($new_sock);
>>>>>>
>>>>>>     my $con = new ESL::ESLconnection($fd);
>>>>>>     my $info = $con->getInfo();
>>>>>>
>>>>>>     my $uuid = $info->getHeader("unique-id");
>>>>>>
>>>>>>     printf "Connected call %s, from %s\n", $uuid,
>>>>>> $info->getHeader("caller-caller-id-number");
>>>>>>     my $r=$con->execute("answer");
>>>>>>     print Dumper $r;
>>>>>>     $con->events("plain","all");
>>>>>>     my
>>>>>> $re=$con->execute("playback","/usr/local/freeswitch1/sounds/en/us/callie/ivr/8000/ivr-welcome_to_freeswitch.wav");
>>>>>>
>>>>>>     while($con->connected()) {
>>>>>>         my $e = $con->recvEvent();
>>>>>>
>>>>>>         if ($e) {
>>>>>>             my $name = $e->getHeader("event-name");
>>>>>>             print "EVENT [$name]\n";
>>>>>>             if ($name eq "DTMF") {
>>>>>>                 my $digit = $e->getHeader("dtmf-digit");
>>>>>>                 print "$digit\n";
>>>>>>             }
>>>>>>         }
>>>>>>     }
>>>>>>     close($new_sock);
>>>>>> }
>>>>>> sub register_Signals() {
>>>>>>     foreach ( keys %SIG ) {
>>>>>>         $SIG{$_} = 'sig_Handler';
>>>>>>     }
>>>>>> }
>>>>>>
>>>>>> sub sig_Handler() {
>>>>>>     my $handle=$_[0];
>>>>>>     if($handle eq "INT") {
>>>>>>         print "$$: SIGNAL SIG$handle is generated\n";
>>>>>>     }
>>>>>> }
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> FreeSWITCH-users mailing list
>>>>>> FreeSWITCH-users at lists.freeswitch.org
>>>>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>>>> UNSUBSCRIBE:
>>>>>> http://lists.freeswitch.org/mailman/options/freeswitch-users
>>>>>> http://www.freeswitch.org
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Anthony Minessale II
>>>>>
>>>>> FreeSWITCH http://www.freeswitch.org/
>>>>> ClueCon http://www.cluecon.com/
>>>>> Twitter: http://twitter.com/FreeSWITCH_wire
>>>>>
>>>>> AIM: anthm
>>>>> MSN:anthony_minessale at hotmail.com<MSN%3Aanthony_minessale at hotmail.com>
>>>>> GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com<PAYPAL%3Aanthony.minessale at gmail.com>
>>>>> IRC: irc.freenode.net #freeswitch
>>>>>
>>>>> FreeSWITCH Developer Conference
>>>>> sip:888 at conference.freeswitch.org<sip%3A888 at conference.freeswitch.org>
>>>>> iax:guest at conference.freeswitch.org/888
>>>>> googletalk:conf+888 at conference.freeswitch.org<googletalk%3Aconf%2B888 at conference.freeswitch.org>
>>>>> pstn:+19193869900
>>>>>
>>>>> _______________________________________________
>>>>> FreeSWITCH-users mailing list
>>>>> FreeSWITCH-users at lists.freeswitch.org
>>>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>>> UNSUBSCRIBE:
>>>>> http://lists.freeswitch.org/mailman/options/freeswitch-users
>>>>> http://www.freeswitch.org
>>>>>
>>>>>
>>>>
>>>
>>> _______________________________________________
>>> FreeSWITCH-users mailing list
>>> FreeSWITCH-users at lists.freeswitch.org
>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>>> http://www.freeswitch.org
>>>
>>>
>>
>>
>> --
>> Anthony Minessale II
>>
>> FreeSWITCH http://www.freeswitch.org/
>> ClueCon http://www.cluecon.com/
>> Twitter: http://twitter.com/FreeSWITCH_wire
>>
>> AIM: anthm
>> MSN:anthony_minessale at hotmail.com <MSN%3Aanthony_minessale at hotmail.com>
>> GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com<PAYPAL%3Aanthony.minessale at gmail.com>
>> IRC: irc.freenode.net #freeswitch
>>
>> FreeSWITCH Developer Conference
>> sip:888 at conference.freeswitch.org <sip%3A888 at conference.freeswitch.org>
>> iax:guest at conference.freeswitch.org/888
>> googletalk:conf+888 at conference.freeswitch.org<googletalk%3Aconf%2B888 at conference.freeswitch.org>
>> pstn:+19193869900
>>
>> _______________________________________________
>> FreeSWITCH-users mailing list
>> FreeSWITCH-users at lists.freeswitch.org
>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>> http://www.freeswitch.org
>>
>>
>
> _______________________________________________
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
>


-- 
Anthony Minessale II

FreeSWITCH http://www.freeswitch.org/
ClueCon http://www.cluecon.com/
Twitter: http://twitter.com/FreeSWITCH_wire

AIM: anthm
MSN:anthony_minessale at hotmail.com <MSN%3Aanthony_minessale at hotmail.com>
GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com<PAYPAL%3Aanthony.minessale at gmail.com>
IRC: irc.freenode.net #freeswitch

FreeSWITCH Developer Conference
sip:888 at conference.freeswitch.org <sip%3A888 at conference.freeswitch.org>
iax:guest at conference.freeswitch.org/888
googletalk:conf+888 at conference.freeswitch.org<googletalk%3Aconf%2B888 at conference.freeswitch.org>
pstn:+19193869900
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20100119/cc2b1f01/attachment-0002.html 


More information about the FreeSWITCH-users mailing list