I need some explanations on the following behaviour of
WaitToRemove...
I create an object wich waits to remove an event.
When it receives it, it puts in the event heap a new event
and waits to remove it.
The problem is that sometimes the thread is blocked in
the second
waitToRemove function. When I trace (with the
EventHeapDebugger)
events in the heap, no event exists.
So, I suppose that the second event is remove before
being get, but,
I don't
know why and how.
Someone can help me? What should I do to have a
"coherent" behaviour?
Here the code and the output:
public void go(){
try{
EventHeap iROS_eh = new
EventHeap(System.getProperty("heapMachine"));
Event[] tev;
Event[] res;
Event evSR;
tev = new Event[2];
tev[0] = new Event("foo1");
tev[1] = new Event("foo2");
System.out.println("Waiting..."); res = iROS_eh.waitToRemoveEvent(tev); Event ev = res[0]; String evType = ev.getEventType(); System.out.println("received :" + evType); if(evType.equals("foo1")){ iROS_eh.putEvent(new Event("foo2")); System.out.println("Sent"); } System.out.println("Waiting for the second time..."); res = iROS_eh.waitToRemoveEvent(tev); System.out.println("OK! CORRECT");
}
catch(Exception e){
System.err.println("Exception : "+e.getMessage());
}
}
public static void main(String[] theArguments) {
Serveur s = new Serveur();
s.go();
} // main(String[])
A client send the event "foo1". The output is:
Connection: connected to machine:4535
Waiting...
received :foo1
Sent
Waiting for the second time...
This process is often blocked in the second WaitToRemove.
Logged In: YES
user_id=629201
Hi Brad, I have a possible explanation. This might be caused
by the bug #725885 I submitted before.
The server remains still waiting to remove a matching event
even if the waitToRemoveEvent call has been terminated in
the client side by CTRL+C or timeout. In this state, the first
matching event can be removed right away and returned to
nowhere.
It is likely that you pressed CTRL+C during
waitToRemoveEvent call before you experience this problem
for some reason. (There seems a path that waits to remove
foo2 without posting one and this might be the reason.) Once
you did, this problem happens over and over since you need
to CTRL+C every time the program is blocked in
waitToRemoveEvent.
Does it help? If this was your problem as I assume, you might
want to have further discussions in bug #725885.
Logged In: NO
like what man