@@ -99,12 +99,36 @@ int stns_load_config(char *filename, stns_conf_t *c)
9999 GET_TOML_BYKEY (gid_shift , toml_rtoi , 0 , TOML_NULL_OR_INT );
100100 GET_TOML_BYKEY (cache_ttl , toml_rtoi , 600 , TOML_NULL_OR_INT );
101101 GET_TOML_BYKEY (negative_cache_ttl , toml_rtoi , 10 , TOML_NULL_OR_INT );
102- GET_TOML_BYKEY (ssl_verify , toml_rtob , 1 , TOML_NULL_OR_INT );
102+
103+ // Load long type fields via temporary int variables
104+ int tmp_ssl_verify = 1 ;
105+ int tmp_request_timeout = 10 ;
106+ int tmp_http_location = 0 ;
107+
108+ if (0 != (raw = toml_raw_in (tab , "ssl_verify" ))) {
109+ if (0 != toml_rtob (raw , & tmp_ssl_verify )) {
110+ syslog (LOG_ERR , "%s(stns)[L%d] cannot parse toml file:%s key:ssl_verify" , __func__ , __LINE__ , filename );
111+ }
112+ }
113+ c -> ssl_verify = (long )tmp_ssl_verify ;
114+
115+ if (0 != (raw = toml_raw_in (tab , "request_timeout" ))) {
116+ if (0 != toml_rtoi (raw , & tmp_request_timeout )) {
117+ syslog (LOG_ERR , "%s(stns)[L%d] cannot parse toml file:%s key:request_timeout" , __func__ , __LINE__ , filename );
118+ }
119+ }
120+ c -> request_timeout = (long )tmp_request_timeout ;
121+
122+ if (0 != (raw = toml_raw_in (tab , "http_location" ))) {
123+ if (0 != toml_rtob (raw , & tmp_http_location )) {
124+ syslog (LOG_ERR , "%s(stns)[L%d] cannot parse toml file:%s key:http_location" , __func__ , __LINE__ , filename );
125+ }
126+ }
127+ c -> http_location = (long )tmp_http_location ;
128+
103129 GET_TOML_BYKEY (cache , toml_rtob , 1 , TOML_NULL_OR_INT );
104- GET_TOML_BYKEY (request_timeout , toml_rtoi , 10 , TOML_NULL_OR_INT );
105130 GET_TOML_BYKEY (request_retry , toml_rtoi , 3 , TOML_NULL_OR_INT );
106131 GET_TOML_BYKEY (request_locktime , toml_rtoi , 60 , TOML_NULL_OR_INT );
107- GET_TOML_BYKEY (http_location , toml_rtob , 0 , TOML_NULL_OR_INT );
108132
109133 TRIM_SLASH (api_endpoint )
110134 TRIM_SLASH (cache_dir )
@@ -314,8 +338,8 @@ static CURLcode inner_http_request(stns_conf_t *c, char *path, stns_response_t *
314338 }
315339 }
316340 curl_easy_setopt (curl , CURLOPT_HTTPHEADER , headers );
317- curl_easy_setopt (curl , CURLOPT_SSL_VERIFYPEER , c -> ssl_verify );
318- curl_easy_setopt (curl , CURLOPT_SSL_VERIFYHOST , c -> ssl_verify );
341+ curl_easy_setopt (curl , CURLOPT_SSL_VERIFYPEER , ( long ) c -> ssl_verify );
342+ curl_easy_setopt (curl , CURLOPT_SSL_VERIFYHOST , ( long ) c -> ssl_verify );
319343 curl_easy_setopt (curl , CURLOPT_USERAGENT , STNS_VERSION_WITH_NAME );
320344 if (c -> http_location == 1 ) {
321345 curl_easy_setopt (curl , CURLOPT_FOLLOWLOCATION , 1L );
@@ -347,13 +371,13 @@ static CURLcode inner_http_request(stns_conf_t *c, char *path, stns_response_t *
347371 "http://unix" , path );
348372 }
349373 curl_easy_setopt (curl , CURLOPT_URL , url );
350- curl_easy_setopt (curl , CURLOPT_NOPROGRESS , 1 );
351- curl_easy_setopt (curl , CURLOPT_TIMEOUT , c -> request_timeout );
374+ curl_easy_setopt (curl , CURLOPT_NOPROGRESS , 1L );
375+ curl_easy_setopt (curl , CURLOPT_TIMEOUT , ( long ) c -> request_timeout );
352376 curl_easy_setopt (curl , CURLOPT_WRITEFUNCTION , response_callback );
353377 curl_easy_setopt (curl , CURLOPT_HEADERFUNCTION , header_callback );
354378 curl_easy_setopt (curl , CURLOPT_WRITEDATA , res );
355379 curl_easy_setopt (curl , CURLOPT_HEADERDATA , c );
356- curl_easy_setopt (curl , CURLOPT_NOSIGNAL , 1 );
380+ curl_easy_setopt (curl , CURLOPT_NOSIGNAL , 1L );
357381
358382#ifdef DEBUG
359383 syslog (LOG_ERR , "%s(stns)[L%d] before request http request: %s" , __func__ , __LINE__ , url );
0 commit comments