summaryrefslogtreecommitdiff
path: root/sql-common
diff options
context:
space:
mode:
authorunknown <knielsen@knielsen-hq.org>2012-10-12 10:54:46 +0200
committerunknown <knielsen@knielsen-hq.org>2012-10-12 10:54:46 +0200
commitfc941f8a2143ce7670f49c2638f352c16f4b9ddb (patch)
tree34dbc9fba4d7889db3d6b12ebb2d251326bced9f /sql-common
parent8215ce4695e743d313e92f4d30f412f79958439c (diff)
downloadmariadb-git-fc941f8a2143ce7670f49c2638f352c16f4b9ddb.tar.gz
MDEV-3802. Millisecond timeout support in non-blocking client library.
In 10.0, VIO timeouts can be in milliseconds, so we add a new function mysql_get_timeout_value_ms() which can return millisecond-precision timeout values. In 5.5, we do not have millisecond precision for timeouts. But we still provide the mysql_get_timeout_value_ms() function; this makes it easier for applications as they can use the millisecond function in 10.0 and still work with the 5.5 version of the client library.
Diffstat (limited to 'sql-common')
-rw-r--r--sql-common/mysql_async.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/sql-common/mysql_async.c b/sql-common/mysql_async.c
index c130eab5061..c7e720076ea 100644
--- a/sql-common/mysql_async.c
+++ b/sql-common/mysql_async.c
@@ -247,6 +247,28 @@ mysql_get_timeout_value(const MYSQL *mysql)
/*
+ In 10.0, VIO timeouts are in milliseconds, so we support getting the
+ millisecond timeout value from async applications.
+
+ In 5.5, timeouts are always in seconds, but we support the 10.0 version
+ that provides milliseconds, so applications can work with either version
+ of the library easily.
+
+ When merging this to 10.0, this function must be removed and the 10.0
+ version used.
+*/
+unsigned int STDCALL
+mysql_get_timeout_value_ms(const MYSQL *mysql)
+{
+ unsigned int timeout= mysql->options.extension->async_context->timeout_value;
+ if (timeout <= UINT_MAX / 1000)
+ return timeout*1000;
+ else
+ return UINT_MAX;
+}
+
+
+/*
Now create non-blocking definitions for all the calls that may block.
Each call FOO gives rise to FOO_start() that prepares the MYSQL object for