summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorunknown <serg@serg.mylan>2003-10-06 14:11:16 +0200
committerunknown <serg@serg.mylan>2003-10-06 14:11:16 +0200
commit08a08a67dbde78258e46b0d9bcd387c8419b8fcd (patch)
tree7bffd47192fc8d22df42f124ba543de3125a5375 /mysys
parent08504cfe276a2ff53ab34a13250220c28702e03c (diff)
downloadmariadb-git-08a08a67dbde78258e46b0d9bcd387c8419b8fcd.tar.gz
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
Diffstat (limited to 'mysys')
-rw-r--r--mysys/queues.c24
-rw-r--r--mysys/thr_alarm.c10
2 files changed, 27 insertions, 7 deletions
diff --git a/mysys/queues.c b/mysys/queues.c
index fe642131d74..ae69684f9e4 100644
--- a/mysys/queues.c
+++ b/mysys/queues.c
@@ -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
- the number of elements! If you need this, fix it :)
+ Reinitialize queue for new usage;
*/
-
int reinit_queue(QUEUE *queue, uint max_elements, uint offset_to_key,
pbool max_at_top, int (*compare) (void *, byte *, byte *),
void *first_cmp_arg)
{
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->compare=compare;
queue->first_cmp_arg=first_cmp_arg;
queue->offset_to_key=offset_to_key;
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);
}
diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c
index 2289f8208bc..5d2ac8b0099 100644
--- a/mysys/thr_alarm.c
+++ b/mysys/thr_alarm.c
@@ -120,6 +120,16 @@ void init_thr_alarm(uint max_alarms)
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.