curl-http2-eof.patch 1005 B

123456789101112131415161718192021222324252627282930313233
  1. From c7de3617464f935f6bab113b4da1bb91253baa7e Mon Sep 17 00:00:00 2001
  2. From: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
  3. Date: Sat, 13 Sep 2014 11:59:23 +0900
  4. Subject: [PATCH] http2: Fix busy loop when EOF is encountered
  5. Previously we did not handle EOF from underlying transport socket and
  6. wrongly just returned error code CURL_AGAIN from http2_recv, which
  7. caused busy loop since socket has been closed. This patch adds the
  8. code to handle EOF situation and tells the upper layer that we got
  9. EOF.
  10. ---
  11. lib/http2.c | 6 ++++++
  12. 1 file changed, 6 insertions(+)
  13. diff --git a/lib/http2.c b/lib/http2.c
  14. index 604514d..f86d3eb 100644
  15. --- a/lib/http2.c
  16. +++ b/lib/http2.c
  17. @@ -744,6 +744,12 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
  18. }
  19. infof(conn->data, "nread=%zd\n", nread);
  20. +
  21. + if(nread == 0) {
  22. + failf(conn->data, "EOF");
  23. + return 0;
  24. + }
  25. +
  26. rv = nghttp2_session_mem_recv(httpc->h2,
  27. (const uint8_t *)httpc->inbuf, nread);
  28. --
  29. 2.0.1