RE: [gnet] Multiple messages in one read on a GConn



Hi Tim -

Thanks for your response. Please find comments below.

I run Linux Enterprise Server 3/ Glib/ Gnet-2.0

> --- Im using a GServer and multiple GConns to get TCP data.
> On the connection callback, on a READ event, I find that multiple messages
> on the same GConn are delivered in a single event. What should I do to make
> one event show up for every new TCP packet (message) ?

I don't think that's possible. If you need this kind of stuff you'd have to 
make it part of the protocol/data, I think (e.g. send a header specifying the 
size of the packet before each packet, or having a unique separator between 
data packets or so).

As you mentioned the protocol does have message size in each packet. 
I just wanted a different way to receive and process messages.
This is not an issue. :)


> --- I run a g_main_loop to let the GConn events come up. I have a problem-
> The callback function locksup.. code just stalls there! Anybody else have
> similar problems?

Code just stalls where when? Do you have a small test program to the list that 
demonstrates the problem?

The code execution stalled at the GConn callback. 

... gconn_callback_function(){

	gchar anotherBuffer[100];

		switch(event..)

			GCONN_READ:

				printf("GCONN_READ");
				memcpy(anotherBuffer, event->buffer, event->length);
				queueMessage(anotherBuffer);
			break;

		GCONN_WRITE:

			break;
}

I had just one GConn object on Event watch.
In the callback, on a GCONN_READ event, I printed the primitive and then queued the event->buffer for processing.
This happened for 2 messages- the primitive got printed in the log, and the processor received the buffer.
On the third message- the primitive got printed and then thats it- execution stalled. no queueing of the buffer.
I even added printfs before the memcpy, strangely nothing happened after the -- printf("GCONN_READ");

I was looking at the mailing lists and what I have could be the Linux Poll Bug thats being discussed. 
My CPU utilization for polling one socket was 50-80% !!
Im quitting on Asynchronous callbacks and going back to the implementing a thread that just "polls" all GTcpSockets for data. Me, Quitter :(

Thanks Tim.






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