Below is the list of changes that have just been committed into a local
5.1 repository of sergeyv. When sergeyv does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2235 06/03/29 23:32:06 SergeyV@selena. +1 -0
Second iteration on mysqlslap locks. Redone to use semaphores,
instead of pthread_cond. opt_slave is not covered yet, since there
is no proper implementation of global (system wide) semaphores on win32.
client/mysqlslap.c
1.26 06/03/29 23:31:22 SergeyV@selena. +80 -42
Second iteration on mysqlslap locks. Redone to use semaphores,
instead of pthread_cond. opt_slave is not covered yet, since there
is no proper implementation of global (system wide) semaphores on win32.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: SergeyV
# Host: selena.
# Root: H:/MYSQL/src/$00002-mysql-5.1
--- 1.25/client/mysqlslap.c 2006-03-10 19:54:05 +03:00
+++ 1.26/client/mysqlslap.c 2006-03-29 23:31:22 +04:00
@@ -78,6 +78,7 @@
#include "client_priv.h"
#ifdef HAVE_LIBPTHREAD
#include <my_pthread.h>
+#include <my_semaphore.h>
#endif
#include <my_sys.h>
#include <m_string.h>
@@ -151,6 +152,11 @@
static const char *load_default_groups[]= { "mysqlslap","client",0 };
+#ifdef HAVE_LIBPTHREAD
+sem_t myslapsemtrd;
+sem_t myslapsemmon;
+#endif
+
typedef struct statement statement;
struct statement {
@@ -361,7 +367,6 @@
if (!opt_only_print)
mysql_close(&mysql); /* Close & free connection */
-
/* Remove lock file */
my_delete(lock_file_str, MYF(0));
@@ -979,22 +984,15 @@
con.limit= limit;
con.thread= opt_use_threads ? 1 :0;
- lock_file= my_open(lock_file_str, O_CREAT|O_WRONLY|O_TRUNC, MYF(0));
-
- if (!opt_slave)
- if (my_lock(lock_file, F_WRLCK, 0, F_TO_EOF, MYF(0)))
- {
- fprintf(stderr,"%s: Could not get lockfile\n",
- my_progname);
- exit(0);
- }
-
#ifdef HAVE_LIBPTHREAD
if (opt_use_threads)
{
- pthread_t mainthread; /* Thread descriptor */
+ pthread_t mainthread; /* Thread descriptor */
pthread_attr_t attr; /* Thread attributes */
+ sem_init(&myslapsemmon, 0, 0);
+ sem_init(&myslapsemtrd, 0, 0);
+
for (x= 0; x < concur; x++)
{
pthread_attr_init(&attr);
@@ -1010,6 +1008,10 @@
exit(0);
}
}
+
+ for (x= 0; x < concur; x++)
+ sem_wait(&myslapsemtrd);
+ sem_post_multiple(&myslapsemmon, concur);
}
#endif
#ifndef __WIN__
@@ -1017,6 +1019,16 @@
else
#endif
{
+ lock_file= my_open(lock_file_str, O_CREAT|O_WRONLY|O_TRUNC, MYF(0));
+
+ if (!opt_slave)
+ if (my_lock(lock_file, F_WRLCK, 0, F_TO_EOF, MYF(0)))
+ {
+ fprintf(stderr,"%s: Could not get lockfile\n",
+ my_progname);
+ exit(0);
+ }
+
fflush(NULL);
for (x= 0; x < concur; x++)
{
@@ -1054,31 +1066,26 @@
break;
}
}
+
+ /* Lets release use some clients! */
+ if (!opt_slave)
+ my_lock(lock_file, F_UNLCK, 0, F_TO_EOF, MYF(0));
}
#endif
- /* Lets release use some clients! */
- if (!opt_slave)
- my_lock(lock_file, F_UNLCK, 0, F_TO_EOF, MYF(0));
-
gettimeofday(&start_time, NULL);
- /*
- We look to grab a write lock at this point. Once we get it we know that
- all clients have completed their work.
- */
+#ifdef HAVE_LIBPTHREAD
if (opt_use_threads)
{
- if (my_lock(lock_file, F_WRLCK, 0, F_TO_EOF, MYF(0)))
- {
- fprintf(stderr,"%s: Could not get lockfile\n",
- my_progname);
- exit(0);
- }
- my_lock(lock_file, F_UNLCK, 0, F_TO_EOF, MYF(0));
+ for (x= 0; x < concur; x++)
+ sem_wait(&myslapsemtrd);
}
+#endif
#ifndef __WIN__
+#ifdef HAVE_LIBPTHREAD
else
+#endif
{
WAIT:
while (x--)
@@ -1090,11 +1097,12 @@
printf("%s: Child %d died with the status %d\n",
my_progname, pid, status);
}
+
+ my_close(lock_file, MYF(0));
}
#endif
- gettimeofday(&end_time, NULL);
- my_close(lock_file, MYF(0));
+ gettimeofday(&end_time, NULL);
sptr->timing= timedif(end_time, start_time);
sptr->users= concur;
@@ -1123,15 +1131,31 @@
goto end;
DBUG_PRINT("info", ("trying to connect to host %s as user %s", host, user));
- lock_file= my_open(lock_file_str, O_RDWR, MYF(0));
- my_lock(lock_file, F_RDLCK, 0, F_TO_EOF, MYF(0));
- if (!opt_only_print)
- {
- if (!(mysql= mysql_real_connect(mysql, host, user, opt_password,
- create_schema_string,
- opt_mysql_port,
+
+#ifdef HAVE_LIBPTHREAD
+ if (opt_use_threads)
+ {
+ sem_post(&myslapsemtrd);
+ sem_wait(&myslapsemmon);
+ }
+#endif
+#ifndef __WIN__
+#ifdef HAVE_LIBPTHREAD
+ else
+#endif
+ {
+ lock_file= my_open(lock_file_str, O_RDWR, MYF(0));
+ my_lock(lock_file, F_RDLCK, 0, F_TO_EOF, MYF(0));
+ }
+#endif
+
+ if (!opt_only_print)
+ {
+ if (!mysql_real_connect(mysql, host, user, opt_password,
+ create_schema_string,
+ opt_mysql_port,
opt_mysql_unix_port,
- 0)))
+ 0))
{
fprintf(stderr,"%s: %s\n",my_progname,mysql_error(mysql));
goto end;
@@ -1139,12 +1163,12 @@
}
DBUG_PRINT("info", ("connected."));
- queries= 0;
+ queries= 0;
limit_not_met:
for (ptr= con->stmt; ptr && ptr->length; ptr= ptr->next)
{
- if (opt_only_print)
+ if (opt_only_print)
{
printf("%.*s;\n", (uint)ptr->length, ptr->string);
}
@@ -1175,17 +1199,31 @@
end:
- if (lock_file != -1)
+#ifdef HAVE_LIBPTHREAD
+ if (opt_use_threads)
{
- my_lock(lock_file, F_UNLCK, 0, F_TO_EOF, MYF(0));
- my_close(lock_file, MYF(0));
+ sem_post(&myslapsemtrd);
+ }
+#endif
+#ifndef __WIN__
+#ifdef HAVE_LIBPTHREAD
+ else
+#endif
+ {
+ if (lock_file != -1)
+ {
+ my_lock(lock_file, F_UNLCK, 0, F_TO_EOF, MYF(0));
+ my_close(lock_file, MYF(0));
+ }
}
+#endif
if (!opt_only_print)
mysql_close(mysql);
if (con->thread)
my_thread_end();
+
DBUG_RETURN(0);
}
| Thread |
|---|
| • bk commit into 5.1 tree (SergeyV:1.2235) | sergeyv | 29 Mar |