diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-03-27 19:21:33 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-03-27 19:21:33 +0000 |
commit | b710492a630fddfca8179a7ca99499a549d72508 (patch) | |
tree | 23da8666e0d6d6e5b6db991b229139971004bf72 /include | |
parent | df5064fc4522ceb0020255f2a722a98511f1d393 (diff) |
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 #14697)
Reported by: moy
Review: http://reviewboard.digium.com/r/211/
........
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@184779 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk/channel.h | 1 | ||||
-rw-r--r-- | include/asterisk/timing.h | 69 |
2 files changed, 40 insertions, 30 deletions
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index d601bb72c..1a0a6ec07 100644 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -496,6 +496,7 @@ struct ast_channel { char unused_old_dtmfq[AST_MAX_EXTENSION]; /*!< (deprecated, use readq instead) Any/all queued DTMF characters */ struct { struct ast_bridge *bridge; /*!< Bridge this channel is participating in */ + struct ast_timer *timer; /*!< timer object that provided timingfd */ }; }; diff --git a/include/asterisk/timing.h b/include/asterisk/timing.h index f10557e9d..d93f4f408 100644 --- a/include/asterisk/timing.h +++ b/include/asterisk/timing.h @@ -45,9 +45,6 @@ 4) Multiple 'event types', so that the code using the timer can know whether the wakeup it received was due to a periodic trigger or a continuous trigger. - - \todo Create an implementation of this API for Linux based on the - following API: http://www.kernel.org/doc/man-pages/online/pages/man2/timerfd_create.2.html */ #ifndef _ASTERISK_TIMING_H @@ -96,7 +93,7 @@ struct ast_timing_interface { */ #define ast_register_timing_interface(i) _ast_register_timing_interface(i, ast_module_info->self) void *_ast_register_timing_interface(struct ast_timing_interface *funcs, - struct ast_module *mod); + struct ast_module *mod); /*! * \brief Unregister a previously registered timing interface. @@ -110,45 +107,57 @@ void *_ast_register_timing_interface(struct ast_timing_interface *funcs, */ int ast_unregister_timing_interface(void *handle); +struct ast_timer; + /*! - * \brief Open a timing fd + * \brief Open a timer * - * \retval -1 error, with errno set - * \retval >=0 success + * \retval NULL on error, with errno set + * \retval non-NULL timer handle on success * \since 1.6.1 */ -int ast_timer_open(void); +struct ast_timer *ast_timer_open(void); /*! * \brief Close an opened timing handle * - * \param handle timing fd returned from timer_open() + * \param handle timer handle returned from timer_open() * * \return nothing * \since 1.6.1 */ -void ast_timer_close(int handle); +void ast_timer_close(struct ast_timer *handle); + +/*! + * \brief Get a poll()-able file descriptor for a timer + * + * \param handle timer handle returned from timer_open() + * + * \return file descriptor which can be used with poll() to wait for events + * \since 1.6.1 + */ +int ast_timer_fd(const struct ast_timer *handle); /*! * \brief Set the timing tick rate * - * \param handle timing fd returned from timer_open() + * \param handle timer handle returned from timer_open() * \param rate ticks per second, 0 turns the ticks off if needed * - * Use this function if you want the timing fd to show input at a certain - * rate. The other alternative use of a timing fd, is using the continuous + * Use this function if you want the timer to show input at a certain + * rate. The other alternative use of a timer is the continuous * mode. * * \retval -1 error, with errno set * \retval 0 success * \since 1.6.1 */ -int ast_timer_set_rate(int handle, unsigned int rate); +int ast_timer_set_rate(const struct ast_timer *handle, unsigned int rate); /*! * \brief Acknowledge a timer event * - * \param handle timing fd returned from timer_open() + * \param handle timer handle returned from timer_open() * \param quantity number of timer events to acknowledge * * \note This function should only be called if timer_get_event() @@ -157,55 +166,55 @@ int ast_timer_set_rate(int handle, unsigned int rate); * \return nothing * \since 1.6.1 */ -void ast_timer_ack(int handle, unsigned int quantity); +void ast_timer_ack(const struct ast_timer *handle, unsigned int quantity); /*! * \brief Enable continuous mode * - * \param handle timing fd returned from timer_open() + * \param handle timer handle returned from timer_open() * - * Continuous mode causes poll() on the timing fd to immediately return + * Continuous mode causes poll() on the timer's fd to immediately return * always until continuous mode is disabled. * * \retval -1 failure, with errno set * \retval 0 success * \since 1.6.1 */ -int ast_timer_enable_continuous(int handle); +int ast_timer_enable_continuous(const struct ast_timer *handle); /*! * \brief Disable continuous mode * - * \param handle timing fd returned from timer_close() + * \param handle timer handle returned from timer_close() * * \retval -1 failure, with errno set * \retval 0 success * \since 1.6.1 */ -int ast_timer_disable_continuous(int handle); +int ast_timer_disable_continuous(const struct ast_timer *handle); /*! - * \brief Determine timing event + * \brief Retrieve timing event * - * \param handle timing fd returned by timer_open() + * \param handle timer handle returned by timer_open() * - * After poll() indicates that there is input on the timing fd, this will + * After poll() indicates that there is input on the timer's fd, this will * be called to find out what triggered it. * - * \return which event triggered the timing fd + * \return which event triggered the timer * \since 1.6.1 */ -enum ast_timer_event ast_timer_get_event(int handle); +enum ast_timer_event ast_timer_get_event(const struct ast_timer *handle); /*! - * \brief Get maximum rate supported for a timing handle + * \brief Get maximum rate supported for a timer * - * \param handle timing fd returned by timer_open() + * \param handle timer handle returned by timer_open() * - * \return maximum rate supported for timing handle + * \return maximum rate supported by timer * \since 1.6.1 */ -unsigned int ast_timer_get_max_rate(int handle); +unsigned int ast_timer_get_max_rate(const struct ast_timer *handle); #if defined(__cplusplus) || defined(c_plusplus) } |