Fix to bug #513, http://bugs.skysql.com/show_bug.cgi?id=513
This commit is contained in:
@ -33,7 +33,8 @@ int main(int argc, char** argv)
|
|||||||
char *message;
|
char *message;
|
||||||
char** optstr;
|
char** optstr;
|
||||||
long msg_index = 1;
|
long msg_index = 1;
|
||||||
|
struct timespec ts1;
|
||||||
|
ts1.tv_sec = 0;
|
||||||
|
|
||||||
memset(cwd,0,1024);
|
memset(cwd,0,1024);
|
||||||
if( argc <4){
|
if( argc <4){
|
||||||
@ -95,7 +96,8 @@ int main(int argc, char** argv)
|
|||||||
fprintf(stderr,"Error: log_manager returned %d",err);
|
fprintf(stderr,"Error: log_manager returned %d",err);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
usleep(100);
|
ts1.tv_nsec = 100*1000000;
|
||||||
|
nanosleep(&ts1, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
skygw_log_flush(LOGFILE_ERROR);
|
skygw_log_flush(LOGFILE_ERROR);
|
||||||
|
@ -382,6 +382,11 @@ static bool file_write_header(
|
|||||||
const char* header_buf3;
|
const char* header_buf3;
|
||||||
time_t* t = NULL;
|
time_t* t = NULL;
|
||||||
struct tm* tm = 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) {
|
if ((t = (time_t *)malloc(sizeof(time_t))) == NULL) {
|
||||||
goto return_succp;
|
goto return_succp;
|
||||||
@ -406,7 +411,7 @@ static bool file_write_header(
|
|||||||
len2 = strlen(header_buf2);
|
len2 = strlen(header_buf2);
|
||||||
len3 = strlen(header_buf3);
|
len3 = strlen(header_buf3);
|
||||||
#if defined(LAPTOP_TEST)
|
#if defined(LAPTOP_TEST)
|
||||||
usleep(DISKWRITE_LATENCY);
|
nanosleep(&ts1, NULL);
|
||||||
#else
|
#else
|
||||||
wbytes1=fwrite((void*)header_buf1, len1, 1, outfile);
|
wbytes1=fwrite((void*)header_buf1, len1, 1, outfile);
|
||||||
wbytes2=fwrite((void*)header_buf2, len2, 1, outfile);
|
wbytes2=fwrite((void*)header_buf2, len2, 1, outfile);
|
||||||
|
@ -820,6 +820,8 @@ void route_buffers()
|
|||||||
while(instance.buff_ind < instance.buffer_count){
|
while(instance.buff_ind < instance.buffer_count){
|
||||||
pthread_mutex_unlock(&instance.work_mtx);
|
pthread_mutex_unlock(&instance.work_mtx);
|
||||||
while(instance.last_ind < instance.session_count){
|
while(instance.last_ind < instance.session_count){
|
||||||
|
struct timespec ts1;
|
||||||
|
ts1.tv_sec = 0;
|
||||||
|
|
||||||
tprg = ((bprg + (float)instance.last_ind)/fin);
|
tprg = ((bprg + (float)instance.last_ind)/fin);
|
||||||
if(!instance.verbose){
|
if(!instance.verbose){
|
||||||
@ -828,7 +830,8 @@ void route_buffers()
|
|||||||
trig += step;
|
trig += step;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
usleep(100);
|
ts1.tv_nsec = 100*1000000;
|
||||||
|
nanosleep(&ts1, NULL);
|
||||||
}
|
}
|
||||||
pthread_mutex_lock(&instance.work_mtx);
|
pthread_mutex_lock(&instance.work_mtx);
|
||||||
instance.buff_ind++;
|
instance.buff_ind++;
|
||||||
@ -863,6 +866,9 @@ void work_buffer(void* thr_num)
|
|||||||
index < instance.session_count &&
|
index < instance.session_count &&
|
||||||
instance.buff_ind < instance.buffer_count)
|
instance.buff_ind < instance.buffer_count)
|
||||||
{
|
{
|
||||||
|
struct timespec ts1;
|
||||||
|
ts1.tv_sec = 0;
|
||||||
|
|
||||||
instance.head->instance->routeQuery(instance.head->filter,
|
instance.head->instance->routeQuery(instance.head->filter,
|
||||||
instance.head->session[index],
|
instance.head->session[index],
|
||||||
instance.buffer[instance.buff_ind]);
|
instance.buffer[instance.buff_ind]);
|
||||||
@ -872,7 +878,8 @@ void work_buffer(void* thr_num)
|
|||||||
fake_ok);
|
fake_ok);
|
||||||
}
|
}
|
||||||
atomic_add(&instance.last_ind,1);
|
atomic_add(&instance.last_ind,1);
|
||||||
usleep(1000*instance.rt_delay);
|
ts1.tv_nsec = 1000*instance.rt_delay*1000000;
|
||||||
|
nanosleep(&ts1, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1151,6 +1151,8 @@ int gw_MySQLAccept(DCB *listener)
|
|||||||
}
|
}
|
||||||
else if (eno == ENFILE || eno == EMFILE)
|
else if (eno == ENFILE || eno == EMFILE)
|
||||||
{
|
{
|
||||||
|
struct timespec ts1;
|
||||||
|
ts1.tv_sec = 0;
|
||||||
/**
|
/**
|
||||||
* Exceeded system's (ENFILE) or processes
|
* Exceeded system's (ENFILE) or processes
|
||||||
* (EMFILE) max. number of files limit.
|
* (EMFILE) max. number of files limit.
|
||||||
@ -1173,7 +1175,8 @@ int gw_MySQLAccept(DCB *listener)
|
|||||||
strerror(eno))));
|
strerror(eno))));
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
usleep(100*i*i);
|
ts1.tv_nsec = 100*i*i*1000000;
|
||||||
|
nanosleep(&ts1, NULL);
|
||||||
|
|
||||||
if (i<10) {
|
if (i<10) {
|
||||||
goto retry_accept;
|
goto retry_accept;
|
||||||
|
@ -1847,7 +1847,7 @@ void protocol_add_srv_command(
|
|||||||
MySQLProtocol* p,
|
MySQLProtocol* p,
|
||||||
mysql_server_cmd_t cmd)
|
mysql_server_cmd_t cmd)
|
||||||
{
|
{
|
||||||
#if defined(SS_DEBUG)
|
#if defined(EXTRA_SS_DEBUG)
|
||||||
server_command_t* c;
|
server_command_t* c;
|
||||||
#endif
|
#endif
|
||||||
spinlock_acquire(&p->protocol_lock);
|
spinlock_acquire(&p->protocol_lock);
|
||||||
|
@ -1224,12 +1224,16 @@ void acquire_lock(
|
|||||||
int* l)
|
int* l)
|
||||||
{
|
{
|
||||||
register int misscount = 0;
|
register int misscount = 0;
|
||||||
|
struct timespec ts1;
|
||||||
|
ts1.tv_sec = 0;
|
||||||
|
|
||||||
while (atomic_add(l, 1) != 0) {
|
while (atomic_add(l, 1) != 0) {
|
||||||
atomic_add(l, -1);
|
atomic_add(l, -1);
|
||||||
misscount += 1;
|
misscount += 1;
|
||||||
if (misscount > 10) {
|
if (misscount > 10)
|
||||||
usleep(rand()%misscount);
|
{
|
||||||
|
ts1.tv_nsec = (rand()%misscount)*1000000;
|
||||||
|
nanosleep(&ts1, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1636,6 +1640,11 @@ static bool file_write_header(
|
|||||||
const char* header_buf4;
|
const char* header_buf4;
|
||||||
time_t* t;
|
time_t* t;
|
||||||
struct tm* tm;
|
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));
|
t = (time_t *)malloc(sizeof(time_t));
|
||||||
tm = (struct tm *)malloc(sizeof(struct tm));
|
tm = (struct tm *)malloc(sizeof(struct tm));
|
||||||
@ -1662,7 +1671,7 @@ static bool file_write_header(
|
|||||||
len3 = strlen(header_buf3);
|
len3 = strlen(header_buf3);
|
||||||
len4 = strlen(header_buf4);
|
len4 = strlen(header_buf4);
|
||||||
#if defined(LAPTOP_TEST)
|
#if defined(LAPTOP_TEST)
|
||||||
usleep(DISKWRITE_LATENCY);
|
nanosleep(&ts1, NULL);
|
||||||
#else
|
#else
|
||||||
wbytes1=fwrite((void*)header_buf1, len1, 1, file->sf_file);
|
wbytes1=fwrite((void*)header_buf1, len1, 1, file->sf_file);
|
||||||
wbytes2=fwrite((void*)header_buf2, len2, 1, file->sf_file);
|
wbytes2=fwrite((void*)header_buf2, len2, 1, file->sf_file);
|
||||||
@ -1709,6 +1718,11 @@ static bool file_write_footer(
|
|||||||
const char* header_buf1;
|
const char* header_buf1;
|
||||||
char* header_buf3 = NULL;
|
char* header_buf3 = NULL;
|
||||||
const char* header_buf4;
|
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);
|
CHK_FILE(file);
|
||||||
|
|
||||||
@ -1734,7 +1748,7 @@ static bool file_write_footer(
|
|||||||
len1 = strlen(header_buf1);
|
len1 = strlen(header_buf1);
|
||||||
len4 = strlen(header_buf4);
|
len4 = strlen(header_buf4);
|
||||||
#if defined(LAPTOP_TEST)
|
#if defined(LAPTOP_TEST)
|
||||||
usleep(DISKWRITE_LATENCY);
|
nanosleep(&ts1, NULL);
|
||||||
#else
|
#else
|
||||||
wbytes3=fwrite((void*)header_buf3, tslen, 1, file->sf_file);
|
wbytes3=fwrite((void*)header_buf3, tslen, 1, file->sf_file);
|
||||||
wbytes1=fwrite((void*)header_buf1, len1, 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;
|
size_t nwritten;
|
||||||
int fd;
|
int fd;
|
||||||
static int writecount;
|
static int writecount;
|
||||||
|
#else
|
||||||
|
struct timespec ts1;
|
||||||
|
ts1.tv_sec = 0;
|
||||||
|
ts1.tv_nsec = DISKWRITE_LATENCY*1000000;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CHK_FILE(file);
|
CHK_FILE(file);
|
||||||
#if defined(LAPTOP_TEST)
|
#if defined(LAPTOP_TEST)
|
||||||
usleep(DISKWRITE_LATENCY);
|
nanosleep(&ts1, NULL);
|
||||||
#else
|
#else
|
||||||
nwritten = fwrite(data, nbytes, 1, file->sf_file);
|
nwritten = fwrite(data, nbytes, 1, file->sf_file);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user