yugan95 commented on code in PR #3801:
URL: https://github.com/apache/celeborn/pull/3801#discussion_r3795295215


##########
cpp/celeborn/network/MessageDispatcher.cpp:
##########
@@ -176,12 +218,88 @@ folly::Future<std::unique_ptr<Message>> 
MessageDispatcher::operator()(
         return p.getFuture();
       });
 
-  this->pipeline_->write(std::move(toSendMsg));
+  // Observe the write future, like Java's TransportClient does with
+  // StdChannelListener. wangle's AsyncSocketHandler::write returns an
+  // already-failed future when the socket is no longer good, and otherwise
+  // fails it from AsyncTransport::WriteCallback::writeErr. Neither necessarily
+  // flips closed_ before the check below, so dropping the future would leave
+  // the promise pending until the request timeout.
+  this->pipeline_->write(std::move(toSendMsg))
+      .thenError([this, requestId](const folly::exception_wrapper& e) {
+        // Phrased like the Java listener's message so that
+        // ShuffleClientImpl::getPushDataFailCause classifies it as a
+        // connection failure rather than a non-critical one.
+        failPendingRequest(
+            requestId,
+            fmt::format(
+                "Failed to send request {}, errorMsg: {}",
+                requestId,
+                e.what().toStdString()));
+      });

Review Comment:
   Marked unavailable rather than closed: `state->retire(reason)` flips the 
flag `active()` reports and fails everything still outstanding on the 
connection retriably — the `failOutstandingRequests` analogue — and is called 
from all three write continuations, `close()` and `~MessageDispatcher`. Closing 
from here isn't safe, for the reason in your other comment: `close()` needs 
`this` and `pipeline_`. The socket is closed by wangle's read-side error 
handling anyway.
   
   On the test: `failedWriteMakesTransportClientInactive` asserts `active()` is 
false after a failed write, which is what the factory gates reuse on 
(`TransportClient.cpp:315`). The factory reconnecting end to end would need a 
listening socket, and there is no server-side scaffolding under `cpp/` yet.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to