aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2015-09-27 19:40:20 +0200
committerDaniel Stenberg <daniel@haxx.se>2015-09-27 23:23:33 +0200
commit46ad4f7f93d80998eba01ceaa6c2619e381a151e (patch)
treef2e76e9197dde28178b4391fb6373770abcf3c0d
parent790d6de485154440d4f8822a54641ee00a0d09f3 (diff)
http2: avoid superfluous Curl_expire() calls
... only call it when there is data arriving for another handle than the one that is currently driving it. Improves single-stream download performance quite a lot. Thanks-to: Tatsuhiro Tsujikawa Bug: http://curl.haxx.se/mail/lib-2015-09/0097.html
-rw-r--r--lib/http2.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/lib/http2.c b/lib/http2.c
index 32de3f64d..05b919625 100644
--- a/lib/http2.c
+++ b/lib/http2.c
@@ -459,7 +459,14 @@ static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame,
stream->memlen += ncopy;
data_s->state.drain++;
- Curl_expire(data_s, 1);
+ {
+ /* get the pointer from userp again since it was re-assigned above */
+ struct connectdata *conn_s = (struct connectdata *)userp;
+
+ /* if we receive data for another handle, wake that up */
+ if(conn_s->data != data_s)
+ Curl_expire(data_s, 1);
+ }
break;
case NGHTTP2_PUSH_PROMISE:
rv = push_promise(data_s, conn, &frame->push_promise);
@@ -525,10 +532,10 @@ static int on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
struct HTTP *stream;
struct SessionHandle *data_s;
size_t nread;
+ struct connectdata *conn = (struct connectdata *)userp;
(void)session;
(void)flags;
(void)data;
- (void)userp;
DEBUGASSERT(stream_id); /* should never be a zero stream ID here */
@@ -550,8 +557,11 @@ static int on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
stream->memlen += nread;
data_s->state.drain++;
- Curl_expire(data_s, 1); /* TODO: fix so that this can be set to 0 for
- immediately? */
+
+ /* if we receive data for another handle, wake that up */
+ if(conn->data != data_s)
+ Curl_expire(data_s, 1); /* TODO: fix so that this can be set to 0 for
+ immediately? */
DEBUGF(infof(data_s, "%zu data received for stream %u "
"(%zu left in buffer %p, total %zu)\n",
@@ -698,9 +708,8 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
struct HTTP *stream;
struct SessionHandle *data_s;
int32_t stream_id = frame->hd.stream_id;
-
+ struct connectdata *conn = (struct connectdata *)userp;
(void)flags;
- (void)userp;
DEBUGASSERT(stream_id); /* should never be a zero stream ID here */
@@ -764,7 +773,9 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
Curl_add_buffer(stream->header_recvbuf, value, valuelen);
Curl_add_buffer(stream->header_recvbuf, "\r\n", 2);
data_s->state.drain++;
- Curl_expire(data_s, 1);
+ /* if we receive data for another handle, wake that up */
+ if(conn->data != data_s)
+ Curl_expire(data_s, 1);
DEBUGF(infof(data_s, "h2 status: HTTP/2 %03d\n",
stream->status_code));
@@ -779,7 +790,9 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
Curl_add_buffer(stream->header_recvbuf, value, valuelen);
Curl_add_buffer(stream->header_recvbuf, "\r\n", 2);
data_s->state.drain++;
- Curl_expire(data_s, 1);
+ /* if we receive data for another handle, wake that up */
+ if(conn->data != data_s)
+ Curl_expire(data_s, 1);
DEBUGF(infof(data_s, "h2 header: %.*s: %.*s\n", namelen, name, valuelen,
value));