Commit 62b61711 authored by zhujiashun's avatar zhujiashun Committed by gejun

* Fix OnDestroyingStream not calling bug

* Fix socket failed bug in rtmp in connection short case
parent 1578278f
...@@ -258,7 +258,6 @@ void Controller::InternalReset(bool in_constructor) { ...@@ -258,7 +258,6 @@ void Controller::InternalReset(bool in_constructor) {
Controller::Call::Call(Controller::Call* rhs) Controller::Call::Call(Controller::Call* rhs)
: nretry(rhs->nretry) : nretry(rhs->nretry)
, need_feedback(rhs->need_feedback) , need_feedback(rhs->need_feedback)
, touched_by_stream_creator(rhs->touched_by_stream_creator)
, peer_id(rhs->peer_id) , peer_id(rhs->peer_id)
, begin_time_us(rhs->begin_time_us) , begin_time_us(rhs->begin_time_us)
, sending_sock(rhs->sending_sock.release()) { , sending_sock(rhs->sending_sock.release()) {
...@@ -266,7 +265,6 @@ Controller::Call::Call(Controller::Call* rhs) ...@@ -266,7 +265,6 @@ Controller::Call::Call(Controller::Call* rhs)
// setting all the fields to next call and _current_call.OnComplete // setting all the fields to next call and _current_call.OnComplete
// will behave incorrectly. // will behave incorrectly.
rhs->need_feedback = false; rhs->need_feedback = false;
rhs->touched_by_stream_creator = false;
rhs->peer_id = (SocketId)-1; rhs->peer_id = (SocketId)-1;
} }
...@@ -733,7 +731,7 @@ void Controller::Call::OnComplete( ...@@ -733,7 +731,7 @@ void Controller::Call::OnComplete(
case CONNECTION_TYPE_SHORT: case CONNECTION_TYPE_SHORT:
if (sending_sock != NULL) { if (sending_sock != NULL) {
// Check the comment in CONNECTION_TYPE_POOLED branch. // Check the comment in CONNECTION_TYPE_POOLED branch.
if (!sending_sock->is_read_progressive()) { if (!sending_sock->is_read_progressive() && c->_stream_creator == NULL) {
sending_sock->SetFailed(); sending_sock->SetFailed();
} else { } else {
sending_sock->OnProgressiveReadCompleted(); sending_sock->OnProgressiveReadCompleted();
...@@ -769,9 +767,7 @@ void Controller::Call::OnComplete( ...@@ -769,9 +767,7 @@ void Controller::Call::OnComplete(
c->_lb->Feedback(info); c->_lb->Feedback(info);
} }
if (touched_by_stream_creator) { if (c->stream_creator()) {
touched_by_stream_creator = false;
CHECK(c->stream_creator());
c->stream_creator()->OnDestroyingStream( c->stream_creator()->OnDestroyingStream(
sending_sock, c, error_code, end_of_rpc); sending_sock, c, error_code, end_of_rpc);
} }
...@@ -1000,7 +996,6 @@ void Controller::IssueRPC(int64_t start_realtime_us) { ...@@ -1000,7 +996,6 @@ void Controller::IssueRPC(int64_t start_realtime_us) {
_remote_side = tmp_sock->remote_side(); _remote_side = tmp_sock->remote_side();
} }
if (_stream_creator) { if (_stream_creator) {
_current_call.touched_by_stream_creator = true;
_stream_creator->OnCreatingStream(&tmp_sock, this); _stream_creator->OnCreatingStream(&tmp_sock, this);
if (FailedInline()) { if (FailedInline()) {
return HandleSendFailed(); return HandleSendFailed();
......
...@@ -29,7 +29,9 @@ class Controller; ...@@ -29,7 +29,9 @@ class Controller;
class StreamCreator { class StreamCreator {
public: public:
// Called when the socket for sending request is about to be created. // Called when the socket for sending request is about to be created.
// If the RPC has retries, this function is called before each retry. // If the RPC has retries, this function MAY be called before each retry.
// This function would not be called if some preconditions are not
// satisfied.
// Params: // Params:
// inout: pointing to the socket to send requests by default, // inout: pointing to the socket to send requests by default,
// replaceable by user created ones (or keep as it is). remote_side() // replaceable by user created ones (or keep as it is). remote_side()
...@@ -43,8 +45,7 @@ public: ...@@ -43,8 +45,7 @@ public:
Controller* cntl) = 0; Controller* cntl) = 0;
// Called when the stream is about to destroyed. // Called when the stream is about to destroyed.
// If the RPC has retries, this function is called before each retry. // If the RPC has retries, this function MUST be called before each retry.
// This method is always called even if OnCreatingStream() is not called.
// Params: // Params:
// sending_sock: The socket chosen by OnCreatingStream(), if OnCreatingStream // sending_sock: The socket chosen by OnCreatingStream(), if OnCreatingStream
// is not called, the enclosed socket may be NULL. // is not called, the enclosed socket may be NULL.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment