Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIx multi thread calls asyncWrite concurrently. #74

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Commits on Mar 29, 2020

  1. Configuration menu
    Copy the full SHA
    f43d656 View commit details
    Browse the repository at this point in the history
  2. 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!
    g-xianhui committed Mar 29, 2020
    Configuration menu
    Copy the full SHA
    edf46e4 View commit details
    Browse the repository at this point in the history