connection_read_handler: fix potential double free
In connection_read_handler(), make sure we act accordingly when r->connection->error is set (indicating the the current request has been finalized). Reproduction of what happens when we don't: enable IPRO+SPDY, and rapidly refresh a page with chrome. These rapid abortions will eventually trigger a segfault/hang/misc bad behaviour.
This commit is contained in:
committed by
Jeffrey Crowell
parent
6a8a1c5bf7
commit
dc40c902ec
@@ -1281,6 +1281,15 @@ void ps_connection_read_handler(ngx_event_t* ev) {
|
|||||||
rc = read(c->fd, chr, 256);
|
rc = read(c->fd, chr, 256);
|
||||||
} while (rc > 0 || (rc == -1 && errno == EINTR)); // Retry on EINTR.
|
} while (rc > 0 || (rc == -1 && errno == EINTR)); // Retry on EINTR.
|
||||||
|
|
||||||
|
if (r->connection->error) {
|
||||||
|
ngx_log_error(NGX_LOG_DEBUG, ngx_cycle->log, 0,
|
||||||
|
"pagespeed [%p] request already finalized", r);
|
||||||
|
ctx->pagespeed_connection = NULL;
|
||||||
|
ngx_close_connection(c);
|
||||||
|
ngx_http_finalize_request(r, NGX_ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (rc == -1 && errno != EAGAIN && errno != EWOULDBLOCK) {
|
if (rc == -1 && errno != EAGAIN && errno != EWOULDBLOCK) {
|
||||||
ctx->pagespeed_connection = NULL;
|
ctx->pagespeed_connection = NULL;
|
||||||
ngx_close_connection(c);
|
ngx_close_connection(c);
|
||||||
|
|||||||
Reference in New Issue
Block a user