Conflicts:
	server/modules/filter/test/harness_common.c
This commit is contained in:
Markus Makela 2014-11-17 20:20:33 +02:00
commit d3df458b27
6 changed files with 53 additions and 17 deletions

View File

@ -33,7 +33,8 @@ int main(int argc, char** argv)
char *message;
char** optstr;
long msg_index = 1;
struct timespec ts1;
ts1.tv_sec = 0;
memset(cwd,0,1024);
if( argc <4){
@ -95,7 +96,8 @@ int main(int argc, char** argv)
fprintf(stderr,"Error: log_manager returned %d",err);
break;
}
usleep(100);
ts1.tv_nsec = 100*1000000;
nanosleep(&ts1, NULL);
}
skygw_log_flush(LOGFILE_ERROR);

View File

@ -382,7 +382,12 @@ static bool file_write_header(
const char* header_buf3;
time_t* t = NULL;
struct tm* tm = NULL;
#if defined(LAPTOP_TEST)
struct timespec ts1;
ts1.tv_sec = 0;
ts1.tv_nsec = DISKWRITE_LATENCY*1000000;
#endif
if ((t = (time_t *)malloc(sizeof(time_t))) == NULL) {
goto return_succp;
}
@ -406,7 +411,7 @@ static bool file_write_header(
len2 = strlen(header_buf2);
len3 = strlen(header_buf3);
#if defined(LAPTOP_TEST)
usleep(DISKWRITE_LATENCY);
nanosleep(&ts1, NULL);
#else
wbytes1=fwrite((void*)header_buf1, len1, 1, outfile);
wbytes2=fwrite((void*)header_buf2, len2, 1, outfile);

View File

@ -866,6 +866,8 @@ void route_buffers()
while(instance.buff_ind < instance.buffer_count){
pthread_mutex_unlock(&instance.work_mtx);
while(instance.last_ind < instance.session_count){
struct timespec ts1;
ts1.tv_sec = 0;
tprg = ((bprg + (float)instance.last_ind)/fin);
if(!instance.verbose){
@ -874,7 +876,8 @@ void route_buffers()
trig += step;
}
}
usleep(100);
ts1.tv_nsec = 100*1000000;
nanosleep(&ts1, NULL);
}
pthread_mutex_lock(&instance.work_mtx);
instance.buff_ind++;
@ -909,7 +912,11 @@ void work_buffer(void* thr_num)
index < instance.session_count &&
instance.buff_ind < instance.buffer_count)
{
struct timespec ts1;
ts1.tv_sec = 0;
if(instance.head->instance->routeQuery(instance.head->filter,
instance.head->session[index],
instance.buffer[instance.buff_ind]) == 0){
if(instance.outfile > 0){
@ -923,7 +930,8 @@ void work_buffer(void* thr_num)
fake_ok);
}
atomic_add(&instance.last_ind,1);
usleep(1000*instance.rt_delay);
ts1.tv_nsec = 1000*instance.rt_delay*1000000;
nanosleep(&ts1, NULL);
}
}

View File

@ -1111,7 +1111,7 @@ int gw_MySQLAccept(DCB *listener)
int sendbuf = GW_BACKEND_SO_SNDBUF;
socklen_t optlen = sizeof(sendbuf);
int eno = 0;
int syseno = 0;
int syseno = 0;
int i = 0;
CHK_DCB(listener);
@ -1151,6 +1151,8 @@ int gw_MySQLAccept(DCB *listener)
}
else if (eno == ENFILE || eno == EMFILE)
{
struct timespec ts1;
ts1.tv_sec = 0;
/**
* Exceeded system's (ENFILE) or processes
* (EMFILE) max. number of files limit.
@ -1173,8 +1175,9 @@ int gw_MySQLAccept(DCB *listener)
strerror(eno))));
}
i++;
usleep(100*i*i);
ts1.tv_nsec = 100*i*i*1000000;
nanosleep(&ts1, NULL);
if (i<10) {
goto retry_accept;
}

View File

@ -1847,7 +1847,7 @@ void protocol_add_srv_command(
MySQLProtocol* p,
mysql_server_cmd_t cmd)
{
#if defined(SS_DEBUG)
#if defined(EXTRA_SS_DEBUG)
server_command_t* c;
#endif
spinlock_acquire(&p->protocol_lock);

View File

@ -1224,12 +1224,16 @@ void acquire_lock(
int* l)
{
register int misscount = 0;
struct timespec ts1;
ts1.tv_sec = 0;
while (atomic_add(l, 1) != 0) {
atomic_add(l, -1);
misscount += 1;
if (misscount > 10) {
usleep(rand()%misscount);
if (misscount > 10)
{
ts1.tv_nsec = (rand()%misscount)*1000000;
nanosleep(&ts1, NULL);
}
}
}
@ -1636,7 +1640,12 @@ static bool file_write_header(
const char* header_buf4;
time_t* t;
struct tm* tm;
#if defined(LAPTOP_TEST)
struct timespec ts1;
ts1.tv_sec = 0;
ts1.tv_nsec = DISKWRITE_LATENCY*1000000;
#endif
t = (time_t *)malloc(sizeof(time_t));
tm = (struct tm *)malloc(sizeof(struct tm));
*t = time(NULL);
@ -1662,7 +1671,7 @@ static bool file_write_header(
len3 = strlen(header_buf3);
len4 = strlen(header_buf4);
#if defined(LAPTOP_TEST)
usleep(DISKWRITE_LATENCY);
nanosleep(&ts1, NULL);
#else
wbytes1=fwrite((void*)header_buf1, len1, 1, file->sf_file);
wbytes2=fwrite((void*)header_buf2, len2, 1, file->sf_file);
@ -1709,7 +1718,12 @@ static bool file_write_footer(
const char* header_buf1;
char* header_buf3 = NULL;
const char* header_buf4;
#if defined(LAPTOP_TEST)
struct timespec ts1;
ts1.tv_sec = 0;
ts1.tv_nsec = DISKWRITE_LATENCY*1000000;
#endif
CHK_FILE(file);
if (shutdown)
@ -1734,7 +1748,7 @@ static bool file_write_footer(
len1 = strlen(header_buf1);
len4 = strlen(header_buf4);
#if defined(LAPTOP_TEST)
usleep(DISKWRITE_LATENCY);
nanosleep(&ts1, NULL);
#else
wbytes3=fwrite((void*)header_buf3, tslen, 1, file->sf_file);
wbytes1=fwrite((void*)header_buf1, len1, 1, file->sf_file);
@ -1784,11 +1798,15 @@ int skygw_file_write(
size_t nwritten;
int fd;
static int writecount;
#else
struct timespec ts1;
ts1.tv_sec = 0;
ts1.tv_nsec = DISKWRITE_LATENCY*1000000;
#endif
CHK_FILE(file);
#if defined(LAPTOP_TEST)
usleep(DISKWRITE_LATENCY);
nanosleep(&ts1, NULL);
#else
nwritten = fwrite(data, nbytes, 1, file->sf_file);