Enable EV_READ for downstream connection.
Removed Downstream::force_resume_read() calls. Added missing delete downstream in shrpx_spdy_upstream.cc. In on_stream_close_callback, delete downstream even if response state != MSG_COMPLETE. This may cause segmentaiton fault.
This commit is contained in:
parent
0ffa4bcb46
commit
6702d34651
|
@ -82,7 +82,7 @@ int DownstreamConnection::attach_downstream(Downstream *downstream)
|
||||||
downstream->set_downstream_connection(this);
|
downstream->set_downstream_connection(this);
|
||||||
downstream_ = downstream;
|
downstream_ = downstream;
|
||||||
bufferevent_setwatermark(bev_, EV_READ, 0, SHRPX_READ_WARTER_MARK);
|
bufferevent_setwatermark(bev_, EV_READ, 0, SHRPX_READ_WARTER_MARK);
|
||||||
bufferevent_disable(bev_, EV_READ);
|
bufferevent_enable(bev_, EV_READ);
|
||||||
bufferevent_setcb(bev_,
|
bufferevent_setcb(bev_,
|
||||||
upstream->get_downstream_readcb(),
|
upstream->get_downstream_readcb(),
|
||||||
upstream->get_downstream_writecb(),
|
upstream->get_downstream_writecb(),
|
||||||
|
@ -134,7 +134,7 @@ void DownstreamConnection::detach_downstream(Downstream *downstream)
|
||||||
}
|
}
|
||||||
downstream->set_downstream_connection(0);
|
downstream->set_downstream_connection(0);
|
||||||
downstream_ = 0;
|
downstream_ = 0;
|
||||||
bufferevent_disable(bev_, EV_READ);
|
bufferevent_enable(bev_, EV_READ);
|
||||||
bufferevent_setcb(bev_, 0, 0, idle_eventcb, this);
|
bufferevent_setcb(bev_, 0, 0, idle_eventcb, this);
|
||||||
client_handler_->pool_downstream_connection(this);
|
client_handler_->pool_downstream_connection(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,7 +260,6 @@ int HttpsUpstream::on_read()
|
||||||
delete downstream;
|
delete downstream;
|
||||||
} else {
|
} else {
|
||||||
pause_read(SHRPX_MSG_BLOCK);
|
pause_read(SHRPX_MSG_BLOCK);
|
||||||
downstream->force_resume_read();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(htperr == htparse_error_none) {
|
} else if(htperr == htparse_error_none) {
|
||||||
|
|
|
@ -112,11 +112,11 @@ void on_stream_close_callback
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
upstream->remove_downstream(downstream);
|
upstream->remove_downstream(downstream);
|
||||||
|
delete downstream;
|
||||||
} else {
|
} else {
|
||||||
// At this point, downstream read may be paused. To reclaim
|
// At this point, downstream read may be paused.
|
||||||
// file descriptor, enable read here and catch read
|
upstream->remove_downstream(downstream);
|
||||||
// notification. And delete downstream there.
|
delete downstream;
|
||||||
downstream->force_resume_read();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,6 @@ void on_ctrl_recv_callback
|
||||||
<< downstream;
|
<< downstream;
|
||||||
}
|
}
|
||||||
downstream->set_request_state(Downstream::MSG_COMPLETE);
|
downstream->set_request_state(Downstream::MSG_COMPLETE);
|
||||||
downstream->force_resume_read();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -221,7 +220,6 @@ void on_data_chunk_recv_callback(spdylay_session *session,
|
||||||
<< downstream;
|
<< downstream;
|
||||||
}
|
}
|
||||||
downstream->set_request_state(Downstream::MSG_COMPLETE);
|
downstream->set_request_state(Downstream::MSG_COMPLETE);
|
||||||
downstream->force_resume_read();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,6 +299,7 @@ int SpdyUpstream::on_write()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// After this function call, downstream may be deleted.
|
||||||
int SpdyUpstream::send()
|
int SpdyUpstream::send()
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
|
@ -357,6 +356,7 @@ void spdy_downstream_readcb(bufferevent *bev, void *ptr)
|
||||||
dconn = 0;
|
dconn = 0;
|
||||||
}
|
}
|
||||||
upstream->send();
|
upstream->send();
|
||||||
|
// At this point, downstream may be deleted.
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -418,6 +418,7 @@ void spdy_downstream_eventcb(bufferevent *bev, short events, void *ptr)
|
||||||
upstream->error_reply(downstream, 502);
|
upstream->error_reply(downstream, 502);
|
||||||
downstream->set_response_state(Downstream::MSG_COMPLETE);
|
downstream->set_response_state(Downstream::MSG_COMPLETE);
|
||||||
upstream->send();
|
upstream->send();
|
||||||
|
// At this point, downstream may be deleted.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(events & (BEV_EVENT_ERROR | BEV_EVENT_TIMEOUT)) {
|
} else if(events & (BEV_EVENT_ERROR | BEV_EVENT_TIMEOUT)) {
|
||||||
|
@ -447,6 +448,7 @@ void spdy_downstream_eventcb(bufferevent *bev, short events, void *ptr)
|
||||||
}
|
}
|
||||||
downstream->set_response_state(Downstream::MSG_COMPLETE);
|
downstream->set_response_state(Downstream::MSG_COMPLETE);
|
||||||
upstream->send();
|
upstream->send();
|
||||||
|
// At this point, downstream may be deleted.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue