浏览代码

pingpong: Introduce Curl_pp_moredata()

A simple function to test whether the PP is not sending and there are
still more data in its receiver cache. This will be later utilized to:

1) Change Curl_pp_multi_statemach() and Curl_pp_easy_statemach() to
   not test socket state and just call user's statemach_act() function
   when there are more data to process, because otherwise the task would
   just hang, waiting for more data from the socket.

2) Allow PP users to read multiple responses by looping as long as there
   are more data available and current phase is not finished.
   (Currently needed for correct processing of IMAP SELECT responses.)
Jiri Hruska 11 年之前
父节点
当前提交
cd65ecb2e8
共有 2 个文件被更改,包括 14 次插入0 次删除
  1. 4 0
      lib/pingpong.c
  2. 10 0
      lib/pingpong.h

+ 4 - 0
lib/pingpong.c

@@ -503,6 +503,10 @@ CURLcode Curl_pp_disconnect(struct pingpong *pp)
   return CURLE_OK;
 }
 
+bool Curl_pp_moredata(struct pingpong *pp)
+{
+  return (!pp->sendleft && pp->cache && pp->nread_resp < pp->cache_size);
+}
 
 
 #endif

+ 10 - 0
lib/pingpong.h

@@ -130,4 +130,14 @@ CURLcode Curl_pp_disconnect(struct pingpong *pp);
 int Curl_pp_getsock(struct pingpong *pp, curl_socket_t *socks,
                     int numsocks);
 
+
+/***********************************************************************
+ *
+ * Curl_pp_moredata()
+ *
+ * Returns whether there are still more data in the cache and so a call
+ * to Curl_pp_readresp() will not block.
+ */
+bool Curl_pp_moredata(struct pingpong *pp);
+
 #endif /* HEADER_CURL_PINGPONG_H */