]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
pingpong: Introduce Curl_pp_moredata()
authorJiri Hruska <jirka@fud.cz>
Thu, 14 Feb 2013 18:36:43 +0000 (19:36 +0100)
committerSteve Holme <steve_holme@hotmail.com>
Fri, 22 Feb 2013 18:35:15 +0000 (18:35 +0000)
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.)

lib/pingpong.c
lib/pingpong.h

index 4b10e845e87e02c65c8c7309372ae766b9b5b865..69834da7d02158da6e2f03be92e59ae72be51108 100644 (file)
@@ -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
index d65671b32e8b6248c9cd30cdb3f5ab03d31403fa..3a87e404188569812d9d88f3020c4099359c981e 100644 (file)
@@ -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 */