]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix ast_app_dtget() time unit inconsistency.
authorRichard Mudgett <rmudgett@digium.com>
Sat, 21 Jan 2012 00:21:44 +0000 (00:21 +0000)
committerRichard Mudgett <rmudgett@digium.com>
Sat, 21 Jan 2012 00:21:44 +0000 (00:21 +0000)
Note: Noone calls ast_app_dtget() with the timeout parameter of zero so
the bad code normally will never get executed.

* Fix unnecessary floating point division in func_timeout.c
timeout_write() when all other values are integers.

(closes issue ASTERISK-16817)
Reported by: Dmitry Andrianov
........

Merged revisions 352029 from http://svn.asterisk.org/svn/asterisk/branches/1.8

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/10@352035 65c4cc65-6c06-0410-ace0-fbb531ad65f3

funcs/func_timeout.c
main/app.c

index 53bbab753139ccc328cff0155f00199eab088bfd..d15e28f8dc3fadf17f26d7681edbc94b8c73ddec 100644 (file)
@@ -171,7 +171,7 @@ static int timeout_write(struct ast_channel *chan, const char *cmd, char *data,
        case 'r':
        case 'R':
                if (chan->pbx) {
-                       chan->pbx->rtimeoutms = when.tv_sec * 1000 + when.tv_usec / 1000.0;
+                       chan->pbx->rtimeoutms = when.tv_sec * 1000 + when.tv_usec / 1000;
                        ast_verb(3, "Response timeout set to %.3f\n", chan->pbx->rtimeoutms / 1000.0);
                }
                break;
@@ -179,7 +179,7 @@ static int timeout_write(struct ast_channel *chan, const char *cmd, char *data,
        case 'd':
        case 'D':
                if (chan->pbx) {
-                       chan->pbx->dtimeoutms = when.tv_sec * 1000 + when.tv_usec / 1000.0;
+                       chan->pbx->dtimeoutms = when.tv_sec * 1000 + when.tv_usec / 1000;
                        ast_verb(3, "Digit timeout set to %.3f\n", chan->pbx->dtimeoutms / 1000.0);
                }
                break;
index 3e3cf5614240a720025bf222a6c412f1f5f639d5..c6a176e650d1c38e52b37decbfc4c47c4f4303c8 100644 (file)
@@ -108,7 +108,7 @@ static AST_RWLIST_HEAD_STATIC(groups, ast_group_info);
  * \param collect
  * \param size
  * \param maxlen
- * \param timeout timeout in seconds
+ * \param timeout timeout in milliseconds
  *
  * \return 0 if extension does not exist, 1 if extension exists
 */
@@ -121,10 +121,12 @@ int ast_app_dtget(struct ast_channel *chan, const char *context, char *collect,
                maxlen = size;
        }
 
-       if (!timeout && chan->pbx) {
-               timeout = chan->pbx->dtimeoutms / 1000.0;
-       } else if (!timeout) {
-               timeout = 5;
+       if (!timeout) {
+               if (chan->pbx && chan->pbx->dtimeoutms) {
+                       timeout = chan->pbx->dtimeoutms;
+               } else {
+                       timeout = 5000;
+               }
        }
 
        if ((ts = ast_get_indication_tone(chan->zone, "dial"))) {