[asio] possible multi-threaded bug with async_write_some()

I'm running asio (boost 1.38) multi-threaded, and noticed that on a context switch between threads, my handler for async_write_some() will sometimes get invoked with no data transferred. My handler would call async_write_some() again if there was remaining data, but this caused (most of) the data to get sent twice since there appears to still be a call to the handler pending in the work queue. I'm not sure if this behavior is a bug or not, but the solution was to check for 0 data transferred and exit the handler if so. -Brian

I neglected to note that this is under Cygwin with -DBOOST_ASIO_DISABLE_IOCP -DBOOST_ASIO_ENABLE_CANCELIO. -Brian Brian and Victoria wrote:
I'm running asio (boost 1.38) multi-threaded, and noticed that on a context switch between threads, my handler for async_write_some() will sometimes get invoked with no data transferred. My handler would call async_write_some() again if there was remaining data, but this caused (most of) the data to get sent twice since there appears to still be a call to the handler pending in the work queue.
I'm not sure if this behavior is a bug or not, but the solution was to check for 0 data transferred and exit the handler if so.
-Brian
participants (1)
-
Brian and Victoria