Race condition in ps2ip client & server?
Posted: Tue Oct 05, 2004 3:09 am
I suspect we have a race condition in the usage of the static rpc buffers. Imagine two threads, both calling send. The first gets all the way through the code into sif, sends the request and blocks on the semaphore waiting for the rpc reply. Because its blocks, the second charges through a similar code path, scribbles all over the outgoing rpc buffer (which often is used as the reply buffer) and then blocks on its own semaphore.
Two threads using the same static buffers at [about] the same time. No?
(In an older code base, I had assigned a per-thread rpc buffer. This prevented the overwrite, but was overkill since the rpc client and servers are essentially not "thread-hot". Which brings up the whole issue of multiple threads doing TCP/IP traffice from the EE. Imagine one doing an accept/recv/select. A simple lock won't work allow multi-threading to occur nicely-- perhaps a better approach is to provide the ability for the IOP server to provide a separate thread per caling thread from the EE)
Two threads using the same static buffers at [about] the same time. No?
(In an older code base, I had assigned a per-thread rpc buffer. This prevented the overwrite, but was overkill since the rpc client and servers are essentially not "thread-hot". Which brings up the whole issue of multiple threads doing TCP/IP traffice from the EE. Imagine one doing an accept/recv/select. A simple lock won't work allow multi-threading to occur nicely-- perhaps a better approach is to provide the ability for the IOP server to provide a separate thread per caling thread from the EE)