@@ -445,6 +445,8 @@ void InitialConnectionContext::readCallback(const bmqio::Status& status,
445445 int * numNeeded,
446446 bdlbb::Blob* blob)
447447{
448+ // executed by one of the *IO* threads
449+
448450 enum RcEnum {
449451 // Value for the various RC error categories
450452 rc_SUCCESS = 0 ,
@@ -518,6 +520,8 @@ void InitialConnectionContext::handleEvent(
518520 bmqp_ctrlmsg::AuthenticationMessage,
519521 bmqp_ctrlmsg::NegotiationMessage>& message)
520522{
523+ // executed by an *AUTHENTICATION* or one of the *IO* threads
524+
521525 enum RcEnum {
522526 // Value for the various RC error categories
523527 rc_SUCCESS = 0 ,
@@ -527,7 +531,7 @@ void InitialConnectionContext::handleEvent(
527531 bsl::shared_ptr<InitialConnectionContext> self = shared_from_this ();
528532
529533 bmqu::MemOutStream errStream (d_allocator_p);
530- int rc = rc_SUCCESS ;
534+ int rc = rc_ERROR ;
531535
532536 bslmt::LockGuard<bslmt::Mutex> guard (&d_mutex); // LOCKED
533537
@@ -551,7 +555,6 @@ void InitialConnectionContext::handleEvent(
551555 }
552556 }
553557 else {
554- rc = rc_ERROR;
555558 errStream << " Unexpected event received: " << oldState << " -> "
556559 << input;
557560 }
@@ -560,7 +563,6 @@ void InitialConnectionContext::handleEvent(
560563 case Event::e_AUTH_REQUEST: {
561564 if (!bsl::holds_alternative<bmqp_ctrlmsg::AuthenticationMessage>(
562565 message)) {
563- rc = rc_ERROR;
564566 errStream
565567 << " Expecting AuthenticationMessage for event AUTH_REQUEST." ;
566568 break ;
@@ -576,7 +578,6 @@ void InitialConnectionContext::handleEvent(
576578 authenticationMsg);
577579 }
578580 else {
579- rc = rc_ERROR;
580581 errStream << " Unexpected event received: " << oldState << " -> "
581582 << input;
582583 }
@@ -585,7 +586,6 @@ void InitialConnectionContext::handleEvent(
585586 case Event::e_NEGOTIATION_MESSAGE: {
586587 if (!bsl::holds_alternative<bmqp_ctrlmsg::NegotiationMessage>(
587588 message)) {
588- rc = rc_ERROR;
589589 errStream << " Expecting NegotiationMessage for event "
590590 " e_NEGOTIATION_MESSAGE." ;
591591 break ;
@@ -608,6 +608,8 @@ void InitialConnectionContext::handleEvent(
608608
609609 createNegotiationContext ();
610610 negotiationContext ()->setNegotiationMessage (negotiationMsg);
611+
612+ rc = rc_SUCCESS;
611613 }
612614 else if (oldState == State::e_NEGOTIATING_OUTBOUND &&
613615 negotiationMsg.isBrokerResponseValue ()) {
@@ -616,9 +618,10 @@ void InitialConnectionContext::handleEvent(
616618
617619 BSLS_ASSERT_SAFE (negotiationContext ());
618620 negotiationContext ()->setNegotiationMessage (negotiationMsg);
621+
622+ rc = rc_SUCCESS;
619623 }
620624 else {
621- rc = rc_ERROR;
622625 errStream << " Unexpected event received: " << oldState << " -> "
623626 << input << " [ negotiationMsg: " << negotiationMsg
624627 << " ]" ;
@@ -639,9 +642,10 @@ void InitialConnectionContext::handleEvent(
639642 BSLS_ASSERT_SAFE (negotiationContext ()
640643 ->negotiationMessage ()
641644 .isClientIdentityValue ());
645+
646+ rc = rc_SUCCESS;
642647 }
643648 else {
644- rc = rc_ERROR;
645649 errStream << " Unexpected event received: " << oldState << " -> "
646650 << input;
647651 }
@@ -657,7 +661,6 @@ void InitialConnectionContext::handleEvent(
657661 break ;
658662 }
659663 default :
660- rc = rc_ERROR;
661664 errStream << " InitialConnectionContext: "
662665 << " unexpected event received: " << input;
663666 }
@@ -667,12 +670,12 @@ void InitialConnectionContext::handleEvent(
667670
668671 bsl::shared_ptr<mqbnet::Session> session;
669672
670- if (rc == 0 && d_state == State::e_NEGOTIATED) {
673+ if (rc == rc_SUCCESS && d_state == State::e_NEGOTIATED) {
671674 rc = d_negotiator_p->createSessionOnMsgType (errStream, &session, this );
672675 BALL_LOG_INFO << " Created a session with " << channel ()->peerUri ();
673676 }
674677
675- if (rc != 0 || d_state == State::e_NEGOTIATED) {
678+ if (rc != rc_SUCCESS || d_state == State::e_NEGOTIATED) {
676679 BALL_LOG_INFO << " Finished initial connection with rc = " << rc
677680 << " , error = '" << errStream.str () << " '" ;
678681 guard.release ()->unlock ();
0 commit comments