mirror of
https://github.com/MariaDB/server.git
synced 2025-05-28 13:01:41 +03:00
fix_max_connections to resize alarm_queue (Bug #1435)
include/queues.h: resize_queue() include/thr_alarm.h: resize_thr_alarm() to resize alarm_queue mysys/queues.c: resize_queue() mysys/thr_alarm.c: resize_thr_alarm() to resize alarm_queue
This commit is contained in:
parent
08504cfe27
commit
08a08a67db
@ -49,6 +49,7 @@ int init_queue(QUEUE *queue,uint max_elements,uint offset_to_key,
|
|||||||
int reinit_queue(QUEUE *queue,uint max_elements,uint offset_to_key,
|
int reinit_queue(QUEUE *queue,uint max_elements,uint offset_to_key,
|
||||||
pbool max_at_top, queue_compare compare,
|
pbool max_at_top, queue_compare compare,
|
||||||
void *first_cmp_arg);
|
void *first_cmp_arg);
|
||||||
|
int resize_queue(QUEUE *queue, uint max_elements);
|
||||||
void delete_queue(QUEUE *queue);
|
void delete_queue(QUEUE *queue);
|
||||||
void queue_insert(QUEUE *queue,byte *element);
|
void queue_insert(QUEUE *queue,byte *element);
|
||||||
byte *queue_remove(QUEUE *queue,uint idx);
|
byte *queue_remove(QUEUE *queue,uint idx);
|
||||||
|
@ -100,6 +100,7 @@ typedef struct st_alarm {
|
|||||||
#define thr_alarm_init(A) (*(A))=0
|
#define thr_alarm_init(A) (*(A))=0
|
||||||
#define thr_alarm_in_use(A) (*(A)!= 0)
|
#define thr_alarm_in_use(A) (*(A)!= 0)
|
||||||
void init_thr_alarm(uint max_alarm);
|
void init_thr_alarm(uint max_alarm);
|
||||||
|
void resize_thr_alarm(uint max_alarms);
|
||||||
my_bool thr_alarm(thr_alarm_t *alarmed, uint sec, ALARM *buff);
|
my_bool thr_alarm(thr_alarm_t *alarmed, uint sec, ALARM *buff);
|
||||||
void thr_alarm_kill(pthread_t thread_id);
|
void thr_alarm_kill(pthread_t thread_id);
|
||||||
void thr_end_alarm(thr_alarm_t *alarmed);
|
void thr_end_alarm(thr_alarm_t *alarmed);
|
||||||
|
@ -44,25 +44,35 @@ int init_queue(QUEUE *queue, uint max_elements, uint offset_to_key,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Reinitialize queue for new usage; Note that you can't currently resize
|
Reinitialize queue for new usage;
|
||||||
the number of elements! If you need this, fix it :)
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
int reinit_queue(QUEUE *queue, uint max_elements, uint offset_to_key,
|
int reinit_queue(QUEUE *queue, uint max_elements, uint offset_to_key,
|
||||||
pbool max_at_top, int (*compare) (void *, byte *, byte *),
|
pbool max_at_top, int (*compare) (void *, byte *, byte *),
|
||||||
void *first_cmp_arg)
|
void *first_cmp_arg)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("reinit_queue");
|
DBUG_ENTER("reinit_queue");
|
||||||
if (queue->max_elements < max_elements)
|
|
||||||
/* It's real easy to do realloc here, just don't want to bother */
|
|
||||||
DBUG_RETURN(my_errno=EE_OUTOFMEMORY);
|
|
||||||
|
|
||||||
queue->elements=0;
|
queue->elements=0;
|
||||||
queue->compare=compare;
|
queue->compare=compare;
|
||||||
queue->first_cmp_arg=first_cmp_arg;
|
queue->first_cmp_arg=first_cmp_arg;
|
||||||
queue->offset_to_key=offset_to_key;
|
queue->offset_to_key=offset_to_key;
|
||||||
queue->max_at_top= max_at_top ? (-1 ^ 1) : 0;
|
queue->max_at_top= max_at_top ? (-1 ^ 1) : 0;
|
||||||
|
resize_queue(queue, max_elements);
|
||||||
|
DBUG_RETURN(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int resize_queue(QUEUE *queue, uint max_elements)
|
||||||
|
{
|
||||||
|
byte **new_root;
|
||||||
|
DBUG_ENTER("resize_queue");
|
||||||
|
if (queue->max_elements == max_elements)
|
||||||
|
DBUG_RETURN(0);
|
||||||
|
if ((new_root= (byte **) my_realloc((void *)queue->root,
|
||||||
|
(max_elements+1)*sizeof(void*), MYF(MY_WME))) == 0)
|
||||||
|
DBUG_RETURN(1);
|
||||||
|
set_if_smaller(queue->elements, max_elements);
|
||||||
|
queue->max_elements=max_elements;
|
||||||
|
queue->root=new_root;
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +120,16 @@ void init_thr_alarm(uint max_alarms)
|
|||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void resize_thr_alarm(uint max_alarms)
|
||||||
|
{
|
||||||
|
pthread_mutex_lock(&LOCK_alarm);
|
||||||
|
/* it's ok not to shrink the queue sometimes */
|
||||||
|
if (alarm_queue.elements < max_alarms)
|
||||||
|
resize_queue(&alarm_queue,max_alarms+1);
|
||||||
|
pthread_mutex_unlock(&LOCK_alarm);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Request alarm after sec seconds.
|
Request alarm after sec seconds.
|
||||||
|
|
||||||
|
@ -86,6 +86,7 @@ static void fix_myisam_max_extra_sort_file_size(THD *thd, enum_var_type type);
|
|||||||
static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type);
|
static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type);
|
||||||
static void fix_max_binlog_size(THD *thd, enum_var_type type);
|
static void fix_max_binlog_size(THD *thd, enum_var_type type);
|
||||||
static void fix_max_relay_log_size(THD *thd, enum_var_type type);
|
static void fix_max_relay_log_size(THD *thd, enum_var_type type);
|
||||||
|
static void fix_max_connections(THD *thd, enum_var_type type);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Variable definition list
|
Variable definition list
|
||||||
@ -147,7 +148,8 @@ sys_var_long_ptr sys_max_binlog_size("max_binlog_size",
|
|||||||
&max_binlog_size,
|
&max_binlog_size,
|
||||||
fix_max_binlog_size);
|
fix_max_binlog_size);
|
||||||
sys_var_long_ptr sys_max_connections("max_connections",
|
sys_var_long_ptr sys_max_connections("max_connections",
|
||||||
&max_connections);
|
&max_connections,
|
||||||
|
fix_max_connections);
|
||||||
sys_var_long_ptr sys_max_connect_errors("max_connect_errors",
|
sys_var_long_ptr sys_max_connect_errors("max_connect_errors",
|
||||||
&max_connect_errors);
|
&max_connect_errors);
|
||||||
sys_var_long_ptr sys_max_delayed_threads("max_delayed_threads",
|
sys_var_long_ptr sys_max_delayed_threads("max_delayed_threads",
|
||||||
@ -636,7 +638,7 @@ static void fix_max_join_size(THD *thd, enum_var_type type)
|
|||||||
thd->options&= ~OPTION_BIG_SELECTS;
|
thd->options&= ~OPTION_BIG_SELECTS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
If one doesn't use the SESSION modifier, the isolation level
|
If one doesn't use the SESSION modifier, the isolation level
|
||||||
@ -689,7 +691,7 @@ static void fix_key_buffer_size(THD *thd, enum_var_type type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void fix_delay_key_write(THD *thd, enum_var_type type)
|
extern void fix_delay_key_write(THD *thd, enum_var_type type)
|
||||||
{
|
{
|
||||||
switch ((enum_delay_key_write) delay_key_write_options) {
|
switch ((enum_delay_key_write) delay_key_write_options) {
|
||||||
case DELAY_KEY_WRITE_NONE:
|
case DELAY_KEY_WRITE_NONE:
|
||||||
@ -705,7 +707,7 @@ void fix_delay_key_write(THD *thd, enum_var_type type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void fix_max_binlog_size(THD *thd, enum_var_type type)
|
static void fix_max_binlog_size(THD *thd, enum_var_type type)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("fix_max_binlog_size");
|
DBUG_ENTER("fix_max_binlog_size");
|
||||||
DBUG_PRINT("info",("max_binlog_size=%lu max_relay_log_size=%lu",
|
DBUG_PRINT("info",("max_binlog_size=%lu max_relay_log_size=%lu",
|
||||||
@ -716,7 +718,7 @@ void fix_max_binlog_size(THD *thd, enum_var_type type)
|
|||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fix_max_relay_log_size(THD *thd, enum_var_type type)
|
static void fix_max_relay_log_size(THD *thd, enum_var_type type)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("fix_max_relay_log_size");
|
DBUG_ENTER("fix_max_relay_log_size");
|
||||||
DBUG_PRINT("info",("max_binlog_size=%lu max_relay_log_size=%lu",
|
DBUG_PRINT("info",("max_binlog_size=%lu max_relay_log_size=%lu",
|
||||||
@ -726,6 +728,13 @@ void fix_max_relay_log_size(THD *thd, enum_var_type type)
|
|||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <thr_alarm.h>
|
||||||
|
static void
|
||||||
|
fix_max_connections(THD *thd, enum_var_type type)
|
||||||
|
{
|
||||||
|
resize_thr_alarm(max_connections);
|
||||||
|
}
|
||||||
|
|
||||||
bool sys_var_long_ptr::update(THD *thd, set_var *var)
|
bool sys_var_long_ptr::update(THD *thd, set_var *var)
|
||||||
{
|
{
|
||||||
ulonglong tmp= var->value->val_int();
|
ulonglong tmp= var->value->val_int();
|
||||||
@ -1478,7 +1487,7 @@ int set_var::check(THD *thd)
|
|||||||
{
|
{
|
||||||
my_error(ER_WRONG_TYPE_FOR_VAR, MYF(0), var->name);
|
my_error(ER_WRONG_TYPE_FOR_VAR, MYF(0), var->name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return var->check(thd, this) ? -1 : 0;
|
return var->check(thd, this) ? -1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user