Fork us on GitHub Follow us on Facebook Follow us on Twitter

Opened 6 years ago

Closed 5 years ago

#556 closed defect (fixed)

fibril_timer semantics are flawed

Reported by: Jiri Svoboda Owned by: Jiri Svoboda
Priority: major Milestone: 0.6.0
Component: helenos/lib/c Version: mainline
Keywords: Cc:
Blocker for: Depends on:
See also: #557, #558

Description

Fibril timer does not hold the timer lock while the callback is executed. That means there is no guarantee after return from fibril_timer_clear() that the callback has been either cancelled or has run to completion. It could happen that the callback is still running after we return from fibril_timer_clear(). That makes the return value of fibril_timer_clear() worthless.

fibril_timer is currently used for TCP retransmissions.

Change History (4)

comment:1 Changed 6 years ago by Jiri Svoboda

Component: helenos/unspecifiedhelenos/lib/c
See also: #557, #558

comment:2 Changed 5 years ago by Jiri Svoboda

The difficult part is that we still want to be able to set the timer again, either from the timer callback function, or from outside of it. So, as an example, just holding the timer mutex while the callback is running would lead to a deadlock, since fibril_timer_set() needs to grab the mutex aswell. One possible solution would be to have a fibril_timer_set_unlocked(), but that would be really really ugly.

comment:3 Changed 5 years ago by Jiri Svoboda

For an extra challenge, TCP may attempt to destroy a timer inside its handler function. That means fibril_timer_destroy() must not wait for the timer fibril to terminate.

comment:4 Changed 5 years ago by Jiri Svoboda

Resolution: fixed
Status: newclosed

Fixed in mainline,2136. It is still possible to set the timer from the timer handler function.

Note: See TracTickets for help on using tickets.