From 39091b847c504997a5a8203d1659510ee3b09a6b Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sun, 22 May 2005 16:12:26 +0000 Subject: [PATCH] * Full text indexer is now switchable on/off --- citadel/ChangeLog | 4 +++ citadel/citadel.h | 67 ++--------------------------------------- citadel/config.h | 64 +++++++++++++++++++++++++++++++++++++++ citadel/control.c | 4 +-- citadel/imap_misc.c | 2 +- citadel/imap_search.c | 4 +-- citadel/msgbase.c | 35 +++++++++++++-------- citadel/room_ops.c | 2 -- citadel/routines2.c | 3 ++ citadel/serv_fulltext.c | 13 ++++++++ citadel/serv_imap.c | 15 ++++++--- citadel/serv_upgrade.c | 4 +++ 12 files changed, 128 insertions(+), 89 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 889c025df..862c44e9d 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,7 @@ $Log$ + Revision 647.18 2005/05/22 16:12:25 ajc + * Full text indexer is now switchable on/off + Revision 647.17 2005/05/20 20:02:50 ajc * The IGnet map is now rewritten to disk only when it changes. * When processing inbound network spool, ignore "." and ".." instead of @@ -6753,3 +6756,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/citadel.h b/citadel/citadel.h index 62a1a5e6c..24b5987ee 100644 --- a/citadel/citadel.h +++ b/citadel/citadel.h @@ -33,7 +33,7 @@ extern "C" { /* * Text description of this software */ -#define CITADEL "Citadel 6.47" +#define CITADEL "Citadel 6.51" /* * REV_LEVEL is the current version number (multiplied by 100 to avoid having @@ -45,7 +45,7 @@ extern "C" { * usually more strict because you're not really supposed to dump/load and * upgrade at the same time. */ -#define REV_LEVEL 647 /* This version */ +#define REV_LEVEL 651 /* This version */ #define REV_MIN 591 /* Oldest compatible database */ #define EXPORT_REV_MIN 626 /* Oldest compatible export files */ @@ -79,69 +79,6 @@ struct ExpirePolicy { #define EXPIRE_AGE 3 /* Expire messages after n days */ -/* - * Global system configuration. - * - * Developers: please do NOT remove the fields labelled "not in use". We - * can't simply remove them from the struct, because this gets written to - * disk, and if you change it then you'll break all existing systems. - * However, if you'd like to reclaim some of that space for another use, feel - * free to do so, as long as the sizes are kept identical. - */ -struct config { - char c_nodename[16]; /* Unqualified "short" nodename */ - char c_fqdn[64]; /* Fully Qualified Domain Name */ - char c_humannode[21]; /* Long name of system */ - char c_phonenum[16]; /* Dialup number of system */ - uid_t c_ctdluid; /* UID under which we run Citadel */ - char c_creataide; /* room creator = room aide flag */ - int c_sleeping; /* watchdog timer setting */ - char c_initax; /* initial access level */ - char c_regiscall; /* call number to register on */ - char c_twitdetect; /* twit detect flag */ - char c_twitroom[ROOMNAMELEN]; /* twit detect msg move to room */ - char c_moreprompt[80]; /* paginator prompt */ - char c_restrict; /* restrict Internet mail flag */ - long c_niu_1; /* (not in use) */ - char c_site_location[32]; /* physical location of server */ - char c_sysadm[26]; /* name of system administrator */ - char c_niu_2[15]; /* (not in use) */ - int c_setup_level; /* what rev level we've setup to */ - int c_maxsessions; /* maximum concurrent sessions */ - char c_ip_addr[20]; /* IP address to listen on */ - int c_port_number; /* Cit listener port (usually 504) */ - int c_ipgm_secret; /* Internal program authentication */ - struct ExpirePolicy c_ep; /* System default msg expire policy */ - int c_userpurge; /* System default user purge (days) */ - int c_roompurge; /* System default room purge (days) */ - char c_logpages[ROOMNAMELEN]; /* Room to log pages to (or not) */ - char c_createax; /* Axlevel required to create rooms */ - long c_maxmsglen; /* Maximum message length */ - int c_min_workers; /* Lower limit on number of threads */ - int c_max_workers; /* Upper limit on number of threads */ - int c_pop3_port; /* POP3 listener port (usually 110) */ - int c_smtp_port; /* SMTP listener port (usually 25) */ - int c_rfc822_strict_from; /* 1 = don't correct From: forgeries*/ - int c_aide_zap; /* Are Aides allowed to zap rooms? */ - int c_imap_port; /* IMAP listener port (usually 143) */ - time_t c_net_freq; /* how often to run the networker */ - char c_disable_newu; /* disable NEWU command */ - char c_niu_4; /* (not in use) */ - char c_baseroom[ROOMNAMELEN]; /* Name of baseroom (Lobby) */ - char c_aideroom[ROOMNAMELEN]; /* Name of aideroom (Aide) */ - int c_purge_hour; /* Hour during which db purges run */ - struct ExpirePolicy c_mbxep; /* Expire policy for mailbox rooms */ - char c_ldap_host[128]; /* Host where LDAP service lives */ - int c_ldap_port; /* Port on host where LDAP lives */ - char c_ldap_base_dn[256]; /* LDAP base DN */ - char c_ldap_bind_dn[256]; /* LDAP bind DN */ - char c_ldap_bind_pw[256]; /* LDAP bind password */ - int c_msa_port; /* SMTP MSA listener port (usu 587) */ - int c_imaps_port; /* IMAPS listener port (usually 993)*/ - int c_pop3s_port; /* POP3S listener port (usually 995)*/ - int c_smtps_port; /* SMTPS listener port (usually 465)*/ -}; - /* * This struct stores a list of rooms with new messages which the client * fetches from the server. This allows the client to "march" through diff --git a/citadel/config.h b/citadel/config.h index 7b1905946..160c5d96e 100644 --- a/citadel/config.h +++ b/citadel/config.h @@ -5,6 +5,70 @@ #include "serv_extensions.h" +/* + * Global system configuration. + * + * Developers: please do NOT remove the fields labelled "not in use". We + * can't simply remove them from the struct, because this gets written to + * disk, and if you change it then you'll break all existing systems. + * However, if you'd like to reclaim some of that space for another use, feel + * free to do so, as long as the sizes are kept identical. + */ +struct config { + char c_nodename[16]; /* Unqualified "short" nodename */ + char c_fqdn[64]; /* Fully Qualified Domain Name */ + char c_humannode[21]; /* Long name of system */ + char c_phonenum[16]; /* Dialup number of system */ + uid_t c_ctdluid; /* UID under which we run Citadel */ + char c_creataide; /* room creator = room aide flag */ + int c_sleeping; /* watchdog timer setting */ + char c_initax; /* initial access level */ + char c_regiscall; /* call number to register on */ + char c_twitdetect; /* twit detect flag */ + char c_twitroom[ROOMNAMELEN]; /* twit detect msg move to room */ + char c_moreprompt[80]; /* paginator prompt */ + char c_restrict; /* restrict Internet mail flag */ + long c_niu_1; /* (not in use) */ + char c_site_location[32]; /* physical location of server */ + char c_sysadm[26]; /* name of system administrator */ + char c_niu_2[15]; /* (not in use) */ + int c_setup_level; /* what rev level we've setup to */ + int c_maxsessions; /* maximum concurrent sessions */ + char c_ip_addr[20]; /* IP address to listen on */ + int c_port_number; /* Cit listener port (usually 504) */ + int c_ipgm_secret; /* Internal program authentication */ + struct ExpirePolicy c_ep; /* System default msg expire policy */ + int c_userpurge; /* System default user purge (days) */ + int c_roompurge; /* System default room purge (days) */ + char c_logpages[ROOMNAMELEN]; /* Room to log pages to (or not) */ + char c_createax; /* Axlevel required to create rooms */ + long c_maxmsglen; /* Maximum message length */ + int c_min_workers; /* Lower limit on number of threads */ + int c_max_workers; /* Upper limit on number of threads */ + int c_pop3_port; /* POP3 listener port (usually 110) */ + int c_smtp_port; /* SMTP listener port (usually 25) */ + int c_rfc822_strict_from; /* 1 = don't correct From: forgeries*/ + int c_aide_zap; /* Are Aides allowed to zap rooms? */ + int c_imap_port; /* IMAP listener port (usually 143) */ + time_t c_net_freq; /* how often to run the networker */ + char c_disable_newu; /* disable NEWU command */ + char c_enable_fulltext; /* enable full text indexing */ + char c_baseroom[ROOMNAMELEN]; /* Name of baseroom (Lobby) */ + char c_aideroom[ROOMNAMELEN]; /* Name of aideroom (Aide) */ + int c_purge_hour; /* Hour during which db purges run */ + struct ExpirePolicy c_mbxep; /* Expire policy for mailbox rooms */ + char c_ldap_host[128]; /* Host where LDAP service lives */ + int c_ldap_port; /* Port on host where LDAP lives */ + char c_ldap_base_dn[256]; /* LDAP base DN */ + char c_ldap_bind_dn[256]; /* LDAP bind DN */ + char c_ldap_bind_pw[256]; /* LDAP bind password */ + int c_msa_port; /* SMTP MSA listener port (usu 587) */ + int c_imaps_port; /* IMAPS listener port (usually 993)*/ + int c_pop3s_port; /* POP3S listener port (usually 995)*/ + int c_smtps_port; /* SMTPS listener port (usually 465)*/ +}; + + void get_config(void); void put_config(void); extern struct config config; diff --git a/citadel/control.c b/citadel/control.c index d018f2743..e497f3dbc 100644 --- a/citadel/control.c +++ b/citadel/control.c @@ -194,7 +194,7 @@ void cmd_conf(char *argbuf) cprintf("%d\n", config.c_imap_port); cprintf("%ld\n", config.c_net_freq); cprintf("%d\n", config.c_disable_newu); - cprintf("1\n"); /* no longer in use */ + cprintf("%d\n", config.c_enable_fulltext); cprintf("%d\n", config.c_purge_hour); #ifdef HAVE_LDAP cprintf("%s\n", config.c_ldap_host); @@ -344,7 +344,7 @@ void cmd_conf(char *argbuf) config.c_disable_newu = 1; break; case 30: - /* no longer in use */ + config.c_enable_fulltext = atoi(buf); break; case 31: if ((config.c_purge_hour >= 0) diff --git a/citadel/imap_misc.c b/citadel/imap_misc.c index 0ddd8d401..59e5d8178 100644 --- a/citadel/imap_misc.c +++ b/citadel/imap_misc.c @@ -331,7 +331,7 @@ void imap_append(int num_parms, char *parms[]) { ret = imap_grabroom(roomname, parms[2], 0); if (ret != 0) { - cprintf("%s NO Invalid mailbox name or location, or access denied\r\n", + cprintf("%s NO Invalid mailbox name or access denied\r\n", parms[0]); return; } diff --git a/citadel/imap_search.c b/citadel/imap_search.c index c43e966fb..a179a759e 100644 --- a/citadel/imap_search.c +++ b/citadel/imap_search.c @@ -449,9 +449,9 @@ void imap_do_search(int num_items, char **itemlist, int is_uid) { /* If there is a BODY search criterion in the query, use our full * text index to disqualify messages that don't have any chance of - * matching. + * matching. (Only do this if the index is enabled!!) */ - for (i=0; i<(num_items-1); ++i) { + if (config.c_enable_fulltext) for (i=0; i<(num_items-1); ++i) { if (!strcasecmp(itemlist[i], "BODY")) { ft_search(&fts_num_msgs, &fts_msgs, itemlist[i+1]); if (fts_num_msgs > 0) { diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 0ee40f6ee..cf73c74f9 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -44,6 +44,7 @@ #include "room_ops.h" #include "user_ops.h" #include "file_ops.h" +#include "config.h" #include "control.h" #include "tools.h" #include "mime_parser.h" @@ -52,7 +53,6 @@ #include "internet_addressing.h" #include "serv_fulltext.h" -extern struct config config; long config_msgnum; @@ -343,10 +343,16 @@ void CtdlSetSeen(long target_msgnum, int target_setting, int which_set) { memset(is_set, 0, (num_msgs * sizeof(char)) ); /* Decide which message set we're manipulating */ - if (which_set == ctdlsetseen_seen) safestrncpy(vset, vbuf.v_seen, sizeof vset); - if (which_set == ctdlsetseen_answered) safestrncpy(vset, vbuf.v_answered, sizeof vset); + switch(which_set) { + case ctdlsetseen_seen: + safestrncpy(vset, vbuf.v_seen, sizeof vset); + break; + case ctdlsetseen_answered: + safestrncpy(vset, vbuf.v_answered, sizeof vset); + break; + } - lprintf(CTDL_DEBUG, "before optimize: %s\n", vset); + /* lprintf(CTDL_DEBUG, "before optimize: %s\n", vset); */ /* Translate the existing sequence set into an array of booleans */ num_sets = num_tokens(vset, ','); @@ -420,11 +426,18 @@ void CtdlSetSeen(long target_msgnum, int target_setting, int which_set) { } /* Decide which message set we're manipulating */ - if (which_set == ctdlsetseen_seen) safestrncpy(vbuf.v_seen, vset, sizeof vbuf.v_seen); - if (which_set == ctdlsetseen_answered) safestrncpy(vbuf.v_answered, vset, sizeof vbuf.v_answered); + switch (which_set) { + case ctdlsetseen_seen: + safestrncpy(vbuf.v_seen, vset, sizeof vbuf.v_seen); + break; + case ctdlsetseen_answered: + safestrncpy(vbuf.v_answered, vset, + sizeof vbuf.v_answered); + break; + } free(is_set); - lprintf(CTDL_DEBUG, " after optimize: %s\n", vset); + /* lprintf(CTDL_DEBUG, " after optimize: %s\n", vset); */ free(msglist); CtdlSetRelationship(&vbuf, &CC->user, &CC->room); } @@ -2147,7 +2160,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ } /* Bump this user's messages posted counter. */ - lprintf(CTDL_DEBUG, "Updating user\n"); + lprintf(CTDL_DEBUG, "Updating user (FIXME defer this)\n"); lgetuser(&CC->user, CC->curr_user); CC->user.posted = CC->user.posted + 1; lputuser(&CC->user); @@ -3167,13 +3180,11 @@ void AdjRefCount(long msgnum, int incr) */ begin_critical_section(S_SUPPMSGMAIN); GetMetaData(&smi, msgnum); - lprintf(CTDL_DEBUG, "Ref count for message <%ld> before write is <%d>\n", - msgnum, smi.meta_refcount); smi.meta_refcount += incr; PutMetaData(&smi); end_critical_section(S_SUPPMSGMAIN); - lprintf(CTDL_DEBUG, "Ref count for message <%ld> after write is <%d>\n", - msgnum, smi.meta_refcount); + lprintf(CTDL_DEBUG, "msg %ld ref count incr %d, is now %d\n", + msgnum, incr, smi.meta_refcount); /* If the reference count is now zero, delete the message * (and its supplementary record as well). diff --git a/citadel/room_ops.c b/citadel/room_ops.c index cb73a80cd..4cc226dc3 100644 --- a/citadel/room_ops.c +++ b/citadel/room_ops.c @@ -830,7 +830,6 @@ void usergoto(char *where, int display_result, int transiently, cdb_free(cdbfr); } - lprintf(CTDL_DEBUG, " *** START COUNT *** \n"); total_messages = 0; for (a=0; a 0L) ++total_messages; @@ -860,7 +859,6 @@ void usergoto(char *where, int display_result, int transiently, } } } - lprintf(CTDL_DEBUG, " *** END COUNT *** \n"); new_messages = total_messages - old_messages; if (msglist != NULL) free(msglist); diff --git a/citadel/routines2.c b/citadel/routines2.c index 1f62c1888..849148131 100644 --- a/citadel/routines2.c +++ b/citadel/routines2.c @@ -829,6 +829,9 @@ void do_system_configuration(CtdlIPC *ipc) strprompt("How often to run network jobs (in seconds)", &sc[28][0], 5); strprompt("Hour to run purges (0-23)", &sc[31][0], 2); + snprintf(sc[30], sizeof sc[30], "%d", (boolprompt( + "Enable full text search index (warning: resource intensive)", + atoi(&sc[30][0])))); /* Save it */ scr_printf("Save this configuration? "); diff --git a/citadel/serv_fulltext.c b/citadel/serv_fulltext.c index d88f50f5e..59e8d01d4 100644 --- a/citadel/serv_fulltext.c +++ b/citadel/serv_fulltext.c @@ -208,6 +208,13 @@ void do_fulltext_indexing(void) { static time_t last_index = 0L; static time_t last_progress = 0L; + /* + * Don't do this if the site doesn't have it enabled. + */ + if (!config.c_enable_fulltext) { + return; + } + /* * Make sure we don't run the indexer too frequently. * FIXME move the setting into config @@ -365,6 +372,12 @@ void cmd_srch(char *argbuf) { char search_string[256]; if (CtdlAccessCheck(ac_logged_in)) return; + + if (!config.c_enable_fulltext) { + cprintf("%d Full text index is not enabled on this server.\n", + ERROR + CMD_NOT_SUPPORTED); + } + extract_token(search_string, argbuf, 0, '|', sizeof search_string); ft_search(&num_msgs, &msgs, search_string); diff --git a/citadel/serv_imap.c b/citadel/serv_imap.c index d40ca8745..c4bd19dd7 100644 --- a/citadel/serv_imap.c +++ b/citadel/serv_imap.c @@ -251,7 +251,10 @@ void imap_rescan_msgids(void) return; } - /* Check to see if the room's contents have changed. If not, we can avoid rescan */ + /* + * Check to see if the room's contents have changed. + * If not, we can avoid this rescan. + */ getroom(&CC->room, CC->room.QRname); if (IMAP->last_mtime == CC->room.QRmtime) { /* No changes! */ return; @@ -291,9 +294,10 @@ void imap_rescan_msgids(void) if (message_still_exists == 0) { cprintf("* %d EXPUNGE\r\n", i + 1); - /* Here's some nice stupid nonsense. When a message - * is expunged, we have to slide all the existing - * messages up in the message array. + /* Here's some nice stupid nonsense. When a + * message is expunged, we have to slide all + * the existing messages up in the message + * array. */ --IMAP->num_msgs; memcpy(&IMAP->msgids[i], @@ -323,12 +327,13 @@ void imap_rescan_msgids(void) /* * Now peruse the room for *new* messages only. */ - if (num_msgs > 0) + if (num_msgs > 0) { for (j = 0; j < num_msgs; ++j) { if (msglist[j] > original_highest) { imap_add_single_msgid(msglist[j], NULL); } } + } imap_set_seen_flags(); /* diff --git a/citadel/serv_upgrade.c b/citadel/serv_upgrade.c index 8abbad180..000e8afea 100644 --- a/citadel/serv_upgrade.c +++ b/citadel/serv_upgrade.c @@ -172,6 +172,10 @@ void update_config(void) { strcpy(config.c_ip_addr, "0.0.0.0"); } + if (CitControl.version < 650) { + config.c_enable_fulltext = 0; + } + put_config(); } -- 2.30.2