diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-03-27 19:17:22 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-03-27 19:17:22 +0000 |
commit | 55337ecaa6dcc942686c070d002c615cb6191dff (patch) | |
tree | e6d02b30d5e60fecf8037b37f51059e617698553 /include | |
parent | 4793ed0202690b9cb09e07b6149b2c2b64eee94e (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.1@184765 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk/channel.h | 8 | ||||
-rw-r--r-- | include/asterisk/timing.h | 66 |
2 files changed, 46 insertions, 28 deletions
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index b7bc66fa7..e4e8bfea7 100644 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -492,7 +492,13 @@ struct ast_channel { unsigned short transfercapability; /*!< ISDN Transfer Capbility - AST_FLAG_DIGITAL is not enough */ - char unused_old_dtmfq[AST_MAX_EXTENSION]; /*!< (deprecated, use readq instead) Any/all queued DTMF characters */ + union { + char unused_old_dtmfq[AST_MAX_EXTENSION]; /*!< (deprecated, use readq instead) Any/all queued DTMF characters */ + struct { + struct ast_timer *timer; /*!< timer object that provided timingfd */ + }; + }; + char context[AST_MAX_CONTEXT]; /*!< Dialplan: Current extension context */ char exten[AST_MAX_EXTENSION]; /*!< Dialplan: Current extension number */ char macrocontext[AST_MAX_CONTEXT]; /*!< Macro: Current non-macro context. See app_macro.c */ diff --git a/include/asterisk/timing.h b/include/asterisk/timing.h index c9a8fcba9..d93f4f408 100644 --- a/include/asterisk/timing.h +++ b/include/asterisk/timing.h @@ -93,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. @@ -107,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() @@ -154,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) } |