Commit 64ae6d4a authored by Bjorn Munch's avatar Bjorn Munch

Bug #55426 mysqltest crashes when trying to unlock not acquired mutex

Bug #55546 mysqltest fails to create a new thread on HPUX
Missing call to pthread_join(), in embedded mode
This independently solves both problems, see 55426 for details.
Addendum: cannot test against a pthread_t, adds boolean flag instead
parent 4937eec1
...@@ -242,7 +242,9 @@ struct st_connection ...@@ -242,7 +242,9 @@ struct st_connection
int cur_query_len; int cur_query_len;
pthread_mutex_t mutex; pthread_mutex_t mutex;
pthread_cond_t cond; pthread_cond_t cond;
pthread_t tid;
int query_done; int query_done;
my_bool has_thread;
#endif /*EMBEDDED_LIBRARY*/ #endif /*EMBEDDED_LIBRARY*/
}; };
...@@ -733,8 +735,6 @@ pthread_handler_t send_one_query(void *arg) ...@@ -733,8 +735,6 @@ pthread_handler_t send_one_query(void *arg)
static int do_send_query(struct st_connection *cn, const char *q, int q_len, static int do_send_query(struct st_connection *cn, const char *q, int q_len,
int flags) int flags)
{ {
pthread_t tid;
if (flags & QUERY_REAP_FLAG) if (flags & QUERY_REAP_FLAG)
return mysql_send_query(&cn->mysql, q, q_len); return mysql_send_query(&cn->mysql, q, q_len);
...@@ -745,9 +745,10 @@ static int do_send_query(struct st_connection *cn, const char *q, int q_len, ...@@ -745,9 +745,10 @@ static int do_send_query(struct st_connection *cn, const char *q, int q_len,
cn->cur_query= q; cn->cur_query= q;
cn->cur_query_len= q_len; cn->cur_query_len= q_len;
cn->query_done= 0; cn->query_done= 0;
if (pthread_create(&tid, &cn_thd_attrib, send_one_query, (void*)cn)) if (pthread_create(&cn->tid, &cn_thd_attrib, send_one_query, (void*)cn))
die("Cannot start new thread for query"); die("Cannot start new thread for query");
cn->has_thread= TRUE;
return 0; return 0;
} }
...@@ -760,6 +761,11 @@ static void wait_query_thread_end(struct st_connection *con) ...@@ -760,6 +761,11 @@ static void wait_query_thread_end(struct st_connection *con)
pthread_cond_wait(&con->cond, &con->mutex); pthread_cond_wait(&con->cond, &con->mutex);
pthread_mutex_unlock(&con->mutex); pthread_mutex_unlock(&con->mutex);
} }
if (con->has_thread)
{
pthread_join(con->tid, NULL);
con->has_thread= FALSE;
}
} }
#else /*EMBEDDED_LIBRARY*/ #else /*EMBEDDED_LIBRARY*/
...@@ -5187,6 +5193,7 @@ void do_connect(struct st_command *command) ...@@ -5187,6 +5193,7 @@ void do_connect(struct st_command *command)
#ifdef EMBEDDED_LIBRARY #ifdef EMBEDDED_LIBRARY
con_slot->query_done= 1; con_slot->query_done= 1;
con_slot->has_thread= FALSE;
#endif #endif
if (!mysql_init(&con_slot->mysql)) if (!mysql_init(&con_slot->mysql))
die("Failed on mysql_init()"); die("Failed on mysql_init()");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment