shinberg / cpp-hiredis-cluster

c++ cluster wrapper for hiredis with async and unix sockets features
BSD 3-Clause "New" or "Revised" License
65 stars 26 forks source link

Why retry() does not check "userErrorCb_ != NULL" #14

Closed jinq0123 closed 7 years ago

jinq0123 commented 7 years ago

userErrorCb_ is checked before call:

    if ( that->userErrorCb_ != NULL && that->userErrorCb_(

But retry() doesn't check NULL. Is that OK?

    static void retry( Connection *con, void *r, void *data )
    {
        AsyncHiredisCommand* that = static_cast<AsyncHiredisCommand*>( data );

        if( that->processHiredisCommand( con ) != REDIS_OK )
        {
            that->userErrorCb_( *that, DisconnectedException(), HiredisProcess::FAILED );
            that->userCallback_p_( that->cluster_p_, r, that->userPrivData_ );
            delete that;
        }
    }
shinberg commented 7 years ago

Hi, because commandState is set to RETRY only if userErrorCb_ exists and returns RETRY state, see the folowing sources

            if ( that->userErrorCb_ != NULL && that->userErrorCb_( *that, ce, state ) == RETRY )
            {
                commandState = RETRY;
            }

thank you