MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / mi_http_wait_async_reply

Function mi_http_wait_async_reply

modules/mi_html/mi_html.c:198–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196
197#define MI_HTTP_MAX_WAIT 2*60*4
198static inline mi_response_t *mi_http_wait_async_reply(struct mi_handler *hdl)
199{
200 mi_http_async_resp_data_t *async_resp_data =
201 (mi_http_async_resp_data_t*)(hdl+1);
202 mi_response_t *mi_resp;
203 int i;
204 int x;
205
206 for( i=0 ; i<MI_HTTP_MAX_WAIT ; i++ ) {
207 if (hdl->param)
208 break;
209 sleep_us(1000*500);
210 }
211
212 if (i==MI_HTTP_MAX_WAIT) {
213 /* no more waiting ....*/
214 lock_get(async_resp_data->lock);
215 if (hdl->param==NULL) {
216 hdl->param = MI_HTTP_ASYNC_EXPIRED;
217 x = 0;
218 } else {
219 x = 1;
220 }
221 lock_release(async_resp_data->lock);
222 if (x==0) {
223 LM_INFO("exiting before receiving reply\n");
224 return NULL;
225 }
226 }
227
228 mi_resp = (mi_response_t *)hdl->param;
229 if (mi_resp==MI_HTTP_ASYNC_FAILED)
230 mi_resp = NULL;
231
232 /* free the async handler*/
233 shm_free(hdl);
234
235 return mi_resp;
236}
237
238static inline void trace_http( union sockaddr_union* cl_socket,
239 char *cmd_name, str* message)

Callers 1

Calls 4

sleep_usFunction · 0.85
lock_getFunction · 0.85
lock_releaseFunction · 0.85
shm_freeFunction · 0.85

Tested by

no test coverage detected