Commit 8a5db175 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

shrpx: Check the length of output buffer in write callback

Possibly because of deferred callback, we may get this callback when
the output buffer is not empty.
parent 81adb6bc
......@@ -54,6 +54,11 @@ void upstream_writecb(bufferevent *bev, void *arg)
{
ClientHandler *handler = reinterpret_cast<ClientHandler*>(arg);
// We actually depend on write low-warter mark == 0.
if(evbuffer_get_length(bufferevent_get_output(bev)) > 0) {
// Possibly because of deferred callback, we may get this callback
// when the output buffer is not empty.
return;
}
if(handler->get_should_close_after_write()) {
delete handler;
} else {
......
......@@ -417,6 +417,9 @@ void https_downstream_readcb(bufferevent *bev, void *ptr)
namespace {
void https_downstream_writecb(bufferevent *bev, void *ptr)
{
if(evbuffer_get_length(bufferevent_get_output(bev)) > 0) {
return;
}
DownstreamConnection *dconn = reinterpret_cast<DownstreamConnection*>(ptr);
Downstream *downstream = dconn->get_downstream();
HttpsUpstream *upstream;
......
......@@ -194,6 +194,9 @@ void readcb(bufferevent *bev, void *ptr)
namespace {
void writecb(bufferevent *bev, void *ptr)
{
if(evbuffer_get_length(bufferevent_get_output(bev)) > 0) {
return;
}
int rv;
SpdySession *spdy = reinterpret_cast<SpdySession*>(ptr);
rv = spdy->on_write();
......
......@@ -491,6 +491,9 @@ void spdy_downstream_readcb(bufferevent *bev, void *ptr)
namespace {
void spdy_downstream_writecb(bufferevent *bev, void *ptr)
{
if(evbuffer_get_length(bufferevent_get_output(bev)) > 0) {
return;
}
DownstreamConnection *dconn = reinterpret_cast<DownstreamConnection*>(ptr);
Downstream *downstream = dconn->get_downstream();
SpdyUpstream *upstream;
......
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