MCPcopy Create free account
hub / github.com/apache/httpd / md_util_try

Function md_util_try

modules/md/md_util.c:1040–1080  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1038/* try and retry for a while **********************************************************************/
1039
1040apr_status_t md_util_try(md_util_try_fn *fn, void *baton, int ignore_errs,
1041 apr_interval_time_t timeout, apr_interval_time_t start_delay,
1042 apr_interval_time_t max_delay, int backoff)
1043{
1044 apr_status_t rv;
1045 apr_time_t now = apr_time_now();
1046 apr_time_t giveup = now + timeout;
1047 apr_interval_time_t nap_duration = start_delay? start_delay : apr_time_from_msec(100);
1048 apr_interval_time_t nap_max = max_delay? max_delay : apr_time_from_sec(10);
1049 apr_interval_time_t left;
1050 int i = 0;
1051
1052 while (1) {
1053 if (APR_SUCCESS == (rv = fn(baton, i++))) {
1054 break;
1055 }
1056 else if (!APR_STATUS_IS_EAGAIN(rv) && !ignore_errs) {
1057 break;
1058 }
1059
1060 now = apr_time_now();
1061 if (now > giveup) {
1062 rv = APR_TIMEUP;
1063 break;
1064 }
1065
1066 left = giveup - now;
1067 if (nap_duration > left) {
1068 nap_duration = left;
1069 }
1070 if (nap_duration > nap_max) {
1071 nap_duration = nap_max;
1072 }
1073
1074 apr_sleep(nap_duration);
1075 if (backoff) {
1076 nap_duration *= 2;
1077 }
1078 }
1079 return rv;
1080}
1081
1082/* execute process ********************************************************************************/
1083

Callers 5

md_acme_drive_cert_pollFunction · 0.85
ad_chain_retrieveFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected