summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2011-11-30 22:57:18 +0200
committerMichael Widenius <monty@askmonty.org>2011-11-30 22:57:18 +0200
commitefcfb195e3fc4a2b87bfcb9ad136d46b9961f49e (patch)
tree9eb3b78e20ecf4bd9e5cd587db50d51c1f06d336 /client
parenta7f87effa57f6486c23bf5b340c8474a635dcf71 (diff)
parent6378bdbf47af72b2f899853586faa5a2d2f0fee1 (diff)
downloadmariadb-git-efcfb195e3fc4a2b87bfcb9ad136d46b9961f49e.tar.gz
Merge with 5.1
Diffstat (limited to 'client')
-rw-r--r--client/mysqltest.cc21
1 files changed, 18 insertions, 3 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 6a3b75f2410..cf1b81d6169 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -264,7 +264,7 @@ struct st_connection
pthread_cond_t cond;
pthread_t tid;
int query_done;
- my_bool has_thread;
+ my_bool has_thread, mutex_inited;
#endif /*EMBEDDED_LIBRARY*/
};
@@ -782,10 +782,12 @@ static int do_send_query(struct st_connection *cn, const char *q, int q_len,
if (flags & QUERY_REAP_FLAG)
return mysql_send_query(cn->mysql, q, q_len);
- if (pthread_mutex_init(&cn->mutex, NULL) ||
- pthread_cond_init(&cn->cond, NULL))
+ if (!cn->mutex_inited &&
+ (pthread_mutex_init(&cn->mutex, NULL) ||
+ pthread_cond_init(&cn->cond, NULL)))
die("Error in the thread library");
+ cn->mutex_inited= 1;
cn->cur_query= q;
cn->cur_query_len= q_len;
cn->query_done= 0;
@@ -815,9 +817,20 @@ static void wait_query_thread_end(struct st_connection *con)
}
}
+static void free_embedded_data(struct st_connection *con)
+{
+ if (con->mutex_inited)
+ {
+ con->mutex_inited= 0;
+ pthread_mutex_destroy(&con->mutex);
+ pthread_cond_destroy(&con->cond);
+ }
+}
+
#else /*EMBEDDED_LIBRARY*/
#define do_send_query(cn,q,q_len,flags) mysql_send_query(cn->mysql, q, q_len)
+#define free_embedded_data(next_con) do { } while(0)
#endif /*EMBEDDED_LIBRARY*/
@@ -1171,6 +1184,7 @@ void close_connections()
if (next_con->util_mysql)
mysql_close(next_con->util_mysql);
my_free(next_con->name, MYF(MY_ALLOW_ZERO_PTR));
+ free_embedded_data(next_con);
}
my_free(connections, MYF(MY_WME));
DBUG_VOID_RETURN;
@@ -5001,6 +5015,7 @@ void do_close_connection(struct st_command *command)
mysql_close(con->mysql);
con->mysql= 0;
+ free_embedded_data(con);
if (con->util_mysql)
mysql_close(con->util_mysql);