[Home]

Summary:ASTERISK-13776: race condition in res/timing_* interfaces
Reporter:Moises Silva (moy)Labels:
Date Opened:2009-03-18 23:12:52Date Closed:2009-03-27 14:21:35
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Resources/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) timing.txt
Description:While doing some testing with trunk it seems I hit a race condition where ast_timer_open() is being called and handled by the DAHDI timing interface, but then before ast_timer_ack gets called, another timing interface gets registered and when ast_timer_ack gets called the timerfd interface handles the call and the file descriptor is therefore not valid for that module (in this case the resulting error is invalid argument.

****** STEPS TO REPRODUCE ******

In my scenario pthread, dahdi and timerfd interfaces were being loaded. I added a few error messages to track the problem. I am attaching the log.

You can see the messages:

timing.c:68 _ast_register_timing_interface: calling ast_register_timing_interface.
timing.c:89 _ast_register_timing_interface: Registering interface 'DAHDI'
timing.c:117 ast_timer_open: calling ast_timer_open.
timing.c:125 ast_timer_open: Used the 'DAHDI' timing module to open the timer 10.
timing.c:68 _ast_register_timing_interface: calling ast_register_timing_interface.
timing.c:89 _ast_register_timing_interface: Registering interface 'timerfd'.
timing.c:171 ast_timer_ack: Doing timer ack using interface 'timerfd' in fd 10.
[Mar 18 23:29:21] ERROR[11908]: timing.c:171 ast_timer_ack: Doing timer ack using interface 'timerfd' in fd 10.
[Mar 18 23:29:21] ERROR[11908]: res_timing_timerfd.c:189 timerfd_timer_ack: Read error on handle 10: Invalid argument

Comments:By: Kevin P. Fleming (kpfleming) 2009-03-26 18:21:15

Actually, there are even worse problems here than what you've noted... I'm working on a solution, stay tuned.

By: Digium Subversion (svnbot) 2009-03-27 14:10:33

Repository: asterisk
Revision: 184762

U   trunk/bridges/bridge_softmix.c
U   trunk/channels/chan_iax2.c
U   trunk/include/asterisk/channel.h
U   trunk/include/asterisk/timing.h
U   trunk/main/channel.c
U   trunk/main/timing.c

------------------------------------------------------------------------
r184762 | kpfleming | 2009-03-27 14:10:32 -0500 (Fri, 27 Mar 2009) | 12 lines

Improve timing interface to remember which provider provided a timer

The ability to load/unload timing interfaces is nice, but it means that when a timer is allocated, it may come from provider A, but later provider B becomes the 'preferred' provider. If this happens, all timer API calls on the timer that was provided by provider A will actually be handed to provider B, which will say WTF and return an error.

This patch changes the timer API to include a pointer to the provider of the timer handle so that future operations on the timer will be forwarded to the proper provider.

(closes issue ASTERISK-13776)
Reported by: moy

Review: http://reviewboard.digium.com/r/211/


------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=184762

By: Digium Subversion (svnbot) 2009-03-27 14:11:29

Repository: asterisk
Revision: 184763

_U  branches/1.6.0/

------------------------------------------------------------------------
r184763 | kpfleming | 2009-03-27 14:11:29 -0500 (Fri, 27 Mar 2009) | 17 lines

Blocked revisions 184762 via svnmerge

........
 r184762 | kpfleming | 2009-03-27 14:10:32 -0500 (Fri, 27 Mar 2009) | 12 lines
 
 Improve timing interface to remember which provider provided a timer
 
 The ability to load/unload timing interfaces is nice, but it means that when a timer is allocated, it may come from provider A, but later provider B becomes the 'preferred' provider. If this happens, all timer API calls on the timer that was provided by provider A will actually be handed to provider B, which will say WTF and return an error.
 
 This patch changes the timer API to include a pointer to the provider of the timer handle so that future operations on the timer will be forwarded to the proper provider.
 
 (closes issue ASTERISK-13776)
 Reported by: moy
 
 Review: http://reviewboard.digium.com/r/211/
........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=184763

By: Digium Subversion (svnbot) 2009-03-27 14:17:24

Repository: asterisk
Revision: 184765

_U  branches/1.6.1/
U   branches/1.6.1/channels/chan_iax2.c
U   branches/1.6.1/include/asterisk/channel.h
U   branches/1.6.1/include/asterisk/timing.h
U   branches/1.6.1/main/channel.c
U   branches/1.6.1/main/timing.c

------------------------------------------------------------------------
r184765 | kpfleming | 2009-03-27 14:17:24 -0500 (Fri, 27 Mar 2009) | 18 lines

Merged revisions 184762 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

........
 r184762 | kpfleming | 2009-03-27 14:10:32 -0500 (Fri, 27 Mar 2009) | 12 lines
 
 Improve timing interface to remember which provider provided a timer
 
 The ability to load/unload timing interfaces is nice, but it means that when a timer is allocated, it may come from provider A, but later provider B becomes the 'preferred' provider. If this happens, all timer API calls on the timer that was provided by provider A will actually be handed to provider B, which will say WTF and return an error.
 
 This patch changes the timer API to include a pointer to the provider of the timer handle so that future operations on the timer will be forwarded to the proper provider.
 
 (closes issue ASTERISK-13776)
 Reported by: moy
 
 Review: http://reviewboard.digium.com/r/211/
........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=184765

By: Digium Subversion (svnbot) 2009-03-27 14:21:34

Repository: asterisk
Revision: 184779

_U  branches/1.6.2/
U   branches/1.6.2/bridges/bridge_softmix.c
U   branches/1.6.2/channels/chan_iax2.c
U   branches/1.6.2/include/asterisk/channel.h
U   branches/1.6.2/include/asterisk/timing.h
U   branches/1.6.2/main/channel.c
U   branches/1.6.2/main/timing.c

------------------------------------------------------------------------
r184779 | kpfleming | 2009-03-27 14:21:34 -0500 (Fri, 27 Mar 2009) | 18 lines

Merged revisions 184762 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

........
 r184762 | kpfleming | 2009-03-27 14:10:32 -0500 (Fri, 27 Mar 2009) | 12 lines
 
 Improve timing interface to remember which provider provided a timer
 
 The ability to load/unload timing interfaces is nice, but it means that when a timer is allocated, it may come from provider A, but later provider B becomes the 'preferred' provider. If this happens, all timer API calls on the timer that was provided by provider A will actually be handed to provider B, which will say WTF and return an error.
 
 This patch changes the timer API to include a pointer to the provider of the timer handle so that future operations on the timer will be forwarded to the proper provider.
 
 (closes issue ASTERISK-13776)
 Reported by: moy
 
 Review: http://reviewboard.digium.com/r/211/
........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=184779