Re: [gnet] Problems with GNet and GIOChannels...



On Thu, 2004-08-26 at 10:49, Tim Müller wrote:
> On Thursday 26 August 2004 15:35, James Wiggs wrote:
> 
> >    Do you explicitly free the data out of your GConnEvent structures
> > after reading it into your own variables?  Any problems with that?
> 
>   There is a problem with that :-)
> 
>   As the GConn API reference says under 'struct GConnEvent': "GConn Event. 
> buffer and length are set only on GNET_CONN_READ events. The buffer is 
> caller-owned." 
> 
>   "caller-owned" = owned by GNet, do not free under any circumstances. GNet 
> will take care of that.

   THANK YOU!  That was actually my next question: what exactly
does "caller-owned" mean?  So, following up on another question
in that post, when I call gnet_conn_readn() and ask for N bytes,
will I ever get a READ event with *less* than N bytes?  If so,
under what circumstances?  Normal, or if a socket close is
detected, or what?

> > Are they using GChunks or something, where you should not free them
> > with g_free()?  
> 
>   Don't worry about freeing the buffers at all. Just copy the data to your own 
> buffer if you can't process it right away.

   It's a copy, then.  Thanks.  So, to sum up: there are no
hidden gotchas involved in sending arbitrary binary data through
a GConn-managed socket.  The memory in the GConnEvent should not
be freed by the event callback.

> Cheers
>  -Tim

best,
Jim Wiggs




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