summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-05-17 02:58:49 +0800
committerptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-05-17 02:58:49 +0800
commitcd9c701afe261511d6f22d00ce883a4bf952f453 (patch)
tree6f03a78247a0d0cd717ead81827da29cc3919477
parent86c0d7458eee83cde3e35abbba85b66337076262 (diff)
downloadpttbbs-cd9c701afe261511d6f22d00ce883a4bf952f453.tar
pttbbs-cd9c701afe261511d6f22d00ce883a4bf952f453.tar.gz
pttbbs-cd9c701afe261511d6f22d00ce883a4bf952f453.tar.bz2
pttbbs-cd9c701afe261511d6f22d00ce883a4bf952f453.tar.lz
pttbbs-cd9c701afe261511d6f22d00ce883a4bf952f453.tar.xz
pttbbs-cd9c701afe261511d6f22d00ce883a4bf952f453.tar.zst
pttbbs-cd9c701afe261511d6f22d00ce883a4bf952f453.zip
*** empty log message ***
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@859 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--util/inndBM.c2
-rw-r--r--util/util_cache.c61
2 files changed, 54 insertions, 9 deletions
diff --git a/util/inndBM.c b/util/inndBM.c
index 73f66c5e..8f1a69a0 100644
--- a/util/inndBM.c
+++ b/util/inndBM.c
@@ -92,7 +92,7 @@ int load_newsfeeds()
feedline[feedcount].server);
bid=getbnum(feedline[feedcount].board);
if(!bid) {
- fprintf(fo,"%s\n", feedline[feedcount].group );
+ fprintf(fo,"%s %s\n", feedline[feedcount].board, feedline[feedcount].group );
feedcount--;
continue; /*移除沒有的看板i*/}
diff --git a/util/util_cache.c b/util/util_cache.c
index 4d69bef8..a8dd6b71 100644
--- a/util/util_cache.c
+++ b/util/util_cache.c
@@ -1,4 +1,4 @@
-/* $Id: util_cache.c,v 1.10 2003/02/16 08:58:00 in2 Exp $ */
+/* $Id: util_cache.c,v 1.11 2003/05/16 18:58:49 ptt Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -312,13 +312,58 @@ userinfo_t *search_ulist(int uid) {
/* .BOARDS cache */
/*-------------------------------------------------------*/
char *fn_board=BBSHOME"/"FN_BOARD;
-static void reload_bcache() {
- if(SHM->Bbusystate) {
- safe_sleep(1);
+static int
+cmpboardname(boardheader_t ** brd, boardheader_t ** tmp)
+{
+ return strcasecmp((*brd)->brdname, (*tmp)->brdname);
+}
+
+static int
+cmpboardclass(boardheader_t ** brd, boardheader_t ** tmp)
+{
+ return (strncmp((*brd)->title, (*tmp)->title, 4) << 8) +
+ strcasecmp((*brd)->brdname, (*tmp)->brdname);
+}
+static void
+sort_bcache()
+{
+ int i;
+ /* critical section \xa4\xa3\xaf\xe0\xb3\xe6\xbfW\xa9I\xa5s \xa9I\xa5sreload
+_bcache or reset_board */
+ for (i = 0; i < SHM->Bnumber; i++) {
+ SHM->bsorted[1][i] = SHM->bsorted[0][i] = &bcache[i];
}
- else{
- puts("bcache is not loaded? resolve_boards() fail");
- exit(1);
+ qsort(SHM->bsorted[0], SHM->Bnumber, sizeof(boardheader_t *),
+ (QCAST) cmpboardname);
+ qsort(SHM->bsorted[1], SHM->Bnumber, sizeof(boardheader_t *),
+ (QCAST) cmpboardclass);
+}
+
+
+static void
+reload_bcache()
+{
+ if (SHM->Bbusystate) {
+ safe_sleep(1);
+ }
+ else {
+ int fd, i;
+
+ SHM->Bbusystate = 1;
+ if ((fd = open(fn_board, O_RDONLY)) > 0) {
+ SHM->Bnumber =
+ read(fd, bcache, MAX_BOARD * sizeof(boardheader_t)) /
+ sizeof(boardheader_t);
+ close(fd);
+ }
+ memset(SHM->lastposttime, 0, MAX_BOARD * sizeof(time_t));
+ SHM->Buptime = SHM->Btouchtime;
+ sort_bcache();
+ for (i = 0; i < SHM->Bnumber; ++i) {
+ bcache[i].firstchild[0] = NULL;
+ bcache[i].firstchild[1] = NULL;
+ }
+ SHM->Bbusystate = 0;
}
}
@@ -329,7 +374,7 @@ void resolve_boards() {
SHM->Btouchtime = 1;
}
- while(SHM->Buptime < SHM->Btouchtime)
+ if(SHM->Buptime < SHM->Btouchtime)
reload_bcache();
numboards = SHM->Bnumber;
}