Commit faee23a9 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Fixed assertion failure. Resume downstream read on SPDY stream close.

parent 4ac68952
...@@ -87,6 +87,11 @@ bool Downstream::resume_read(IOCtrlReason reason) ...@@ -87,6 +87,11 @@ bool Downstream::resume_read(IOCtrlReason reason)
return ioctrl_.resume_read(reason); return ioctrl_.resume_read(reason);
} }
void Downstream::force_resume_read()
{
ioctrl_.force_resume_read();
}
namespace { namespace {
void check_transfer_encoding_chunked(bool *chunked, void check_transfer_encoding_chunked(bool *chunked,
const Headers::value_type &item) const Headers::value_type &item)
...@@ -416,12 +421,13 @@ void body_buf_cb(evbuffer *body, size_t oldlen, size_t newlen, void *arg) ...@@ -416,12 +421,13 @@ void body_buf_cb(evbuffer *body, size_t oldlen, size_t newlen, void *arg)
int Downstream::init_response_body_buf() int Downstream::init_response_body_buf()
{ {
assert(response_body_buf_ == 0); if(!response_body_buf_) {
response_body_buf_ = evbuffer_new(); response_body_buf_ = evbuffer_new();
if(response_body_buf_ == 0) { if(response_body_buf_ == 0) {
DIE(); DIE();
} }
evbuffer_setcb(response_body_buf_, body_buf_cb, this); evbuffer_setcb(response_body_buf_, body_buf_cb, this);
}
return 0; return 0;
} }
......
...@@ -56,6 +56,7 @@ public: ...@@ -56,6 +56,7 @@ public:
int32_t get_stream_id() const; int32_t get_stream_id() const;
void pause_read(IOCtrlReason reason); void pause_read(IOCtrlReason reason);
bool resume_read(IOCtrlReason reason); bool resume_read(IOCtrlReason reason);
void force_resume_read();
// downstream request API // downstream request API
const Headers& get_request_headers() const; const Headers& get_request_headers() const;
void add_request_header(const std::string& name, const std::string& value); void add_request_header(const std::string& name, const std::string& value);
......
...@@ -58,4 +58,10 @@ bool IOControl::resume_read(IOCtrlReason reason) ...@@ -58,4 +58,10 @@ bool IOControl::resume_read(IOCtrlReason reason)
} }
} }
void IOControl::force_resume_read()
{
std::fill(ctrlv_.begin(), ctrlv_.end(), 0);
bufferevent_enable(bev_, EV_READ);
}
} // namespace shrpx } // namespace shrpx
...@@ -48,6 +48,8 @@ public: ...@@ -48,6 +48,8 @@ public:
void pause_read(IOCtrlReason reason); void pause_read(IOCtrlReason reason);
// Returns true if read operation is enabled after this call // Returns true if read operation is enabled after this call
bool resume_read(IOCtrlReason reason); bool resume_read(IOCtrlReason reason);
// Clear all pause flags and enable read
void force_resume_read();
private: private:
bufferevent *bev_; bufferevent *bev_;
std::vector<int> ctrlv_; std::vector<int> ctrlv_;
......
...@@ -103,6 +103,11 @@ void on_stream_close_callback ...@@ -103,6 +103,11 @@ void on_stream_close_callback
if(downstream->get_response_state() == Downstream::MSG_COMPLETE) { if(downstream->get_response_state() == Downstream::MSG_COMPLETE) {
upstream->get_downstream_queue()->remove(downstream); upstream->get_downstream_queue()->remove(downstream);
delete downstream; delete downstream;
} else {
// At this point, downstream read may be paused. To reclaim
// file descriptor, enable read here and catch read
// notification. And delete downstream there.
downstream->force_resume_read();
} }
} }
} }
......
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