Skip to content

Commit 1adf9ce

Browse files
author
Arun Kuruvila
committed
Merge branch 'mysql-5.5' into mysql-5.6
2 parents 802b76a + 96d9025 commit 1adf9ce

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

client/mysqlimport.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
/* Global Thread counter */
3333
uint counter;
34+
pthread_mutex_t init_mutex;
3435
pthread_mutex_t counter_mutex;
3536
pthread_cond_t count_threshhold;
3637

@@ -425,8 +426,13 @@ static MYSQL *db_connect(char *host, char *database,
425426
MYSQL *mysql;
426427
if (verbose)
427428
fprintf(stdout, "Connecting to %s\n", host ? host : "localhost");
429+
pthread_mutex_lock(&init_mutex);
428430
if (!(mysql= mysql_init(NULL)))
431+
{
432+
pthread_mutex_unlock(&init_mutex);
429433
return 0;
434+
}
435+
pthread_mutex_unlock(&init_mutex);
430436
if (opt_compress)
431437
mysql_options(mysql,MYSQL_OPT_COMPRESS,NullS);
432438
if (opt_local_file)
@@ -645,6 +651,7 @@ int main(int argc, char **argv)
645651
pthread_attr_setdetachstate(&attr,
646652
PTHREAD_CREATE_JOINABLE);
647653

654+
pthread_mutex_init(&init_mutex, NULL);
648655
pthread_mutex_init(&counter_mutex, NULL);
649656
pthread_cond_init(&count_threshhold, NULL);
650657

@@ -699,6 +706,7 @@ int main(int argc, char **argv)
699706
pthread_cond_timedwait(&count_threshhold, &counter_mutex, &abstime);
700707
}
701708
pthread_mutex_unlock(&counter_mutex);
709+
pthread_mutex_destroy(&init_mutex);
702710
pthread_mutex_destroy(&counter_mutex);
703711
pthread_cond_destroy(&count_threshhold);
704712
pthread_attr_destroy(&attr);

0 commit comments

Comments
 (0)