Hi all,
attached patch allows http_receive_result to be non blocking if
requested. It allow us to start only one thread for http client side.
any objections?
Thanks,
Alex
=== gwlib/http.c
==================================================================
--- gwlib/http.c (revision 207)
+++ gwlib/http.c (local)
@@ -1656,13 +1656,16 @@
}
-void *http_receive_result(HTTPCaller *caller, int *status, Octstr **final_url,
- List **headers, Octstr **body)
+void *http_receive_result_real(HTTPCaller *caller, int *status, Octstr
**final_url,
+ List **headers, Octstr **body, int blocking)
{
HTTPServer *trans;
void *request_id;
- trans = gwlist_consume(caller);
+ if (blocking == 0)
+ trans = gwlist_extract_first(caller);
+ else
+ trans = gwlist_consume(caller);
if (trans == NULL)
return NULL;
=== gwlib/http.h
==================================================================
--- gwlib/http.h (revision 207)
+++ gwlib/http.h (local)
@@ -352,9 +352,12 @@
* (the one passed to http_start request if non-NULL) or NULL if
* http_caller_signal_shutdown has been called and there are no queued results.
*/
-void *http_receive_result(HTTPCaller *caller, int *status, Octstr **final_url,
- List **headers, Octstr **body);
+void *http_receive_result_real(HTTPCaller *caller, int *status, Octstr
**final_url,
+ List **headers, Octstr **body, int blocking);
+/* old compatibility mode, always blocking */
+#define http_receive_result(caller, status, final_url, headers, body) \
+ http_receive_result_real(caller, status, final_url, headers, body, 1);
/***********************************************************************
* HTTP server interface.