diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-06-17 01:26:37 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-06-17 01:26:37 +0800 |
commit | d3cdd1fd4a2a5d5d164f5b31a74131b5ee4eace0 (patch) | |
tree | 7fe7957be4fe217bfc907bcb24343c0ad5ec2502 /daemon | |
parent | 9415460aa8ea606ea54edeed2477519940b1813b (diff) | |
download | pttbbs-d3cdd1fd4a2a5d5d164f5b31a74131b5ee4eace0.tar pttbbs-d3cdd1fd4a2a5d5d164f5b31a74131b5ee4eace0.tar.gz pttbbs-d3cdd1fd4a2a5d5d164f5b31a74131b5ee4eace0.tar.bz2 pttbbs-d3cdd1fd4a2a5d5d164f5b31a74131b5ee4eace0.tar.lz pttbbs-d3cdd1fd4a2a5d5d164f5b31a74131b5ee4eace0.tar.xz pttbbs-d3cdd1fd4a2a5d5d164f5b31a74131b5ee4eace0.tar.zst pttbbs-d3cdd1fd4a2a5d5d164f5b31a74131b5ee4eace0.zip |
* ackq: fix reuse number
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4643 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/logind/logind.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/daemon/logind/logind.c b/daemon/logind/logind.c index a36f2ea2..46a20730 100644 --- a/daemon/logind/logind.c +++ b/daemon/logind/logind.c @@ -330,9 +330,12 @@ ackq_add(login_conn_ctx *ctx) if (g_ack_queue[i]) continue; g_ack_queue[i] = ctx; + g_ack_queue_reuse--; return; } assert(!"corrupted ack queue"); + // may cause leak here, since queue is corrupted. + return; } else if (++g_ack_queue_size > g_ack_queue_capacity) { @@ -350,6 +353,7 @@ static int ackq_del(login_conn_ctx *ctx) { size_t i; + for (i = 0; i < g_ack_queue_size; i++) { if (g_ack_queue[i] != ctx) @@ -363,6 +367,11 @@ ackq_del(login_conn_ctx *ctx) else g_ack_queue_reuse++; } + + // reset queue to zero if already empty. + if (g_ack_queue_reuse == g_ack_queue_size) + g_ack_queue_reuse = g_ack_queue_size = 0; + return 0; } |