multi: make max_total_* members size_t
No binary (build failed)
—
(log yok)
| @@ -414,8 +414,7 @@ void Curl_cshutdn_add(struct cshutdn *cshutdn, | |
| size_t conns_in_pool) | |
| { | |
| struct Curl_easy *data = cshutdn->multi->admin; | |
| - | size_t max_total = (cshutdn->multi->max_total_connections > 0) ? |
| - | (size_t)cshutdn->multi->max_total_connections : 0; |
| + | size_t max_total = cshutdn->multi->max_total_connections; |
| /* Add the connection to our shutdown list for non-blocking shutdown | |
| * during multi processing. */ | |
| @@ -627,6 +627,9 @@ | |
| #endif | |
| #endif | |
| + | #if SIZEOF_LONG > SIZEOF_SIZE_T |
| + | #error "unexpected: 'long' is larger than 'size_t'" |
| + | #endif |
| /* | |
| * Arg 2 type for gethostname in case it has not been defined in config file. | |
| */ | |
| @@ -333,6 +333,18 @@ bool curlx_sotouz_fits(curl_off_t sonum, size_t *puznum) | |
| return TRUE; | |
| } | |
| + | |
| + | bool curlx_sltouz(long slnum, size_t *puznum) |
| + | { |
| + | if(slnum < 0) { |
| + | *puznum = 0; |
| + | return FALSE; |
| + | } |
| + | /* We error in curl_setup.h if SIZEOF_LONG > SIZEOF_SIZE_T */ |
| + | *puznum = (size_t)slnum; |
| + | return TRUE; |
| + | } |
| + | |
| curl_off_t curlx_uztoso(size_t uznum) | |
| { | |
| #if SIZEOF_SIZE_T >= SIZEOF_CURL_OFF_T | |
| @@ -73,6 +73,10 @@ bool curlx_sztouz(ssize_t sznum, size_t *puznum); | |
| * too large and set 0 */ | |
| bool curlx_sotouz_fits(curl_off_t sonum, size_t *puznum); | |
| + | /* Convert a long to size_t, return FALSE if negative or too large |
| + | * and set 0 */ |
| + | bool curlx_sltouz(long sznum, size_t *puznum); |
| + | |
| #ifdef _WIN32 | |
| #undef read | |
| #define read(fd, buf, count) (ssize_t)_read(fd, buf, curlx_uztoui(count)) | |
| @@ -3271,10 +3271,12 @@ CURLMcode curl_multi_setopt(CURLM *m, | |
| multi->maxconnects = (unsigned int)uarg; | |
| break; | |
| case CURLMOPT_MAX_HOST_CONNECTIONS: | |
| - | multi->max_host_connections = va_arg(param, long); |
| + | if(!curlx_sltouz(va_arg(param, long), &multi->max_host_connections)) |
| + | res = CURLM_BAD_FUNCTION_ARGUMENT; |
| break; | |
| case CURLMOPT_MAX_TOTAL_CONNECTIONS: | |
| - | multi->max_total_connections = va_arg(param, long); |
| + | if(!curlx_sltouz(va_arg(param, long), &multi->max_total_connections)) |
| + | res = CURLM_BAD_FUNCTION_ARGUMENT; |
| break; | |
| /* options formerly used for pipelining */ | |
| case CURLMOPT_MAX_PIPELINE_LENGTH: | |
| @@ -149,11 +149,10 @@ struct Curl_multi { | |
| struct cshutdn cshutdn; /* connection shutdown handling */ | |
| struct cpool cpool; /* connection pool (bundles) */ | |
| - | long max_host_connections; /* if >0, a fixed limit of the maximum number |
| - | of connections per host */ |
| - | |
| - | long max_total_connections; /* if >0, a fixed limit of the maximum number |
| - | of connections in total */ |
| + | size_t max_host_connections; /* if >0, a fixed limit of the maximum number |
| + | of connections per host */ |
| + | size_t max_total_connections; /* if >0, a fixed limit of the maximum number |
| + | of connections in total */ |
| /* timer callback and user data pointer for the *socket() API */ | |
| curl_multi_timer_callback timer_cb; | |
| @@ -3690,7 +3690,7 @@ static CURLcode create_conn(struct Curl_easy *data, | |
| CURL_TRC_M(data, "Allowing sub-requests (like DoH) to override " | |
| "max connection limit"); | |
| else { | |
| - | infof(data, "No connections available, total of %ld reached.", |
| + | infof(data, "No connections available, total of %zu reached.", |
| data->multi->max_total_connections); | |
| connections_available = FALSE; | |
| } | |