adding fifo input to the main glib2 loop



Hi,
  I have an app that mkfifo()s && open()s and then attaches a
g_io_channel to the fd. The basic idea is that clients can drop scheme
code to a fifo for the app to execute, thus the server only reads the
pipe and clients should only write it.

I have this working with one catch, after the first command is read
(first callback instance) the app itself goes to 100% CPU use. Other
commands get through fine but from a break && bt it seems that glib2 is
churning on some property of the fd (the break always stops in glib2s
select (or poll, cant remember which it was)).

Is there some condition that I must set or other thing required to
monitor fifos? Or some app that folks know of that does fifo IO from the
main loop.

This is a trimmed non error detecting version of what I am doing.

GIOCondition cond = GIOCondition( G_IO_IN ); //| G_IO_ERR | G_IO_PRI );
string socketpath = getRemoveControlSocketPath(); //  == ~/.ego/socket
unlink( socketpath.c_str() );
rc = mkfifo( socketpath.c_str(), S_IRUSR | S_IWUSR | O_NONBLOCK );
int fd = open( socketpath.c_str(), O_RDONLY | O_NONBLOCK );
channel = g_io_channel_unix_new( fd );
result  = g_io_add_watch( channel, cond, executeRemoveScheme_cb,
(gpointer)fd );
g_io_channel_unref (channel);

I have tried with and without IO_ERR|IO_PRI added.
-- 
-----------------------------------------------------
http://witme.sourceforge.net/libferris.web/




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]