From f86b8cf32e528fc67aaab054034d86fe4fabfcb8 Mon Sep 17 00:00:00 2001 From: piaip Date: Sat, 17 May 2008 13:14:43 +0000 Subject: - improve from_ip sort style git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4316 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- util/shmctl.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'util/shmctl.c') diff --git a/util/shmctl.c b/util/shmctl.c index 4a1a2a4c..e50fef43 100644 --- a/util/shmctl.c +++ b/util/shmctl.c @@ -280,8 +280,12 @@ cmputmpidle(const void * i, const void * j) static int cmputmpfrom(const void * i, const void * j) { - // desc sorted - return -(SHM->uinfo[*(int*)i].from_ip - SHM->uinfo[*(int*)j].from_ip); + int r = strcmp(SHM->uinfo[*(int*)i].from, SHM->uinfo[*(int*)j].from); + if (r) return r; + + // *** from_ip (in_addr_t) is big endian network number. + return memcmp(&(SHM->uinfo[*(int*)i].from_ip), &(SHM->uinfo[*(int*)j].from_ip), + sizeof(SHM->uinfo[0].from_ip)); } static int -- cgit v1.2.3