gvisor/pkg/tcpip
Ghanan Gowripalan d057871f41 CancellableTimer to encapsulate the work of safely stopping timers
Add a new CancellableTimer type to encapsulate the work of safely stopping
timers when it fires at the same time some "related work" is being handled. The
term "related work" is some work that needs to be done while having obtained
some common lock (L).

Example: Say we have an invalidation timer that may be extended or cancelled by
some event. Creating a normal timer and simply cancelling may not be sufficient
as the timer may have already fired when the event handler attemps to cancel it.
Even if the timer and event handler obtains L before doing work, once the event
handler releases L, the timer will eventually obtain L and do some unwanted
work.

To prevent the timer from doing unwanted work, it checks if it should early
return instead of doing the normal work after obtaining L. When stopping the
timer callers must have L locked so the timer can be safely informed that it
should early return.

Test: Tests that CancellableTimer fires and resets properly. Test to make sure
the timer fn is not called after being stopped within the lock L.
PiperOrigin-RevId: 288806984
2020-01-08 17:50:54 -08:00
..
adapters/gonet Add support for TIME_WAIT timeout. 2019-11-07 09:46:55 -08:00
buffer Use PacketBuffers for outgoing packets. 2019-11-14 10:15:38 -08:00
checker Automated rollback of changelist 287029703 2019-12-26 13:05:52 -08:00
hash/jenkins Cleanup visibility. 2019-11-23 23:54:41 -08:00
header Pass the NIC-internal name to the NIC name function when generating opaque IIDs 2020-01-06 16:21:31 -08:00
iptables Reorder BUILD license and load functions in netstack. 2019-10-14 15:21:59 -07:00
link Fix panic in sniffer. 2019-11-25 09:11:05 -08:00
network Remove redundant function argument 2020-01-08 10:22:51 -08:00
ports Add UDP SO_REUSEADDR support to the port manager. 2019-12-09 15:53:00 -08:00
sample Add additional packages to go branch 2019-12-11 14:22:36 -08:00
seqnum Cleanup visibility. 2019-11-23 23:54:41 -08:00
stack CancellableTimer to encapsulate the work of safely stopping timers 2020-01-08 17:50:54 -08:00
transport Introduce tcpip.SockOptBool 2020-01-08 15:40:48 -08:00
BUILD CancellableTimer to encapsulate the work of safely stopping timers 2020-01-08 17:50:54 -08:00
packet_buffer.go Use PacketBuffers with GSO. 2019-11-22 14:52:35 -08:00
packet_buffer_state.go Use PacketBuffers for outgoing packets. 2019-11-14 10:15:38 -08:00
tcpip.go Introduce tcpip.SockOptBool 2020-01-08 15:40:48 -08:00
tcpip_test.go Implement proper local broadcast behavior 2019-10-03 19:31:35 -07:00
time.s Change copyright notice to "The gVisor Authors" 2019-04-29 14:26:23 -07:00
time_unsafe.go Update build tags to allow Go 1.14 2019-10-29 13:18:16 -07:00
timer.go CancellableTimer to encapsulate the work of safely stopping timers 2020-01-08 17:50:54 -08:00
timer_test.go CancellableTimer to encapsulate the work of safely stopping timers 2020-01-08 17:50:54 -08:00