[OpenSIPS-Users] FIFO very fragile

Dave Singer dave.dorasinger at gmail.com
Tue May 10 02:28:21 CEST 2011


Brett,

In your perl app are you starting and forking/threading the read before
   print FIFO ":uptime:reply_fifo\n";
?
I seem to remember starting the read process first to be very important.
My speculation is the reply fifo is not truely active until it has a
process actively attached and reading from it. So when opensips tries
to write to it, it succeeds checking the fifo file exists and it has
proper properties but when it tries to write to it linux says it is
not ready or something since it is not a buffer per say. Then opensips
waits for something to update/push it which never happens. (again just
my speculation from my previous efforts)

Dave

On Mon, May 9, 2011 at 5:01 PM, Brett Nemeroff <brett at nemeroff.com> wrote:
>
> Dave,
> Yeah, I do actually get a reply. Works reliably too as long as I'm careful about what I'm asking for. I'm trying to do all of this directly from perl. For some reason I can't write to the fifo with a simple:
> open(FIFO,">/tmp/opensips_fifo");
> print FIFO ":uptime:reply_fifo\n";
> The fifo never receives it.. now, if I leave the reader attached and use "echo" from bash, it works great.
> Really, the concern I have it doing things that cause the fifo to "die" and become unavailable. I've seen this with the opensipsctl script as well, where the fifo just stops responding until you restart.
> -Brett
>
> On Mon, May 9, 2011 at 4:03 PM, Dave Singer <dave.dorasinger at gmail.com> wrote:
>>
>> Are you actually able to get results out of the reply fifo?
>> It's been a long time since I created my bash fifo script so I don't remember all the particulars of what I ran into.
>> It can be important to start the read fifo before sending the command
>>
>> Hear is a snippet from a bash fifo I did.
>>
>> trap "\rm -f $dlg $fifo_reply ${fifo_answer}* 2> /dev/null; exit 1" 0
>> if [ ! -w $FIFO ] ; then # can I write to FIFO server?
>>         echo "Error opening ser's FIFO $FIFO" >> $DEBUG_OUT
>>         echo "FAILED"
>>         exit 1
>> fi
>> mkdir -p $fifo_dir 2> /dev/null
>> mkfifo $fifo_reply # create a reply FIFO
>> if [ $? -ne 0 ] ; then
>>         echo "error opening reply fifo $fifo_reply" >> $DEBUG_OUT
>>         echo "FAILED"
>>         exit 1
>> fi
>> chmod a+w $fifo_reply
>> # start reader now so that it is ready for replies
>> # immediately after a request is out
>> cat < $fifo_reply > $dlg  &
>> fifo_job="$!"
>>
>> # set trap to cleanup in case of problems or outside kill
>> trap "kill -9 $fifo_job $fifo_answer_job 2>1 >> $DEBUG_OUT ;  exit 1" 0
>> # finally actually push command to the fifo
>> echo "reply pid: $fifo_job, reply fifo: $fifo_reply" >> $DEBUG_OUT
>>
>> You may want to just use the fifo handeling built into opensipsctl
>> eg:
>> /path/opensipsctl fifo ps
>>
>> Dave
>>
>>
>> On Mon, May 9, 2011 at 1:42 PM, Brett Nemeroff <brett at nemeroff.com> wrote:
>>>
>>> Dave,
>>> I don't think those are the issues. First of all, if I supply the full path to the reply fifo, I get an error message that the filename is invalid. More importantly, it doesn't work. :) without the full path, it does work.
>>> Secondly, I don't think it's SELinux issue because it *does work* repeatedly over and over. But an extra carriage return spoils the fun for everyone and I can't fix it without restarting opensips.
>>> Do you believe SELinux could cause an issue like that?
>>> Thanks!
>>> -Brett
>>>
>>> On Mon, May 9, 2011 at 3:39 PM, Dave Singer <dave.dorasinger at gmail.com> wrote:
>>>>
>>>> Brett,
>>>> I believe you need the full path to the reply fifo.
>>>> Try:
>>>> echo -e ":address_dump:/tmp/my_fifo\n\n" > /tmp/opensips_fifo
>>>>
>>>> you may also have a permissions ( chmod a+w /tmp/my_fifo ) and/or SELinux issue (very likely if SELinux is enabled, I posted a howto for SELinux in the list a number of months back)
>>>>
>>>> Dave
>>>>
>>>> On Mon, May 9, 2011 at 9:40 AM, Brett Nemeroff <brett at nemeroff.com> wrote:
>>>>>
>>>>> Hello List,
>>>>> So I've been doing some testing with the mi_fifo and found that it appears to be really fragile. Here's what I've done:
>>>>> mkfifo /tmp/my_fifo
>>>>> cat /tmp/my_fifo&
>>>>> echo -e ":address_dump:my_fifo\n\n" > /tmp/opensips_fifo
>>>>> *returns*
>>>>> 200 OK
>>>>>   48 <1.2.3.4,2, 0, 0, NULL, NULL>
>>>>> ** cat process ends
>>>>> cat /tmp/my_fifo&
>>>>> echo -e ":address_dump:my_fifo\n\n" > /tmp/opensips_fifo
>>>>> ** nothing
>>>>> At this point, I can't make the fifo work again until I restart opensips. If I detach from the fifo (kill the cat, so to speak), and reattach it doesn't work. Nothing seems to make it responsive again. At first I though something was horribly broken, but then I removed one of my \n from the fifo command and now it works "as expected". Two new-lines shouldn't break the fifo, right?
>>>>> Thanks!
>>>>> -Brett
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Users mailing list
>>>>> Users at lists.opensips.org
>>>>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> David Singer
>>>>
>>>> _______________________________________________
>>>> Users mailing list
>>>> Users at lists.opensips.org
>>>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>>>
>>>
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.opensips.org
>>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>>
>>
>>
>>
>> --
>> David Singer
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>



More information about the Users mailing list