server session BUGFIX handle removing ids not from the beginning
... in the thread pollsession queue.
diff --git a/src/session_server.c b/src/session_server.c
index 3557f0c..8fad7e9 100644
--- a/src/session_server.c
+++ b/src/session_server.c
@@ -704,9 +704,18 @@
/* another equal value, simply cannot be */
ERRINT;
}
+ if (found == 2) {
+ /* move the following values */
+ ps->queue[q_idx ? q_idx - 1 : NC_PS_QUEUE_SIZE - 1] = ps->queue[q_idx];
+ }
} else if (ps->queue[q_idx] == id) {
/* found our id, there can be no more equal valid values */
- found = 1;
+ if (i == 0) {
+ found = 1;
+ } else {
+ /* this is not okay, our id is in the middle of the queue */
+ found = 2;
+ }
}
}
if (!found) {
@@ -714,8 +723,10 @@
}
/* remove the id by moving the queue */
- --ps->queue_len;
- ps->queue_begin = (ps->queue_begin + 1) % NC_PS_QUEUE_SIZE;
+ if (found == 1) {
+ --ps->queue_len;
+ ps->queue_begin = (ps->queue_begin + 1) % NC_PS_QUEUE_SIZE;
+ }
}
int