km4arr / openpgm

Automatically exported from code.google.com/p/openpgm
0 stars 0 forks source link

select on pgmsocket and linux pipe doesn't work to capture pipe's incoming data #20

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
environment : 
Linux : 2.6.18-164.11.1.el5
openpgm version : openpgm-5.1.118 

Can someone please help with the following issue : 

when we do select on read operation on  pgmsocket (pgmsocket is set at blocking 
mode ) and linux pipes, if there is not pgmdata, the select seems to be able to 
correctly return with pipe socketId set (if there is incoming data in pipe). 

However, if there is incoming data for pgmsocket, when select returns, it only 
captures socektId for pgmsocket, not pipe socketId, even though there is 
incoming data for the pipe.

Thanks,
Frank

Original issue reported on code.google.com by frankxie...@gmail.com on 24 May 2012 at 4:30

GoogleCodeExporter commented 9 years ago
You'll like this, it's a /feature/ not a bug.

In order to reduce to one thread you receive events for every notification that 
the PGM protocol requires for operation.  This means many events and timeouts 
are raised without receiving data.

If you want to *only* receive data you will have to implement an asynchronous 
queue between the raw PGM socket and your application.  An example is provided 
with async.[ch] and one of the examples.  The code is provided as an example so 
it can be modified as required with limited expectation of support.  Depending 
on abstraction it may be possible to combine the threads together but it 
depends on your event loop and pump.

I'll also add a reminder here that your senders also need to call pgm_recv() 
and by definition will not receive data unless you are using a flat bus 
topology.  Your integration design determines how many threads you require.  
This can be one thread for receiving, sending, the event queue, or one or more 
for each.

-- 
Steve-o

Original comment by fnjo...@gmail.com on 24 May 2012 at 4:41

GoogleCodeExporter commented 9 years ago
Hi, Steve:

Thanks for your prompt reply.

The async.c code shows only one pgm_sock_t invovled. 

What we are trying to achieve is to use ONE single thread to receive data from 
MULTIPLE pgm_sock_t, plus a few linux PIPEs. 

Any advices ? 

Thanks,
Frank

Original comment by frankxie...@gmail.com on 24 May 2012 at 5:22

GoogleCodeExporter commented 9 years ago
I like to restate my original question in case there is any mis-understanding.

Let's there are 1 pgm_sockets, s1 (set blocking mode), there is pipes : p1

There is a variable FD_SET readset.
readset is set correcly to include s1, p1.

now I do select(nfds, &readset, NULL, NULL, NULL ).
Here is the issue I was trying to describe in my original post:

case 1, if there is NO data pending on pgmsocket s1 AND there is data pending 
on p1, the select return with correct bit set in readset.

case 2, if there IS data pending on pgmsocket s1 AND there IS data pending on 
p1, the select return with ONLY bits set for s1, not bit set for p1. 

I am trying to understand why case2 happens.

Thanks,
Frank

Original comment by frankxie...@gmail.com on 24 May 2012 at 8:10

GoogleCodeExporter commented 9 years ago
This is reading more confusing.  How about an example code to demonstrate?

Original comment by fnjo...@gmail.com on 2 Jun 2012 at 2:18