summaryrefslogtreecommitdiff
path: root/lib/pingpong.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2013-02-15 11:03:42 +0100
committerDaniel Stenberg <daniel@haxx.se>2013-02-15 11:10:18 +0100
commitc25383ae1329199107943211e543612d288eb1ae (patch)
tree2331b0da5e51f749924dd205702109ebc974e9a6 /lib/pingpong.c
parent6106eeba16f45a6a2fccdfac2b9b64dcf12f2a20 (diff)
downloadcurl-c25383ae1329199107943211e543612d288eb1ae.tar.gz
rename "easy" statemachines: call them block instead
... since they're not used by the easy interface really, I wanted to remove the association. Also, I unified the pingpong statemachine driver into a single function with a 'wait' argument: Curl_pp_statemach.
Diffstat (limited to 'lib/pingpong.c')
-rw-r--r--lib/pingpong.c74
1 files changed, 22 insertions, 52 deletions
diff --git a/lib/pingpong.c b/lib/pingpong.c
index 330b47f76..eeeeec339 100644
--- a/lib/pingpong.c
+++ b/lib/pingpong.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -76,48 +76,10 @@ long Curl_pp_state_timeout(struct pingpong *pp)
return timeout_ms;
}
-
/*
- * Curl_pp_multi_statemach()
- *
- * called repeatedly until done when the multi interface is used.
+ * Curl_pp_statemach()
*/
-CURLcode Curl_pp_multi_statemach(struct pingpong *pp)
-{
- struct connectdata *conn = pp->conn;
- curl_socket_t sock = conn->sock[FIRSTSOCKET];
- int rc;
- struct SessionHandle *data=conn->data;
- CURLcode result = CURLE_OK;
- long timeout_ms = Curl_pp_state_timeout(pp);
-
- if(timeout_ms <= 0) {
- failf(data, "server response timeout");
- return CURLE_OPERATION_TIMEDOUT;
- }
-
- rc = Curl_socket_ready(pp->sendleft?CURL_SOCKET_BAD:sock, /* reading */
- pp->sendleft?sock:CURL_SOCKET_BAD, /* writing */
- 0);
-
- if(rc == -1) {
- failf(data, "select/poll error");
- return CURLE_OUT_OF_MEMORY;
- }
- else if(rc != 0)
- result = pp->statemach_act(conn);
-
- /* if rc == 0, then select() timed out */
-
- return result;
-}
-
-/*
- * Curl_pp_easy_statemach()
- *
- * called repeatedly until done when the easy interface is used.
- */
-CURLcode Curl_pp_easy_statemach(struct pingpong *pp)
+CURLcode Curl_pp_statemach(struct pingpong *pp, bool wait)
{
struct connectdata *conn = pp->conn;
curl_socket_t sock = conn->sock[FIRSTSOCKET];
@@ -125,29 +87,37 @@ CURLcode Curl_pp_easy_statemach(struct pingpong *pp)
long interval_ms;
long timeout_ms = Curl_pp_state_timeout(pp);
struct SessionHandle *data=conn->data;
- CURLcode result;
+ CURLcode result = CURLE_OK;
if(timeout_ms <=0 ) {
failf(data, "server response timeout");
return CURLE_OPERATION_TIMEDOUT; /* already too little time */
}
- interval_ms = 1000; /* use 1 second timeout intervals */
- if(timeout_ms < interval_ms)
- interval_ms = timeout_ms;
+ if(wait) {
+ interval_ms = 1000; /* use 1 second timeout intervals */
+ if(timeout_ms < interval_ms)
+ interval_ms = timeout_ms;
+ }
+ else
+ interval_ms = 0; /* immediate */
rc = Curl_socket_ready(pp->sendleft?CURL_SOCKET_BAD:sock, /* reading */
pp->sendleft?sock:CURL_SOCKET_BAD, /* writing */
interval_ms);
- if(Curl_pgrsUpdate(conn))
- result = CURLE_ABORTED_BY_CALLBACK;
- else
- result = Curl_speedcheck(data, Curl_tvnow());
+ if(wait) {
+ /* if we didn't wait, we don't have to spend time on this now */
+ if(Curl_pgrsUpdate(conn))
+ result = CURLE_ABORTED_BY_CALLBACK;
+ else
+ result = Curl_speedcheck(data, Curl_tvnow());
- if(result)
- ;
- else if(rc == -1) {
+ if(result)
+ return result;
+ }
+
+ if(rc == -1) {
failf(data, "select/poll error");
result = CURLE_OUT_OF_MEMORY;
}