1
0
mirror of https://github.com/moparisthebest/spdylay synced 2024-12-21 23:28:52 -05:00

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.
This commit is contained in:
Tatsuhiro Tsujikawa 2012-11-22 03:13:30 +09:00
parent 81adb6bc7f
commit 8a5db1751e
4 changed files with 14 additions and 0 deletions

View File

@ -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 {

View File

@ -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;

View File

@ -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();

View File

@ -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;