mariadb/client/thimble.cc
unknown 758567104c added loops and other cool stuff to mysqltest
fixed slave to preserve temp tables on slave stop; slave start
added abort-slave-event-count option to mysqld to test the above
added a test case for temp tables with a contantly aborting slave
removed warning in sql_parse.cc
fixed thimble.cc to compile


BitKeeper/etc/ignore:
  Added client/thimble support-files/mysql-3.23.29-gamma.spec to the ignore list
client/mysqltest.c:
  added while, let, and echo, added fractional sec sleep support
client/thimble.cc:
  fixes to make it compile
mysql-test/t/3.23/rpl000001.test:
  sleep less
mysql-test/t/3.23/rpl000002.test:
  sleep less
mysql-test/t/3.23/rpl000003.test:
  sleep less
mysql-test/t/3.23/rpl000005.test:
  sleep less
sql/mysqld.cc:
  --abort-slave-event count
sql/slave.cc:
  remember temp tables when slave thread termintates and restore them on
  slave start
sql/slave.h:
  --abort-slave-event-count
sql/sql_parse.cc:
  remove warning
2000-12-02 10:11:50 -07:00

93 lines
1.8 KiB
C++

#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "my_global.h"
static void spawn_stern_thread(pthread_t *t);
static int act_goofy(void);
static void *be_stern(void *);
static struct {
pthread_mutex_t lock;
pthread_cond_t cond;
int msg;
} comm = { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0 };
int
main(void)
{
pthread_t t;
spawn_stern_thread(&t);
while (act_goofy() != 0)
/* do nothing */;
pthread_exit(NULL);
/* notreached */
return EXIT_SUCCESS;
}
static void spawn_stern_thread(pthread_t *t)
{
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if (pthread_create(t, &attr, be_stern, NULL) != 0)
exit(EXIT_FAILURE);
pthread_attr_destroy(&attr);
}
static int act_goofy(void)
{
int ret;
char buf[30];
fputs("Are you ready to act goofy (Y/n)? ", stdout); fflush(stdout);
fgets(buf, sizeof(buf), stdin);
pthread_mutex_lock(&comm.lock);
if (buf[0] == 'y' || buf[0] == '\n') {
fputs("** Waawlwalkwwwaa!!\n", stdout); fflush(stdout);
++comm.msg;
ret = 1;
}
else {
fputs("OK, I hate you. Let me go.\n", stdout); fflush(stdout);
comm.msg = -1;
ret = 0;
}
pthread_mutex_unlock(&comm.lock);
pthread_cond_signal(&comm.cond);
return ret;
}
static void *be_stern(void *v __attribute__((unused)))
{
int msg;
for (;;) {
pthread_mutex_lock(&comm.lock);
while (comm.msg == 0)
pthread_cond_wait(&comm.cond, &comm.lock);
msg = comm.msg;
comm.msg = 0;
pthread_mutex_unlock(&comm.lock);
if (msg < 0)
break; /* the goofy one learned a lesson! */
fputs("I HAVE TO BE STERN WITH YOU!\n", stderr);
fprintf(stderr, "I should give you %d lashes.\n", msg);
sleep(msg);
}
fputs("You are NOTHING!\n", stderr);
return NULL;
}