mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
the perform "state machine" is more explained now
This commit is contained in:
parent
e2844f5e04
commit
b93a60daf9
41
lib/multi.c
41
lib/multi.c
@ -42,7 +42,8 @@ struct Curl_one_easy {
|
|||||||
struct Curl_one_easy *prev;
|
struct Curl_one_easy *prev;
|
||||||
|
|
||||||
CURL *easy_handle; /* this is the easy handle for this unit */
|
CURL *easy_handle; /* this is the easy handle for this unit */
|
||||||
CURLMstate state; /* the handle's state */
|
CURLMstate state; /* the handle's state */
|
||||||
|
CURLcode result; /* previous result */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -193,7 +194,7 @@ CURLMcode curl_multi_fdset(CURLM *multi_handle,
|
|||||||
/* after the transfer is done, go DONE */
|
/* after the transfer is done, go DONE */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
easy = easy->next; /* check next handle */
|
||||||
}
|
}
|
||||||
|
|
||||||
return CURLM_OK;
|
return CURLM_OK;
|
||||||
@ -209,30 +210,62 @@ CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles)
|
|||||||
|
|
||||||
easy=multi->first.next;
|
easy=multi->first.next;
|
||||||
while(easy) {
|
while(easy) {
|
||||||
|
|
||||||
switch(easy->state) {
|
switch(easy->state) {
|
||||||
case CURLM_STATE_INIT:
|
case CURLM_STATE_INIT:
|
||||||
|
/* init this transfer */
|
||||||
|
easy->result = Curl_init(easy->easy_handle);
|
||||||
/* after init, go CONNECT */
|
/* after init, go CONNECT */
|
||||||
|
if(CURLE_OK == easy->result)
|
||||||
|
easy->state = CURLM_STATE_CONNECT;
|
||||||
break;
|
break;
|
||||||
case CURLM_STATE_CONNECT:
|
case CURLM_STATE_CONNECT:
|
||||||
|
/* connect */
|
||||||
|
easy->result = Curl_connect(easy->easy_handle);
|
||||||
/* after connect, go DO */
|
/* after connect, go DO */
|
||||||
|
if(CURLE_OK == easy->result)
|
||||||
|
easy->state = CURLM_STATE_DO;
|
||||||
break;
|
break;
|
||||||
case CURLM_STATE_DO:
|
case CURLM_STATE_DO:
|
||||||
|
/* Do the fetch or put request */
|
||||||
|
easy->result = Curl_do(easy->easy_handle);
|
||||||
/* after do, go PERFORM */
|
/* after do, go PERFORM */
|
||||||
|
if(CURLE_OK == easy->result)
|
||||||
|
easy->state = CURLM_STATE_PERFORM;
|
||||||
break;
|
break;
|
||||||
case CURLM_STATE_PERFORM:
|
case CURLM_STATE_PERFORM:
|
||||||
/* read/write data if it is ready to do so */
|
/* read/write data if it is ready to do so */
|
||||||
|
easy->result = Curl_readwrite(easy->easy_handle, &done);
|
||||||
/* after the transfer is done, go DONE */
|
/* after the transfer is done, go DONE */
|
||||||
|
if(TRUE == done)
|
||||||
|
easy->state = CURLM_STATE_DONE;
|
||||||
break;
|
break;
|
||||||
case CURLM_STATE_DONE:
|
case CURLM_STATE_DONE:
|
||||||
|
/* post-transfer command */
|
||||||
|
easy->result = Curl_done(easy->easy_handle);
|
||||||
/* after we have DONE what we're supposed to do, go COMPLETED */
|
/* after we have DONE what we're supposed to do, go COMPLETED */
|
||||||
|
if(CURLE_OK == easy->result)
|
||||||
|
easy->state = CURLM_STATE_COMPLETED;
|
||||||
break;
|
break;
|
||||||
case CURLM_STATE_COMPLETED:
|
case CURLM_STATE_COMPLETED:
|
||||||
/* this is a completed transfer */
|
/* this is a completed transfer, it is likely to still be connected */
|
||||||
|
|
||||||
|
/* This node should be delinked from the list now and we should post
|
||||||
|
an information message that we are complete. */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if((CURLM_STATE_COMPLETED != easy->state) &&
|
||||||
|
(CURLE_OK != easy->result)) {
|
||||||
|
/*
|
||||||
|
* If an error was returned, and we aren't in completed now,
|
||||||
|
* then we go to completed and consider this transfer aborted.
|
||||||
|
*/
|
||||||
|
easy->state = CURLM_STATE_COMPLETED;
|
||||||
|
}
|
||||||
|
|
||||||
|
easy = easy->next; /* operate on next handle */
|
||||||
}
|
}
|
||||||
|
return CURLM_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
CURLMcode curl_multi_cleanup(CURLM *multi_handle);
|
CURLMcode curl_multi_cleanup(CURLM *multi_handle);
|
||||||
|
Loading…
Reference in New Issue
Block a user