summaryrefslogtreecommitdiff
path: root/tests/async_queries.c
diff options
context:
space:
mode:
authorunknown <knielsen@knielsen-hq.org>2012-01-06 12:43:18 +0100
committerunknown <knielsen@knielsen-hq.org>2012-01-06 12:43:18 +0100
commit17940b652d0a078f5a28b089aa0f5362756d438e (patch)
tree0c198251f33fd1b19ae2bb443a732496a3bf5ee3 /tests/async_queries.c
parenta5b881594da4258257b18cc42f5ce7be3524e02c (diff)
downloadmariadb-git-17940b652d0a078f5a28b089aa0f5362756d438e.tar.gz
MWL#192: non-blocking client API, after-review fixes.
Main change is that non-blocking operation is now an option that must be explicitly enabled with mysql_option(mysql, MYSQL_OPT_NONBLOCK, ...) before any non-blocing operation can be used. Also the CLIENT_REMEMBER_OPTIONS flag is now always enabled and thus effectively ignored (it was not really useful anyway, and this simplifies things when non-blocking mysql_real_connect() fails).
Diffstat (limited to 'tests/async_queries.c')
-rw-r--r--tests/async_queries.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/tests/async_queries.c b/tests/async_queries.c
index 677208f11f5..0f9b39e1938 100644
--- a/tests/async_queries.c
+++ b/tests/async_queries.c
@@ -1,17 +1,15 @@
/*
Copyright 2011 Kristian Nielsen and Monty Program Ab.
- Experiments with non-blocking libmysql.
+ This file is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
- This is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- This is distributed in the hope that it will be useful,
+ This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
You should have received a copy of the GNU General Public License
along with this. If not, see <http://www.gnu.org/licenses/>.
@@ -93,7 +91,7 @@ static struct my_option options[] =
&opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"connections", 'n', "Number of simultaneous connections/queries.",
&opt_connections, &opt_connections, 0, GET_UINT, REQUIRED_ARG,
- 0, 0, 0, 0, 0, 0},
+ 5, 0, 0, 0, 0, 0},
{"queryfile", 'q', "Name of file containing extra queries to run",
&opt_query_file, &opt_query_file, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
@@ -219,8 +217,8 @@ again:
break;
case 20:
- free(sd->query_element->query);
- free(sd->query_element);
+ my_free(sd->query_element->query, MYF(0));
+ my_free(sd->query_element, MYF(0));
if (sd->err)
{
printf("%d | Error: %s\n", sd->index, mysql_error(&sd->mysql));
@@ -315,8 +313,8 @@ add_query(const char *q)
char *q2;
size_t len;
- e= malloc(sizeof(*e));
- q2= strdup(q);
+ e= my_malloc(sizeof(*e), MYF(0));
+ q2= my_strdup(q, MYF(0));
if (!e || !q2)
fatal(NULL, "Out of memory");
@@ -395,7 +393,7 @@ main(int argc, char *argv[])
add_query(*argv++);
}
- sds= malloc(opt_connections * sizeof(*sds));
+ sds= my_malloc(opt_connections * sizeof(*sds), MYF(0));
if (!sds)
fatal(NULL, "Out of memory");
@@ -412,6 +410,7 @@ main(int argc, char *argv[])
for (i= 0; i < opt_connections; i++)
{
mysql_init(&sds[i].mysql);
+ mysql_options(&sds[i].mysql, MYSQL_OPT_NONBLOCK, 0);
mysql_options(&sds[i].mysql, MYSQL_READ_DEFAULT_GROUP, "async_queries");
/*