diff options
author | unknown <brian@zim.(none)> | 2006-06-15 15:08:58 -0700 |
---|---|---|
committer | unknown <brian@zim.(none)> | 2006-06-15 15:08:58 -0700 |
commit | 382ec3e2b2c7a9c950aba9cc8d1ec3ae9cb4ac59 (patch) | |
tree | c658e7bdf7b913176ff1e4c8251142a09b1159d5 /client | |
parent | 705c73b6982410105a70547e9c6886c7c85872a7 (diff) | |
parent | e605df8c99a705b08c78268639277b4f5965bfd0 (diff) | |
download | mariadb-git-382ec3e2b2c7a9c950aba9cc8d1ec3ae9cb4ac59.tar.gz |
Merge baker@bk-internal.mysql.com:/home/bk/mysql-5.1-new-maint
into zim.(none):/home/brian/mysql/cleanup-5.1
BitKeeper/deleted/.del-partition_innodb.result:
Delete: mysql-test/r/partition_innodb.result
BitKeeper/deleted/.del-partition_innodb.test:
Delete: mysql-test/t/partition_innodb.test
include/config-win.h:
Auto merged
mysql-test/r/create.result:
Auto merged
mysql-test/r/partition.result:
Auto merged
mysql-test/t/create.test:
Auto merged
mysql-test/t/partition.test:
Auto merged
Diffstat (limited to 'client')
-rw-r--r-- | client/mysql.cc | 1 | ||||
-rw-r--r-- | client/mysqlimport.c | 45 |
2 files changed, 26 insertions, 20 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index 96df1fafc3b..ab1f4bdc8c5 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -852,6 +852,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case OPT_NOPAGER: printf("WARNING: option deprecated; use --disable-pager instead.\n"); opt_nopager= 1; + break; case OPT_MYSQL_PROTOCOL: { if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0) diff --git a/client/mysqlimport.c b/client/mysqlimport.c index ccd6932e25b..18a31117c08 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -35,9 +35,10 @@ /* Global Thread counter */ -int counter= 0; +int counter; #ifdef HAVE_LIBPTHREAD pthread_mutex_t counter_mutex; +pthread_cond_t count_threshhold; #endif static void db_error_with_table(MYSQL *mysql, char *table); @@ -556,6 +557,7 @@ error: pthread_mutex_lock(&counter_mutex); counter--; + pthread_cond_signal(&count_threshhold); pthread_mutex_unlock(&counter_mutex); my_thread_end(); @@ -584,28 +586,26 @@ int main(int argc, char **argv) { pthread_t mainthread; /* Thread descriptor */ pthread_attr_t attr; /* Thread attributes */ + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, + PTHREAD_CREATE_DETACHED); + VOID(pthread_mutex_init(&counter_mutex, NULL)); + VOID(pthread_cond_init(&count_threshhold, NULL)); - for (; *argv != NULL; argv++) /* Loop through tables */ + for (counter= 0; *argv != NULL; argv++) /* Loop through tables */ { - /* - If we hit thread count limit we loop until some threads exit. - We sleep for a second, so that we don't chew up a lot of - CPU in the loop. - */ -sanity_label: - if (counter == opt_use_threads) + pthread_mutex_lock(&counter_mutex); + while (counter == opt_use_threads) { - sleep(1); - goto sanity_label; + struct timespec abstime; + + set_timespec(abstime, 3); + pthread_cond_timedwait(&count_threshhold, &counter_mutex, &abstime); } - pthread_mutex_lock(&counter_mutex); + /* Before exiting the lock we set ourselves up for the next thread */ counter++; pthread_mutex_unlock(&counter_mutex); - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, - PTHREAD_CREATE_DETACHED); - /* now create the thread */ if (pthread_create(&mainthread, &attr, worker_thread, (void *)*argv) != 0) @@ -621,13 +621,18 @@ sanity_label: /* We loop until we know that all children have cleaned up. */ -loop_label: - if (counter) + pthread_mutex_lock(&counter_mutex); + while (counter) { - sleep(1); - goto loop_label; + struct timespec abstime; + + set_timespec(abstime, 3); + pthread_cond_timedwait(&count_threshhold, &counter_mutex, &abstime); } + pthread_mutex_unlock(&counter_mutex); VOID(pthread_mutex_destroy(&counter_mutex)); + VOID(pthread_cond_destroy(&count_threshhold)); + pthread_attr_destroy(&attr); } else #endif |