| 185 | |
| 186 | #define MI_JSON_MAX_WAIT 2*60*4 |
| 187 | static inline mi_response_t *mi_json_wait_async_reply(struct mi_handler *hdl) |
| 188 | { |
| 189 | mi_json_async_resp_data_t *async_resp_data = |
| 190 | (mi_json_async_resp_data_t*)(hdl+1); |
| 191 | mi_response_t *mi_resp; |
| 192 | int i; |
| 193 | int x; |
| 194 | |
| 195 | for( i=0 ; i<MI_JSON_MAX_WAIT ; i++ ) { |
| 196 | if (hdl->param) |
| 197 | break; |
| 198 | sleep_us(1000*500); |
| 199 | } |
| 200 | |
| 201 | if (i==MI_JSON_MAX_WAIT) { |
| 202 | /* no more waiting ....*/ |
| 203 | lock_get(async_resp_data->lock); |
| 204 | if (hdl->param==NULL) { |
| 205 | hdl->param = MI_JSON_ASYNC_EXPIRED; |
| 206 | x = 0; |
| 207 | } else { |
| 208 | x = 1; |
| 209 | } |
| 210 | lock_release(async_resp_data->lock); |
| 211 | if (x==0) { |
| 212 | LM_INFO("exiting before receiving reply\n"); |
| 213 | return NULL; |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | mi_resp = (mi_response_t *)hdl->param; |
| 218 | if (mi_resp==MI_JSON_ASYNC_FAILED) |
| 219 | mi_resp = NULL; |
| 220 | |
| 221 | /* free the async handler*/ |
| 222 | shm_free(hdl); |
| 223 | |
| 224 | return mi_resp; |
| 225 | } |
| 226 | |
| 227 | #define MI_HTTP_OK_CODE 200 |
| 228 | #define MI_HTTP_ACCEPTED_CODE 202 |
no test coverage detected