Rev 1532 | Rev 1547 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1532 | Rev 1536 | ||
---|---|---|---|
Line 214... | Line 214... | ||
214 | .remove_callback = conn_remove |
214 | .remove_callback = conn_remove |
215 | }; |
215 | }; |
216 | 216 | ||
217 | /** Insert sort timeout msg into timeouts list |
217 | /** Insert sort timeout msg into timeouts list |
218 | * |
218 | * |
219 | * Assume async_futex is held |
- | |
220 | */ |
219 | */ |
221 | static void insert_timeout(awaiter_t *wd) |
220 | static void insert_timeout(awaiter_t *wd) |
222 | { |
221 | { |
223 | link_t *tmp; |
222 | link_t *tmp; |
224 | awaiter_t *cur; |
223 | awaiter_t *cur; |
Line 281... | Line 280... | ||
281 | /** Return new incoming message for current(thread-local) connection */ |
280 | /** Return new incoming message for current(thread-local) connection */ |
282 | ipc_callid_t async_get_call_timeout(ipc_call_t *call, suseconds_t usecs) |
281 | ipc_callid_t async_get_call_timeout(ipc_call_t *call, suseconds_t usecs) |
283 | { |
282 | { |
284 | msg_t *msg; |
283 | msg_t *msg; |
285 | ipc_callid_t callid; |
284 | ipc_callid_t callid; |
- | 285 | connection_t *conn; |
|
286 | 286 | ||
287 | assert(PS_connection); |
287 | assert(PS_connection); |
- | 288 | /* GCC 4.1.0 coughs on PS_connection-> dereference, |
|
- | 289 | * GCC 4.1.1 happilly puts the rdhwr instruction in delay slot. |
|
- | 290 | * I would never expect to find so many errors in |
|
- | 291 | * compiler *($&$(*&$ |
|
- | 292 | */ |
|
- | 293 | conn = PS_connection; |
|
288 | 294 | ||
289 | if (usecs < 0) /* TODO: let it get through the ipc_call once */ |
295 | if (usecs < 0) /* TODO: let it get through the ipc_call once */ |
290 | return 0; |
296 | return 0; |
291 | 297 | ||
292 | futex_down(&async_futex); |
298 | futex_down(&async_futex); |
293 | 299 | ||
294 | if (usecs) { |
300 | if (usecs) { |
295 | gettimeofday(&PS_connection->wdata.expires, NULL); |
301 | gettimeofday(&conn->wdata.expires, NULL); |
296 | tv_add(&PS_connection->wdata.expires, usecs); |
302 | tv_add(&conn->wdata.expires, usecs); |
297 | } else { |
303 | } else { |
298 | PS_connection->wdata.inlist = 0; |
304 | conn->wdata.inlist = 0; |
299 | } |
305 | } |
300 | /* If nothing in queue, wait until something appears */ |
306 | /* If nothing in queue, wait until something appears */ |
301 | while (list_empty(&PS_connection->msg_queue)) { |
307 | while (list_empty(&conn->msg_queue)) { |
302 | if (usecs) { |
308 | if (usecs) { |
303 | PS_connection->wdata.inlist = 1; |
309 | conn->wdata.inlist = 1; |
304 | insert_timeout(&PS_connection->wdata); |
310 | insert_timeout(&conn->wdata); |
305 | } |
311 | } |
306 | PS_connection->wdata.active = 0; |
312 | conn->wdata.active = 0; |
307 | psthread_schedule_next_adv(PS_TO_MANAGER); |
313 | psthread_schedule_next_adv(PS_TO_MANAGER); |
308 | /* Futex is up after getting back from async_manager |
314 | /* Futex is up after getting back from async_manager |
309 | * get it again */ |
315 | * get it again */ |
310 | futex_down(&async_futex); |
316 | futex_down(&async_futex); |
311 | if (usecs && PS_connection->wdata.timedout && \ |
317 | if (usecs && conn->wdata.timedout && \ |
312 | list_empty(&PS_connection->msg_queue)) { |
318 | list_empty(&conn->msg_queue)) { |
313 | /* If we timed out-> exit */ |
319 | /* If we timed out-> exit */ |
314 | futex_up(&async_futex); |
320 | futex_up(&async_futex); |
315 | return 0; |
321 | return 0; |
316 | } |
322 | } |
317 | } |
323 | } |
318 | 324 | ||
319 | msg = list_get_instance(PS_connection->msg_queue.next, msg_t, link); |
325 | msg = list_get_instance(conn->msg_queue.next, msg_t, link); |
320 | list_remove(&msg->link); |
326 | list_remove(&msg->link); |
321 | callid = msg->callid; |
327 | callid = msg->callid; |
322 | *call = msg->call; |
328 | *call = msg->call; |
323 | free(msg); |
329 | free(msg); |
324 | 330 | ||
Line 448... | Line 454... | ||
448 | 454 | ||
449 | /* Unknown call from unknown phone - hang it up */ |
455 | /* Unknown call from unknown phone - hang it up */ |
450 | ipc_answer_fast(callid, EHANGUP, 0, 0); |
456 | ipc_answer_fast(callid, EHANGUP, 0, 0); |
451 | } |
457 | } |
452 | 458 | ||
453 | /** Fire all timeouts that expired */ |
459 | /** Fire all timeouts that expired |
- | 460 | * |
|
- | 461 | */ |
|
454 | static void handle_expired_timeouts(void) |
462 | static void handle_expired_timeouts(void) |
455 | { |
463 | { |
456 | struct timeval tv; |
464 | struct timeval tv; |
457 | awaiter_t *waiter; |
465 | awaiter_t *waiter; |
458 | link_t *cur; |
466 | link_t *cur; |
Line 500... | Line 508... | ||
500 | futex_down(&async_futex); |
508 | futex_down(&async_futex); |
501 | if (!list_empty(&timeout_list)) { |
509 | if (!list_empty(&timeout_list)) { |
502 | waiter = list_get_instance(timeout_list.next,awaiter_t,link); |
510 | waiter = list_get_instance(timeout_list.next,awaiter_t,link); |
503 | gettimeofday(&tv,NULL); |
511 | gettimeofday(&tv,NULL); |
504 | if (tv_gteq(&tv, &waiter->expires)) { |
512 | if (tv_gteq(&tv, &waiter->expires)) { |
- | 513 | futex_up(&async_futex); |
|
505 | handle_expired_timeouts(); |
514 | handle_expired_timeouts(); |
506 | continue; |
515 | continue; |
507 | } else |
516 | } else |
508 | timeout = tv_sub(&waiter->expires, &tv); |
517 | timeout = tv_sub(&waiter->expires, &tv); |
509 | } else |
518 | } else |