Re: [gtk-list] Re: gdk_io_* clarification



[big snip]

> It's not the ref count on the file descriptor per se,
> but the ref count on the GSource that was created
> to handle the IO watch.
> 
> This only should happen after a call to gdk_input_remove()
> 
> (Though it won't necessarily be invoked _within_ the call to 
> gdk_input_remove(), especially if that call is made within
> your input function)
> 
> Can you come up with a (hopefully short...) example of
> when this is happening?

	I'll go into a little more detail about what it does ... if that 
isn't sufficient I can try to make an example but I'm not sure I can do
a short one...

	I am writing an NNTP implementation for the Usenet News reader I'm
creating.  Commands are generated and responses are read only after the user
has done something with the GUI so I have notification of write-ready only
turned on when issuing a command, i.e.  most of the time I am monitoring
the socket with

gdk_input_add_full(fd, GDK_INPUT_READ, ...)

	but when the user wants to send a command to the server I do a
gdk_input_remove() on that file descriptor and immediately call

gdk_input_add_full(fd, GDK_INPUT_READ|GDK_INPUT_WRITE, ...)

	(I probably don't need read notification here, but I leave it on
all the time) and then turn it off after the command has been sent.

	What I see is the program will read the greeting string from the
server but after the file descriptor is setup to ask for notification of
write-ready status it just stops.  The change in notification status does
occur in the handler that is called when data is first ready to be read
from the server.

	In summary,

1. Program asks to be notified of data ready to read
2. Data becomes available
3. Handler that was registered with gdk_input_add_full is called
4. Data is read
5. Program now asks for read and write notification (still in handler)
6. Handler returns
7. Destroy notify is called (for reasons I don't understand)
8. Program just sits there forever

	I'm a bit suspicious that the gdk_input_remove(),
gdk_input_add_full() method of changing the notifications on that file
descriptor but I don't see any other way to do it.

	BTW, I assume that leaving write notification on all the time is
a bad thing.  This gets called continously when the program is idle and
sounds a bad as continuous polling to me.  I would've thought it would be
much better to turn this on only when you need it and to turn it off again
straight away.


Thanks.


--
James Macnicol
j-macnicol@adfa.edu.au



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