You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Both of these methods bypass FIFOBuffer's thread safety by using methods on FIFOBuffer to return memory addresses and sizes to take/receive network data.
FIFOBuffer does not expose its mutex, so the only way to implement this is with a temporary char buffer.
Alternatively, FIFOBuffer could be extended to take a StreamSocket to read/write from, but probably makes FIFOBuffer less generic.
This problem affects use of FIFOBuffer in conjunction with SocketReactor, for which samples show their use. When an additional thread is introduced that can also process FIFO content, you will get issues with concurrent access.
// Poco/Net/src/StreamSocket.cppintStreamSocket::receiveBytes(FIFOBuffer& fifoBuf)
{
// writing to the address returned by next() is not thread safe. available() could also changeint ret = impl()->receiveBytes(fifoBuf.next(), (int) fifoBuf.available());
if (ret > 0) fifoBuf.advance(ret);
return ret;
}
intStreamSocket::sendBytes(FIFOBuffer& fifoBuf)
{
// reading from the address returned by buffer() is not thread safe. used() may also changeint ret = impl()->sendBytes(&fifoBuf.buffer()[0], (int) fifoBuf.used());
if (ret > 0) fifoBuf.drain(ret);
return ret;
}
The text was updated successfully, but these errors were encountered:
aleks-f
changed the title
StreamSocket::receiveBytes(FIFOBuffer&) and sendBytes(FIFOBuffer&) with not thread safe
StreamSocket::receiveBytes(FIFOBuffer&) and sendBytes(FIFOBuffer&) are not thread safe
Oct 3, 2014
Both of these methods bypass
FIFOBuffer
's thread safety by using methods onFIFOBuffer
to return memory addresses and sizes to take/receive network data.FIFOBuffer
does not expose its mutex, so the only way to implement this is with a temporary char buffer.Alternatively,
FIFOBuffer
could be extended to take aStreamSocket
to read/write from, but probably makesFIFOBuffer
less generic.This problem affects use of
FIFOBuffer
in conjunction withSocketReactor
, for which samples show their use. When an additional thread is introduced that can also process FIFO content, you will get issues with concurrent access.The text was updated successfully, but these errors were encountered: