@@ -138,7 +138,7 @@ pg_text_array_to_slist(ArrayType *array, struct curl_slist *headers)
138
138
return headers ;
139
139
}
140
140
141
- static int init (CURLM * cm , char * method , char * url , struct curl_slist * reqHeaders , char * reqBody , int64 id , HTAB * curlDataMap )
141
+ static int init (CURLM * cm , char * method , char * url , int timeout_milliseconds , struct curl_slist * reqHeaders , char * reqBody , int64 id , HTAB * curlDataMap )
142
142
{
143
143
CURL * eh = curl_easy_init ();
144
144
@@ -178,6 +178,7 @@ static int init(CURLM *cm, char *method, char *url, struct curl_slist *reqHeader
178
178
curl_easy_setopt (eh , CURLOPT_HEADER , 0L );
179
179
curl_easy_setopt (eh , CURLOPT_URL , url );
180
180
curl_easy_setopt (eh , CURLOPT_HTTPHEADER , reqHeaders );
181
+ curl_easy_setopt (eh , CURLOPT_TIMEOUT_MS , timeout_milliseconds );
181
182
curl_easy_setopt (eh , CURLOPT_PRIVATE , id );
182
183
if (log_min_messages <= DEBUG1 )
183
184
curl_easy_setopt (eh , CURLOPT_VERBOSE , 1L );
@@ -286,6 +287,7 @@ worker_main(Datum main_arg)
286
287
q.id,\
287
288
q.method,\
288
289
q.url,\
290
+ q.timeout_milliseconds,\
289
291
array(\
290
292
select key || ': ' || value from jsonb_each_text(q.headers)\
291
293
),\
@@ -325,21 +327,22 @@ worker_main(Datum main_arg)
325
327
int64 id = DatumGetInt64 (SPI_getbinval (SPI_tuptable -> vals [j ], SPI_tuptable -> tupdesc , 1 , & tupIsNull ));
326
328
char * method = TextDatumGetCString (SPI_getbinval (SPI_tuptable -> vals [j ], SPI_tuptable -> tupdesc , 2 , & tupIsNull ));
327
329
char * url = TextDatumGetCString (SPI_getbinval (SPI_tuptable -> vals [j ], SPI_tuptable -> tupdesc , 3 , & tupIsNull ));
330
+ int32 timeout_milliseconds = DatumGetInt32 (SPI_getbinval (SPI_tuptable -> vals [j ], SPI_tuptable -> tupdesc , 4 , & tupIsNull ));
328
331
329
332
Datum headersBin ;
330
333
Datum bodyBin ;
331
334
ArrayType * pgHeaders ;
332
335
char * body = NULL ;
333
336
334
- headersBin = SPI_getbinval (SPI_tuptable -> vals [j ], SPI_tuptable -> tupdesc , 4 , & tupIsNull );
337
+ headersBin = SPI_getbinval (SPI_tuptable -> vals [j ], SPI_tuptable -> tupdesc , 5 , & tupIsNull );
335
338
if (!tupIsNull ) {
336
339
pgHeaders = DatumGetArrayTypeP (headersBin );
337
340
headers = pg_text_array_to_slist (pgHeaders , headers );
338
341
}
339
- bodyBin = SPI_getbinval (SPI_tuptable -> vals [j ], SPI_tuptable -> tupdesc , 5 , & tupIsNull );
342
+ bodyBin = SPI_getbinval (SPI_tuptable -> vals [j ], SPI_tuptable -> tupdesc , 6 , & tupIsNull );
340
343
if (!tupIsNull ) body = TextDatumGetCString (bodyBin );
341
344
342
- res = init (cm , method , url , headers , body , id , curlDataMap );
345
+ res = init (cm , method , url , timeout_milliseconds , headers , body , id , curlDataMap );
343
346
344
347
if (res ) {
345
348
elog (ERROR , "error: init() returned %d\n" , res );
0 commit comments