From: Stephen D. <sd...@us...> - 2005-10-02 22:39:16
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20391/nsd Modified Files: driver.c log.c nsconf.c nsd.h queue.c server.c Removed Files: nsconf.h Log Message: * nsd/log.c: * nsd/nsd.h: Remove NsParam* wrapper macros. Directly using Ns_Config* is clearer (and grep-able). * nsd/server.c: * nsd/nsconf.c: * nsd/queue.c: Use new Ns_Config* routines which handle defaults and range checking. Note: config file values which are less than the lower bound of a range are rounded up and not converted to the default value, as before. * nsd/driver.c: Some config defaults have changed. * nsd/nsconf.h: Removed. Incroporated default values directly into code. Index: nsd.h =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/nsd.h,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** nsd.h 2 Oct 2005 22:23:09 -0000 1.33 --- nsd.h 2 Oct 2005 22:39:06 -0000 1.34 *************** *** 360,364 **** int maxline; /* Maximum request line size. */ int maxheaders; /* Maximum number of request headers. */ ! int maxsize; /* Maximum request size in memory. */ unsigned int loggingFlags; /* Logging control flags */ --- 360,364 ---- int maxline; /* Maximum request line size. */ int maxheaders; /* Maximum number of request headers. */ ! int readahead; /* Maximum request size in memory. */ unsigned int loggingFlags; /* Logging control flags */ *************** *** 840,851 **** extern void NsInitRequests(void); - /* - * Configuration routines. - */ - extern void NsConfigLog(void); - #define NsParamString(key, def) Ns_ConfigString(NS_CONFIG_PARAMETERS, (key), (def)) - #define NsParamBool(key, def) Ns_ConfigBool(NS_CONFIG_PARAMETERS, (key), (def)) - #define NsParamInt(key, def) Ns_ConfigInt(NS_CONFIG_PARAMETERS, (key), (def)) extern int NsQueueConn(Sock *sockPtr, Ns_Time *nowPtr); --- 840,844 ---- --- nsconf.h DELETED --- Index: log.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/log.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** log.c 4 Aug 2005 22:17:41 -0000 1.7 --- log.c 2 Oct 2005 22:39:06 -0000 1.8 *************** *** 155,179 **** NsConfigLog(void) { ! Ns_DString ds; ! logConfig[Notice].enabled = NsParamBool("lognotice", LOG_NOTICE_BOOL); ! logConfig[Debug].enabled = NsParamBool("logdebug", LOG_DEBUG_BOOL); ! logConfig[Dev].enabled = NsParamBool("logdev", LOG_DEV_BOOL); ! if (NsParamBool( "logroll", LOG_ROLL_BOOL)) { flags |= LOG_ROLL; } ! if (NsParamBool("logusec", LOG_USEC_BOOL)) { flags |= LOG_USEC; } ! if (NsParamBool("logexpanded", LOG_EXPANDED_BOOL)) { flags |= LOG_EXPAND; } ! maxback = NsParamInt("logmaxbackup", LOG_MAXBACK_INT); ! maxlevel = NsParamInt("logmaxlevel", LOG_MAXLEVEL_INT); ! maxbuffer = NsParamInt("logmaxbuffer", LOG_MAXBUFFER_INT); ! file = NsParamString("serverlog", LOG_FILE_STRING); if (!Ns_PathIsAbsolute(file)) { Ns_DStringInit(&ds); --- 155,180 ---- NsConfigLog(void) { ! Ns_DString ds; ! CONST char *path = NS_CONFIG_PARAMETERS; ! logConfig[Notice].enabled = Ns_ConfigBool(path, "lognotice", NS_TRUE); ! logConfig[Debug].enabled = Ns_ConfigBool(path, "logdebug", NS_FALSE); ! logConfig[Dev].enabled = Ns_ConfigBool(path, "logdev", NS_FALSE); ! if (Ns_ConfigBool(path, "logroll", NS_TRUE)) { flags |= LOG_ROLL; } ! if (Ns_ConfigBool(path, "logusec", NS_FALSE)) { flags |= LOG_USEC; } ! if (Ns_ConfigBool(path, "logexpanded", NS_FALSE)) { flags |= LOG_EXPAND; } ! maxback = Ns_ConfigIntRange(path, "logmaxbackup", 10, 0, 999); ! maxlevel = Ns_ConfigInt(path, "logmaxlevel", INT_MAX); ! maxbuffer = Ns_ConfigInt(path, "logmaxbuffer", 10); ! file = Ns_ConfigString(path, "serverlog", "server.log"); if (!Ns_PathIsAbsolute(file)) { Ns_DStringInit(&ds); *************** *** 203,207 **** Ns_InfoErrorLog(void) { ! return (char*)file; } --- 204,208 ---- Ns_InfoErrorLog(void) { ! return (char*) file; } Index: server.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/server.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** server.c 30 Jul 2005 03:17:50 -0000 1.11 --- server.c 2 Oct 2005 22:39:06 -0000 1.12 *************** *** 198,202 **** Ns_DString ds; NsServer *servPtr; ! char *path, *spath, *map, *key, *dirf, *p; Ns_Set *set; int i, n, status; --- 198,202 ---- Ns_DString ds; NsServer *servPtr; ! CONST char *path, *spath, *map, *key, *p; Ns_Set *set; int i, n, status; *************** *** 223,254 **** * Set some server options. */ ! ! servPtr->opts.realm = Ns_ConfigGetValue(path, "realm"); ! if (servPtr->opts.realm == NULL) { ! servPtr->opts.realm = server; ! } ! if (!Ns_ConfigGetBool(path, "checkmodifiedsince", ! &servPtr->opts.modsince)) { ! servPtr->opts.modsince = SERV_MODSINCE_BOOL; ! } ! if (!Ns_ConfigGetBool(path, "flushcontent", ! &servPtr->opts.flushcontent)) { ! servPtr->opts.flushcontent = SERV_FLUSHCONTENT_BOOL; ! } ! if (!Ns_ConfigGetBool(path, "noticedetail", ! &servPtr->opts.noticedetail)) { ! servPtr->opts.noticedetail = SERV_NOTICEDETAIL_BOOL; ! } ! if (!Ns_ConfigGetInt(path, "errorminsize", ! &servPtr->opts.errorminsize)) { ! servPtr->opts.errorminsize = SERV_ERRORMINSIZE_INT; ! } ! p = Ns_ConfigGetValue(path, "headercase"); ! if (p != NULL && STRIEQ(p, "tolower")) { servPtr->opts.hdrcase = ToLower; ! } else if (p != NULL && STRIEQ(p, "toupper")) { servPtr->opts.hdrcase = ToUpper; - } else { - servPtr->opts.hdrcase = Preserve; } --- 223,238 ---- * Set some server options. */ ! ! servPtr->opts.realm = Ns_ConfigString(path, "realm", server); ! servPtr->opts.modsince = Ns_ConfigBool(path, "checkmodifiedsince", NS_TRUE); ! servPtr->opts.flushcontent = Ns_ConfigBool(path, "flushcontent", NS_FALSE); ! servPtr->opts.noticedetail = Ns_ConfigBool(path, "noticedetail", NS_TRUE); ! servPtr->opts.errorminsize = Ns_ConfigInt(path, "errorminsize", 514); ! servPtr->opts.hdrcase = Preserve; ! p = Ns_ConfigString(path, "headercase", "preserve"); ! if (STRIEQ(p, "tolower")) { servPtr->opts.hdrcase = ToLower; ! } else if (STRIEQ(p, "toupper")) { servPtr->opts.hdrcase = ToUpper; } *************** *** 256,259 **** --- 240,244 ---- * Encoding defaults for the server */ + servPtr->encoding.outputCharset = Ns_ConfigGetValue(path, "outputCharset"); if (servPtr->encoding.outputCharset != NULL) { *************** *** 307,315 **** Tcl_IncrRefCount(servPtr->tcl.modules); Ns_RWLockInit(&servPtr->tcl.lock); ! if (!Ns_ConfigGetInt(path, "nsvbuckets", &n) || n < 1) { ! n = TCL_NSVBUCKETS_INT; ! } ! servPtr->nsv.nbuckets = n; ! servPtr->nsv.buckets = NsTclCreateBuckets(server, n); Tcl_InitHashTable(&servPtr->share.inits, TCL_STRING_KEYS); Tcl_InitHashTable(&servPtr->share.vars, TCL_STRING_KEYS); --- 292,297 ---- Tcl_IncrRefCount(servPtr->tcl.modules); Ns_RWLockInit(&servPtr->tcl.lock); ! servPtr->nsv.nbuckets = Ns_ConfigIntRange(path, "nsvbuckets", 8, 1, INT_MAX); ! servPtr->nsv.buckets = NsTclCreateBuckets(server, servPtr->nsv.nbuckets); Tcl_InitHashTable(&servPtr->share.inits, TCL_STRING_KEYS); Tcl_InitHashTable(&servPtr->share.vars, TCL_STRING_KEYS); *************** *** 326,330 **** if (p != NULL && Tcl_SplitList(NULL, p, &n, &servPtr->tcl.errorLogHeaders) != TCL_OK) { ! Ns_Log(Error, "invalid error log headers: %s", p); } --- 308,312 ---- if (p != NULL && Tcl_SplitList(NULL, p, &n, &servPtr->tcl.errorLogHeaders) != TCL_OK) { ! Ns_Log(Error, "config: errorlogheaders is not a list: %s", p); } *************** *** 341,380 **** path = Ns_ConfigGetPath(server, NULL, "fastpath", NULL); ! if (!Ns_ConfigGetBool(path, "cache", &i) || i) { ! if (!Ns_ConfigGetInt(path, "cachemaxsize", &n)) { ! n = FASTPATH_CACHESIZE_INT; ! } ! if (!Ns_ConfigGetInt(path, "cachemaxentry", &i) || i < 0) { ! i = FASTPATH_CACHEMAXENTRY_INT; ! } ! servPtr->fastpath.cachemaxentry = i; ! servPtr->fastpath.cache = NsFastpathCache(server, n); ! } ! if (!Ns_ConfigGetBool(path, "mmap", &servPtr->fastpath.mmap)) { ! servPtr->fastpath.mmap = FASTPATH_MMAP_BOOL; ! } ! dirf = Ns_ConfigGetValue(path, "directoryfile"); ! if (dirf == NULL) { ! dirf = Ns_ConfigGetValue(spath, "directoryfile"); } ! if (dirf != NULL) { ! dirf = ns_strdup(dirf); ! p = dirf; ! n = 1; ! while ((p = (strchr(p, ','))) != NULL) { ! ++n; ! ++p; ! } ! servPtr->fastpath.dirc = n; ! servPtr->fastpath.dirv = ns_malloc(sizeof(char *) * n); ! for (i = 0; i < n; ++i) { ! p = strchr(dirf, ','); ! if (p != NULL) { ! *p++ = '\0'; ! } ! servPtr->fastpath.dirv[i] = dirf; ! dirf = p; ! } } servPtr->fastpath.serverdir = Ns_ConfigGetValue(path, "serverdir"); if (servPtr->fastpath.serverdir == NULL) { --- 323,340 ---- path = Ns_ConfigGetPath(server, NULL, "fastpath", NULL); ! if (Ns_ConfigBool(path, "cache", NS_FALSE)) { ! servPtr->fastpath.cachemaxentry = ! Ns_ConfigIntRange(path, "cachemaxentry", 8192, 1, INT_MAX); ! n = Ns_ConfigIntRange(path, "cachemaxsize", 5000*1024, 1, INT_MAX); ! servPtr->fastpath.cache = NsFastpathCache(server, n); } ! servPtr->fastpath.mmap = Ns_ConfigBool(path, "mmap", NS_FALSE); ! ! p = Ns_ConfigGetValue(path, "directoryfile"); ! if (p != NULL && Tcl_SplitList(NULL, p, &servPtr->fastpath.dirc, ! &servPtr->fastpath.dirv) != TCL_OK) { ! Ns_Log(Error, "config: directoryfile is not a list: %s", p); } + servPtr->fastpath.serverdir = Ns_ConfigGetValue(path, "serverdir"); if (servPtr->fastpath.serverdir == NULL) { *************** *** 385,392 **** servPtr->fastpath.serverdir = Ns_DStringExport(&ds); } ! servPtr->fastpath.pagedir = Ns_ConfigGetValue(path, "pagedir"); ! if (servPtr->fastpath.pagedir == NULL) { ! servPtr->fastpath.pagedir = "pages"; ! } if (Ns_PathIsAbsolute(servPtr->fastpath.pagedir)) { servPtr->fastpath.pageroot = servPtr->fastpath.pagedir; --- 345,350 ---- servPtr->fastpath.serverdir = Ns_DStringExport(&ds); } ! ! servPtr->fastpath.pagedir = Ns_ConfigString(path, "pagedir", "pages"); if (Ns_PathIsAbsolute(servPtr->fastpath.pagedir)) { servPtr->fastpath.pageroot = servPtr->fastpath.pagedir; *************** *** 396,407 **** servPtr->fastpath.pageroot = Ns_DStringExport(&ds); } p = Ns_ConfigGetValue(path, "directorylisting"); if (p != NULL && (STREQ(p, "simple") || STREQ(p, "fancy"))) { p = "_ns_dirlist"; } ! servPtr->fastpath.dirproc = Ns_ConfigGetValue(path, "directoryproc"); ! if (servPtr->fastpath.dirproc == NULL) { ! servPtr->fastpath.dirproc = p; ! } servPtr->fastpath.diradp = Ns_ConfigGetValue(path, "directoryadp"); --- 354,363 ---- servPtr->fastpath.pageroot = Ns_DStringExport(&ds); } + p = Ns_ConfigGetValue(path, "directorylisting"); if (p != NULL && (STREQ(p, "simple") || STREQ(p, "fancy"))) { p = "_ns_dirlist"; } ! servPtr->fastpath.dirproc = Ns_ConfigString(path, "directoryproc", p); servPtr->fastpath.diradp = Ns_ConfigGetValue(path, "directoryadp"); *************** *** 411,417 **** path = Ns_ConfigGetPath(server, NULL, "vhost", NULL); ! if (!Ns_ConfigGetBool(path, "enabled", &servPtr->vhost.enabled)) { ! servPtr->vhost.enabled = VHOST_ENABLED_BOOL; ! } if (servPtr->vhost.enabled && Ns_PathIsAbsolute(servPtr->fastpath.pagedir)) { --- 367,371 ---- path = Ns_ConfigGetPath(server, NULL, "vhost", NULL); ! servPtr->vhost.enabled = Ns_ConfigBool(path, "enabled", NS_FALSE); if (servPtr->vhost.enabled && Ns_PathIsAbsolute(servPtr->fastpath.pagedir)) { *************** *** 420,437 **** servPtr->vhost.enabled = NS_FALSE; } ! if (!Ns_ConfigGetBool(path, "stripwww", &i) || i) { servPtr->vhost.opts |= NSD_STRIP_WWW; } ! if (!Ns_ConfigGetBool(path, "stripport", &i) || i) { servPtr->vhost.opts |= NSD_STRIP_PORT; } servPtr->vhost.hostprefix = Ns_ConfigGetValue(path, "hostprefix"); ! Ns_ConfigGetInt(path, "hosthashlevel", &servPtr->vhost.hosthashlevel); ! if (servPtr->vhost.hosthashlevel < 0) { ! servPtr->vhost.hosthashlevel = 0; ! } ! if (servPtr->vhost.hosthashlevel > 5) { ! servPtr->vhost.hosthashlevel = 5; ! } if (servPtr->vhost.enabled) { NsPageRoot(&ds, servPtr, "www.example.com:80"); --- 374,386 ---- servPtr->vhost.enabled = NS_FALSE; } ! if (Ns_ConfigBool(path, "stripwww", NS_TRUE)) { servPtr->vhost.opts |= NSD_STRIP_WWW; } ! if (Ns_ConfigBool(path, "stripport", NS_TRUE)) { servPtr->vhost.opts |= NSD_STRIP_PORT; } servPtr->vhost.hostprefix = Ns_ConfigGetValue(path, "hostprefix"); ! servPtr->vhost.hosthashlevel = ! Ns_ConfigIntRange(path, "hosthashlevel", 0, 0, 5); if (servPtr->vhost.enabled) { NsPageRoot(&ds, servPtr, "www.example.com:80"); *************** *** 474,499 **** path = Ns_ConfigGetPath(server, NULL, "adp", NULL); ! servPtr->adp.errorpage = Ns_ConfigGetValue(path, "errorpage"); ! servPtr->adp.startpage = Ns_ConfigGetValue(path, "startpage"); ! if (!Ns_ConfigGetBool(path, "enableexpire", ! &servPtr->adp.enableexpire)) { ! servPtr->adp.enableexpire = ADP_ENABLEEXPIRE_BOOL; ! } ! if (!Ns_ConfigGetBool(path, "enabledebug", ! &servPtr->adp.enabledebug)) { ! servPtr->adp.enabledebug = ADP_ENABLEDEBUG_BOOL; ! } ! servPtr->adp.debuginit = Ns_ConfigGetValue(path, "debuginit"); ! if (servPtr->adp.debuginit == NULL) { ! servPtr->adp.debuginit = ADP_DEBUGINIT_STRING; ! } ! servPtr->adp.defaultparser = Ns_ConfigGetValue(path, "defaultparser"); ! if (servPtr->adp.defaultparser == NULL) { ! servPtr->adp.defaultparser = ADP_DEFPARSER_STRING; ! } ! if (!Ns_ConfigGetInt(path, "cachesize", &n)) { ! n = ADP_CACHESIZE_INT; ! } ! servPtr->adp.cachesize = n; /* --- 423,433 ---- path = Ns_ConfigGetPath(server, NULL, "adp", NULL); ! servPtr->adp.errorpage = Ns_ConfigString(path, "errorpage", NULL); ! servPtr->adp.startpage = Ns_ConfigString(path, "startpage", NULL); ! servPtr->adp.enableexpire = Ns_ConfigBool(path, "enableexpire", NS_FALSE); ! servPtr->adp.enabledebug = Ns_ConfigBool(path, "enabledebug", NS_FALSE); ! servPtr->adp.debuginit = Ns_ConfigString(path, "debuginit", "ns_adp_debuginit"); ! servPtr->adp.defaultparser = Ns_ConfigString(path, "defaultparser", "adp"); ! servPtr->adp.cachesize = Ns_ConfigInt(path, "cachesize", 5000*1024); /* *************** *** 502,516 **** path = Ns_ConfigGetPath(server, NULL, "adp", "compress", NULL); ! if (!Ns_ConfigGetBool(path, "enable", &servPtr->adp.compress.enable)) { ! servPtr->adp.compress.enable = ADP_ENABLECOMPRESS_BOOL; ! } ! if (!Ns_ConfigGetInt(path, "level", &n) || n < 1 || n > 9) { ! n = ADP_COMPRESSLEVEL_INT; ! } ! servPtr->adp.compress.level = n; ! if (!Ns_ConfigGetInt(path, "minsize", &n) || n < 0) { ! n = 0; ! } ! servPtr->adp.compress.minsize = n; /* --- 436,442 ---- path = Ns_ConfigGetPath(server, NULL, "adp", "compress", NULL); ! servPtr->adp.compress.enable = Ns_ConfigBool(path, "enable", NS_FALSE); ! servPtr->adp.compress.level = Ns_ConfigIntRange(path, "level", 4, 1, 9); ! servPtr->adp.compress.minsize = Ns_ConfigInt(path, "minsize", 0); /* *************** *** 624,631 **** * before NsQueueConn begins to return NS_ERROR. */ ! ! if (!Ns_ConfigGetInt(path, "maxconnections", &maxconns)) { ! maxconns = SERV_MAXCONNS_INT; ! } connBufPtr = ns_calloc((size_t) maxconns, sizeof(Conn)); for (n = 0; n < maxconns - 1; ++n) { --- 550,555 ---- * before NsQueueConn begins to return NS_ERROR. */ ! ! maxconns = Ns_ConfigIntRange(path, "maxconnections", 100, 1, INT_MAX); connBufPtr = ns_calloc((size_t) maxconns, sizeof(Conn)); for (n = 0; n < maxconns - 1; ++n) { *************** *** 635,670 **** connBufPtr[n].nextPtr = NULL; poolPtr->queue.freePtr = &connBufPtr[0]; ! ! if (!Ns_ConfigGetInt(path, "minthreads", ! &poolPtr->threads.min)) { ! poolPtr->threads.min = SERV_MINTHREADS_INT; ! } ! if (!Ns_ConfigGetInt(path, "maxthreads", ! &poolPtr->threads.max)) { ! poolPtr->threads.max = SERV_MAXTHREADS_INT; ! } ! if (!Ns_ConfigGetInt(path, "threadtimeout", ! &poolPtr->threads.timeout)) { ! poolPtr->threads.timeout = SERV_THREADTIMEOUT_INT; ! } ! ! /* ! * Determine the minimum and maximum number of threads, adjusting the ! * values as needed. The threadtimeout value is the maximum number of ! * seconds a thread will wait for a connection before exiting if the ! * current number of threads is above the minimum. ! */ ! ! if (poolPtr->threads.max > maxconns) { ! Ns_Log(Warning, "serv: cannot have more maxthreads than maxconns: " ! "%d max threads adjusted down to %d max connections", ! poolPtr->threads.max, maxconns); ! poolPtr->threads.max = maxconns; ! } ! if (poolPtr->threads.min > poolPtr->threads.max) { ! Ns_Log(Warning, "serv: cannot have more minthreads than maxthreads: " ! "%d min threads adjusted down to %d max threads", ! poolPtr->threads.min, poolPtr->threads.max); ! poolPtr->threads.min = poolPtr->threads.max; ! } } --- 559,568 ---- connBufPtr[n].nextPtr = NULL; poolPtr->queue.freePtr = &connBufPtr[0]; ! ! poolPtr->threads.max = ! Ns_ConfigIntRange(path, "maxthreads", 10, 0, maxconns); ! poolPtr->threads.min = ! Ns_ConfigIntRange(path, "minthreads", 0, 0, poolPtr->threads.max); ! poolPtr->threads.timeout = ! Ns_ConfigIntRange(path, "threadtimeout", 120, 0, INT_MAX); } Index: queue.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/queue.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** queue.c 1 Aug 2005 16:22:25 -0000 1.6 --- queue.c 2 Oct 2005 22:39:06 -0000 1.7 *************** *** 553,560 **** path = Ns_ConfigGetPath(servPtr->server, NULL, NULL); ! if (!Ns_ConfigGetInt(path, "connsperthread", &cpt)) { ! cpt = SERV_MAXCONNSPERTHREAD_INT; ! } ! ncons = cpt; --- 553,557 ---- path = Ns_ConfigGetPath(servPtr->server, NULL, NULL); ! cpt = Ns_ConfigIntRange(path, "connsperthread", 0, 0, INT_MAX); ncons = cpt; Index: nsconf.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/nsconf.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** nsconf.c 4 Aug 2005 05:29:40 -0000 1.5 --- nsconf.c 2 Oct 2005 22:39:06 -0000 1.6 *************** *** 38,49 **** NS_RCSID("@(#) $Header$"); - /* - * Local functions defined in this file. - */ - static int GetInt(char *key, int def); - static int GetBool(char *key, int def); struct _nsconf nsconf; /* --- 38,45 ---- NS_RCSID("@(#) $Header$"); struct _nsconf nsconf; + /* *************** *** 152,155 **** --- 148,152 ---- int i; Ns_DString ds; + char *path = NS_CONFIG_PARAMETERS; NsUpdateEncodings(); *************** *** 164,168 **** if (!Ns_ConfigGetInt(NS_CONFIG_THREADS, "stacksize", &i)) { ! i = GetInt("stacksize", THREAD_STACKSIZE_INT); } Ns_ThreadStackSize(i); --- 161,165 ---- if (!Ns_ConfigGetInt(NS_CONFIG_THREADS, "stacksize", &i)) { ! i = Ns_ConfigIntRange(path, "stacksize", 64*1024, 0, INT_MAX); } Ns_ThreadStackSize(i); *************** *** 177,182 **** * nsmain.c */ ! ! nsconf.shutdowntimeout = GetInt("shutdowntimeout", SHUTDOWNTIMEOUT_INT); /* --- 174,180 ---- * nsmain.c */ ! ! nsconf.shutdowntimeout = ! Ns_ConfigIntRange(path, "shutdowntimeout", 20, 0, INT_MAX); /* *************** *** 184,188 **** */ ! nsconf.sched.maxelapsed = GetInt("schedmaxelapsed", SCHED_MAXELAPSED_INT); /* --- 182,187 ---- */ ! nsconf.sched.maxelapsed = ! Ns_ConfigIntRange(path, "schedmaxelapsed", 2, 0, INT_MAX); /* *************** *** 190,206 **** */ ! nsconf.backlog = GetInt("listenbacklog", SOCKLISTENBACKLOG_INT); /* * dns.c */ ! ! if (GetBool("dnscache", DNS_CACHE_BOOL)) { ! int max = GetInt("dnscachemaxentries", 100); ! i = GetInt("dnscachetimeout", DNS_TIMEOUT_INT); ! if (max > 0 && i > 0) { ! i *= 60; /* NB: Config minutes, seconds internally. */ ! NsEnableDNSCache(i, max); ! } } --- 189,205 ---- */ ! nsconf.backlog = Ns_ConfigIntRange(path, "listenbacklog", 32, 0, INT_MAX); /* * dns.c */ ! ! if (Ns_ConfigBool(path, "dnscache", NS_TRUE)) { ! int max = Ns_ConfigInt(path, "dnscachemaxentries", 100); ! i = Ns_ConfigInt(path, "dnscachetimeout", 60); ! if (max > 0 && i > 0) { ! i *= 60; /* NB: Config minutes, seconds internally. */ ! NsEnableDNSCache(i, max); ! } } *************** *** 209,259 **** */ ! nsconf.tcl.sharedlibrary = Ns_ConfigGetValue(NS_CONFIG_PARAMETERS, "tcllibrary"); if (nsconf.tcl.sharedlibrary == NULL) { Ns_HomePath(&ds, "modules", "tcl", NULL); nsconf.tcl.sharedlibrary = Ns_DStringExport(&ds); } ! nsconf.tcl.lockoninit = GetBool("tclinitlock", TCL_INITLCK_BOOL); Ns_DStringFree(&ds); } - - - /* - *---------------------------------------------------------------------- - * - * GetInt, GetBool -- - * - * Helper routines for getting int or bool config values, using - * default values if necessary. - * - * Results: - * Int value of 1/0 bool. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - - static int - GetInt(char *key, int def) - { - int i; - - if (!Ns_ConfigGetInt(NS_CONFIG_PARAMETERS, key, &i) || i < 0) { - i = def; - } - return i; - } - - static bool - GetBool(char *key, int def) - { - int i; - - if (!Ns_ConfigGetBool(NS_CONFIG_PARAMETERS, key, &i)) { - i = def; - } - return i; - } --- 208,218 ---- */ ! nsconf.tcl.sharedlibrary = Ns_ConfigGetValue(path, "tcllibrary"); if (nsconf.tcl.sharedlibrary == NULL) { Ns_HomePath(&ds, "modules", "tcl", NULL); nsconf.tcl.sharedlibrary = Ns_DStringExport(&ds); } ! nsconf.tcl.lockoninit = Ns_ConfigBool(path, "tclinitlock", NS_FALSE); Ns_DStringFree(&ds); } Index: driver.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/driver.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** driver.c 2 Aug 2005 04:59:54 -0000 1.20 --- driver.c 2 Oct 2005 22:39:06 -0000 1.21 *************** *** 159,163 **** { char *path,*address, *host, *bindaddr, *defproto, *defserver; ! int i, n, defport, controlFlag; ServerMap *mapPtr; Tcl_HashEntry *hPtr; --- 159,163 ---- { char *path,*address, *host, *bindaddr, *defproto, *defserver; ! int i, n, defport; ServerMap *mapPtr; Tcl_HashEntry *hPtr; *************** *** 271,322 **** drvPtr->opts = init->opts; drvPtr->servPtr = servPtr; ! if (!Ns_ConfigGetInt(path, "bufsize", &n) || n < 1) { ! n = DRV_BUFSIZE_INT; ! } ! drvPtr->bufsize = n; ! if (!Ns_ConfigGetInt(path, "rcvbuf", &n)) { ! n = DRV_RCVBUF_INT; ! } ! drvPtr->rcvbuf = n; ! if (!Ns_ConfigGetInt(path, "sndbuf", &n)) { ! n = DRV_SNDBUF_INT; ! } ! drvPtr->sndbuf = n; ! if (!Ns_ConfigGetInt(path, "sendwait", &n) || n < 1) { ! n = DRV_SNDWAIT_INT; ! } ! drvPtr->sendwait = n; ! if (!Ns_ConfigGetInt(path, "recvwait", &n) || n < 1) { ! n = DRV_RCVWAIT_INT; ! } ! drvPtr->recvwait = n; ! if (!Ns_ConfigGetInt(path, "closewait", &n) || n < 0) { ! n = DRV_CLOSEWAIT_INT; ! } ! drvPtr->closewait = n; ! if (!Ns_ConfigGetInt(path, "keepwait", &n) || n < 0) { ! n = DRV_KEEPWAIT_INT; ! } ! drvPtr->keepwait = n; ! if (!Ns_ConfigGetBool(path, "keepallmethods", &n)) { ! n = DRV_KEEPALLMETHODS_BOOL; ! } ! drvPtr->keepallmethods = n; ! if (!Ns_ConfigGetInt(path, "backlog", &n) || n < 1) { ! n = nsconf.backlog; ! } ! drvPtr->backlog = n; ! if (!Ns_ConfigGetInt(path, "maxinput", &n) || n < 1) { ! n = DRV_MAXINPUT_INT; ! } ! drvPtr->maxinput = _MAX(n, DRV_MININPUT_INT); ! if (!Ns_ConfigGetInt(path, "maxline", &n) || n < 1) { ! n = DRV_MAXLINE_INT; ! } ! drvPtr->maxline = _MAX(n, DRV_MINLINE_INT); ! if (!Ns_ConfigGetInt(path, "maxsize", &n) || n < 1) { ! n = drvPtr->maxinput; ! } ! drvPtr->maxsize = n; /* --- 271,289 ---- drvPtr->opts = init->opts; drvPtr->servPtr = servPtr; ! ! drvPtr->maxinput = Ns_ConfigIntRange(path, "maxinput", 1024*1024, 1024, INT_MAX); ! drvPtr->maxline = Ns_ConfigIntRange(path, "maxline", 4096, 256, INT_MAX); ! drvPtr->maxheaders = Ns_ConfigIntRange(path, "maxheaders", 128, 8, INT_MAX); ! drvPtr->bufsize = Ns_ConfigIntRange(path, "bufsize", 16384, 1024, INT_MAX); ! drvPtr->readahead = Ns_ConfigIntRange(path, "readahead", drvPtr->bufsize, ! drvPtr->bufsize, drvPtr->maxinput); ! drvPtr->sndbuf = Ns_ConfigIntRange(path, "sndbuf", 0, 0, INT_MAX); ! drvPtr->rcvbuf = Ns_ConfigIntRange(path, "rcvbuf", 0, 0, INT_MAX); ! drvPtr->sendwait = Ns_ConfigIntRange(path, "sendwait", 30, 1, INT_MAX); ! drvPtr->recvwait = Ns_ConfigIntRange(path, "recvwait", 30, 1, INT_MAX); ! drvPtr->closewait = Ns_ConfigIntRange(path, "closewait", 2, 0, INT_MAX); ! drvPtr->keepwait = Ns_ConfigIntRange(path, "keepwait", 30, 0, INT_MAX); ! drvPtr->keepallmethods = Ns_ConfigBool(path, "keepallmethods", NS_FALSE); ! drvPtr->backlog = Ns_ConfigIntRange(path, "backlog", 64, 1, INT_MAX); /* *************** *** 324,342 **** * socket handling errors. These all default to Off. */ drvPtr->loggingFlags = 0; ! if (Ns_ConfigGetBool(path, "readtimeoutlogging", &controlFlag) ! && controlFlag) { drvPtr->loggingFlags |= LOGGING_READTIMEOUT; } ! if (Ns_ConfigGetBool(path, "serverrejectlogging", &controlFlag) ! && controlFlag) { drvPtr->loggingFlags |= LOGGING_SERVERREJECT; } ! if (Ns_ConfigGetBool(path, "sockerrorlogging", &controlFlag) ! && controlFlag) { drvPtr->loggingFlags |= LOGGING_SOCKERROR; } ! if (Ns_ConfigGetBool(path, "sockshuterrorlogging", &controlFlag) ! && controlFlag) { drvPtr->loggingFlags |= LOGGING_SOCKSHUTERROR; } --- 291,306 ---- * socket handling errors. These all default to Off. */ + drvPtr->loggingFlags = 0; ! if (Ns_ConfigBool(path, "readtimeoutlogging", NS_FALSE)) { drvPtr->loggingFlags |= LOGGING_READTIMEOUT; } ! if (Ns_ConfigBool(path, "serverrejectlogging", NS_FALSE)) { drvPtr->loggingFlags |= LOGGING_SERVERREJECT; } ! if (Ns_ConfigBool(path, "sockerrorlogging", NS_FALSE)) { drvPtr->loggingFlags |= LOGGING_SOCKERROR; } ! if (Ns_ConfigBool(path, "sockshuterrorlogging", NS_FALSE)) { drvPtr->loggingFlags |= LOGGING_SOCKSHUTERROR; } *************** *** 359,365 **** drvPtr->protocol = ns_strdup(defproto); drvPtr->address = ns_strdup(address); ! if (!Ns_ConfigGetInt(path, "port", &drvPtr->port)) { ! drvPtr->port = defport; ! } drvPtr->location = Ns_ConfigGetValue(path, "location"); if (drvPtr->location != NULL && strstr(drvPtr->location, "://")) { --- 323,327 ---- drvPtr->protocol = ns_strdup(defproto); drvPtr->address = ns_strdup(address); ! drvPtr->port = Ns_ConfigInt(path, "port", defport); drvPtr->location = Ns_ConfigGetValue(path, "location"); if (drvPtr->location != NULL && strstr(drvPtr->location, "://")) { *************** *** 1455,1464 **** /* ! * Use temp file for large content if exceeds configured maxsize */ #ifndef _WIN32 if (reqPtr->coff > 0 && ! reqPtr->length > sockPtr->drvPtr->maxsize && sockPtr->tfd <= 0) { sockPtr->tfd = Ns_GetTemp(); --- 1417,1426 ---- /* ! * Use temp file for content larger than readahead bytes. */ #ifndef _WIN32 if (reqPtr->coff > 0 && ! reqPtr->length > sockPtr->drvPtr->readahead && sockPtr->tfd <= 0) { sockPtr->tfd = Ns_GetTemp(); *************** *** 1619,1623 **** } reqPtr->content = sockPtr->taddr; ! Ns_Log(Debug, "spooling content into temp file, maxsize=%d, filesize=%i", sockPtr->drvPtr->maxsize, sockPtr->tsize); #endif } else { --- 1581,1586 ---- } reqPtr->content = sockPtr->taddr; ! Ns_Log(Debug, "spooling content to file: readahead=%d, filesize=%i", ! sockPtr->drvPtr->readahead, sockPtr->tsize); #endif } else { |