Skip to content

Conversation

g-xianhui
Copy link

Multiple thread may excute asyncWrite at the same time.
1. Thread A request quite a lot RedisAsyncClient::command, all the
command post to RedisClientImpl::strand.
2. Thread B execute commands in strand one by one. The first asyncWrite
swap dataWrited and dataQueued, so other doAsyncCommand won't enter
asyncWrite.
3. the first asyncWrite call ends with a boost::asio::async_write, and
left a later asyncWrite as handler.
4. boost::asio::async_write complete, thread C excute the handler
asyncWrite, clear dataWrited.
5. Now thread B execute doAsyncCommand, and find dataWrited was empty,
so it enters asyncWrite concurrently!

1. Thread A request quite a lot RedisAsyncClient::command, all the
command post to RedisClientImpl::strand.
2. Thread B execute commands in strand one by one. The first asyncWrite
swap dataWrited and dataQueued, so other doAsyncCommand won't enter
asyncWrite.
3. the first asyncWrite call ends with a boost::asio::async_write, and
left a later asyncWrite as handler.
4. boost::asio::async_write complete, thread C excute the handler
asyncWrite, clear dataWrited.
5. Now thread B execute doAsyncCommand, and find dataWrited was empty,
so it enters asyncWrite concurrently!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant