diff --git a/trunk/src/app/srs_app_rtc_dtls.cpp b/trunk/src/app/srs_app_rtc_dtls.cpp index d5657e923..1c2a34f16 100644 --- a/trunk/src/app/srs_app_rtc_dtls.cpp +++ b/trunk/src/app/srs_app_rtc_dtls.cpp @@ -259,7 +259,7 @@ SrsDtls::SrsDtls(ISrsDtlsCallback* cb) version_ = SrsDtlsVersionAuto; trd = NULL; - client_state_ = SrsDtlsStateInit; + state_ = SrsDtlsStateInit; } SrsDtls::~SrsDtls() @@ -409,8 +409,11 @@ srs_error_t SrsDtls::on_dtls(char* data, int nb_data) { srs_error_t err = srs_success; - // When got packet, always stop the ARQ. - if (role_ == SrsDtlsRoleClient && client_state_ == SrsDtlsStateServerHello) { + // When got packet, stop the ARQ if server in the first ARQ state SrsDtlsStateServerHello. + // @note But for ARQ state, we should never stop the ARQ, for example, we are in the second ARQ sate + // SrsDtlsStateServerDone, but we got previous late wrong packet ServeHello, which is not the expect + // packet SessionNewTicket, we should never stop the ARQ thread. + if (role_ == SrsDtlsRoleClient && state_ == SrsDtlsStateServerHello) { stop_arq(); } diff --git a/trunk/src/app/srs_app_rtc_dtls.hpp b/trunk/src/app/srs_app_rtc_dtls.hpp index 03342c16e..32cb76025 100644 --- a/trunk/src/app/srs_app_rtc_dtls.hpp +++ b/trunk/src/app/srs_app_rtc_dtls.hpp @@ -97,12 +97,12 @@ public: // The state for DTLS client. enum SrsDtlsState { - SrsDtlsStateInit, - SrsDtlsStateClientHello, - SrsDtlsStateServerHello, - SrsDtlsStateClientCertificate, - SrsDtlsStateServerDone, - SrsDtlsStateClientDone, + SrsDtlsStateInit, // Start. + SrsDtlsStateClientHello, // Should start ARQ thread. + SrsDtlsStateServerHello, // We are in the first ARQ state. + SrsDtlsStateClientCertificate, // Should start ARQ thread again. + SrsDtlsStateServerDone, // We are in the second ARQ state. + SrsDtlsStateClientDone, // Done. }; class SrsDtls : public ISrsCoroutineHandler @@ -127,7 +127,7 @@ private: // @note If passive(DTLS server), the ARQ is driven by DTLS client. SrsCoroutine* trd; // The DTLS-client state to drive the ARQ thread. - SrsDtlsState client_state_; + SrsDtlsState state_; // @remark: dtls_role_ default value is DTLS_SERVER. SrsDtlsRole role_;