After closing all connections on a SocketService I was unable to connect again. Further investigation showed that the the code was waiting in SocketService::Attach, trying to 'EnterMutex()', but the Mutex is locked elswhere.
The problem turned out to be that even when no ports are connected the SocketService still calls the system function poll(), which never seems to return.
This only shows up after a connection has been made and severed, because before that the SocketService thread is not started.
I am not sure what it is supposed to be polling...it is not clear to me what the iosync member is suppoised to be doing.
Anyway the solution seems to be to *NOT* call poll, if count == 0. This does mean though that the code sits in a loop until a new connection is made. Maybe a ccxx_yield() call should also be included.
Well, fixed.
You must always call poll. There is always a fd to wait. Note that ccxx_yield solution waste many processor time. iosync is used to tell to thread to add or delete a socket from wait list.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So what was the final resolution to this? It is unclear from freddy77's response what "well, fixed" means. I am having what sounds like the issue nickl described in his post, but I do not see the exact code he referenced in port.cpp so I'm assuming the SocketPort::attach function has been changed since the referenced version.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Using CommonC++ 1.9.3:
OS Linux 2.4.3 (mandrake)
After closing all connections on a SocketService I was unable to connect again. Further investigation showed that the the code was waiting in SocketService::Attach, trying to 'EnterMutex()', but the Mutex is locked elswhere.
The problem turned out to be that even when no ports are connected the SocketService still calls the system function poll(), which never seems to return.
This only shows up after a connection has been made and severed, because before that the SocketService thread is not started.
I am not sure what it is supposed to be polling...it is not clear to me what the iosync member is suppoised to be doing.
Anyway the solution seems to be to *NOT* call poll, if count == 0. This does mean though that the code sits in a loop until a new connection is made. Maybe a ccxx_yield() call should also be included.
:::::::
port.cpp:448
if(count)
{
poll( mfd.getList(), count + 1, timer );
LeaveMutex();
}
else
{
LeaveMutex();
ccxx_yield();
}
Obviously if there is a reason to poll the iosync, then this code misses that.
Well, fixed.
You must always call poll. There is always a fd to wait. Note that ccxx_yield solution waste many processor time. iosync is used to tell to thread to add or delete a socket from wait list.
So what was the final resolution to this? It is unclear from freddy77's response what "well, fixed" means. I am having what sounds like the issue nickl described in his post, but I do not see the exact code he referenced in port.cpp so I'm assuming the SocketPort::attach function has been changed since the referenced version.