You can subscribe to this list here.
2005 |
Jan
|
Feb
(32) |
Mar
(56) |
Apr
(92) |
May
(39) |
Jun
(226) |
Jul
(98) |
Aug
(66) |
Sep
|
Oct
(153) |
Nov
(43) |
Dec
(42) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(97) |
Feb
(141) |
Mar
(147) |
Apr
(80) |
May
(51) |
Jun
(93) |
Jul
(88) |
Aug
(50) |
Sep
(179) |
Oct
(48) |
Nov
(82) |
Dec
(71) |
2007 |
Jan
(42) |
Feb
(46) |
Mar
(123) |
Apr
(21) |
May
(139) |
Jun
(59) |
Jul
(34) |
Aug
(57) |
Sep
(47) |
Oct
(137) |
Nov
(49) |
Dec
(12) |
2008 |
Jan
(10) |
Feb
(8) |
Mar
(63) |
Apr
(17) |
May
(34) |
Jun
(38) |
Jul
(16) |
Aug
(62) |
Sep
(9) |
Oct
(121) |
Nov
(38) |
Dec
(4) |
2009 |
Jan
|
Feb
(11) |
Mar
(9) |
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
(4) |
Apr
(10) |
May
(1) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
(2) |
Oct
(1) |
Nov
|
Dec
(12) |
2012 |
Jan
(26) |
Feb
(1) |
Mar
(15) |
Apr
(1) |
May
(1) |
Jun
(7) |
Jul
(2) |
Aug
|
Sep
(1) |
Oct
(52) |
Nov
(8) |
Dec
(25) |
2013 |
Jan
(35) |
Feb
(14) |
Mar
(10) |
Apr
(10) |
May
(29) |
Jun
(16) |
Jul
(5) |
Aug
(8) |
Sep
(8) |
Oct
(6) |
Nov
(1) |
Dec
(3) |
2014 |
Jan
(16) |
Feb
(13) |
Mar
(5) |
Apr
(9) |
May
(21) |
Jun
(6) |
Jul
(5) |
Aug
(2) |
Sep
(59) |
Oct
(115) |
Nov
(122) |
Dec
(45) |
2015 |
Jan
(31) |
Feb
(32) |
Mar
(19) |
Apr
(25) |
May
(3) |
Jun
(4) |
Jul
(18) |
Aug
(3) |
Sep
(23) |
Oct
(11) |
Nov
(17) |
Dec
(12) |
2016 |
Jan
(20) |
Feb
(27) |
Mar
(20) |
Apr
(40) |
May
(35) |
Jun
(48) |
Jul
(44) |
Aug
(51) |
Sep
(18) |
Oct
(42) |
Nov
(39) |
Dec
(29) |
2017 |
Jan
(37) |
Feb
(34) |
Mar
(20) |
Apr
(37) |
May
(10) |
Jun
(2) |
Jul
(14) |
Aug
(15) |
Sep
(25) |
Oct
(29) |
Nov
(15) |
Dec
(29) |
2018 |
Jan
(5) |
Feb
(15) |
Mar
(6) |
Apr
(20) |
May
(39) |
Jun
(39) |
Jul
(17) |
Aug
(20) |
Sep
(10) |
Oct
(17) |
Nov
(20) |
Dec
(8) |
2019 |
Jan
(28) |
Feb
(21) |
Mar
(13) |
Apr
(44) |
May
(44) |
Jun
(28) |
Jul
(51) |
Aug
(30) |
Sep
(7) |
Oct
(20) |
Nov
(8) |
Dec
(21) |
2020 |
Jan
(27) |
Feb
(5) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Stephen D. <sd...@us...> - 2005-10-09 23:44:02
|
Update of /cvsroot/naviserver/naviserver/m4 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18251/m4 Added Files: tcl.m4 Log Message: * Makefile: * autogen.sh: New script to run the various autotools to generate the build system. * missing: Add this default automake helper script. * configure.in: Initialise automake, even though we don't use it, so that we can use aclocal to manage our m4 scripts. * aclocal.m4: * acinclude.m4: Contents of aclocal.m4 now moved to acinclude.m4. aclocal.m4 is now autogenerated by the aclocal tool, called from within autogen. * configure: * include/nsconfig.h.in: Remove autogenerated scripts from cvs. New strategy is to call autogen.sh on first checkout to intialise the build environment. * tcl.m4: * m4/tcl.m4: Move into m4 subdirectory. Upgrade to revision 1.74 from Tcl cvs. Fully quote macro names (needs to go upstream). * .cvsignore: * include/.cvsignore: Ignore some new autogenerated build scripts, and some old ones we no longer keep in cvs. --- NEW FILE: tcl.m4 --- # tcl.m4 -- # # This file provides a set of autoconf macros to help TEA-enable # a Tcl extension. # # Copyright (c) 1999-2000 Ajuba Solutions. # Copyright (c) 2002-2005 ActiveState Corporation. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # # RCS: @(#) $Id: tcl.m4,v 1.1 2005/10/09 23:43:58 sdeasey Exp $ AC_PREREQ(2.50) # Possible values for key variables defined: # # TEA_WINDOWINGSYSTEM - win32 aqua x11 (mirrors 'tk windowingsystem') # TEA_PLATFORM - windows unix [...3909 lines suppressed...] # we need TCLSH_PROG defined to get Windows short pathnames AC_REQUIRE([TEA_PROG_TCLSH]) AC_MSG_CHECKING([short pathname for $1 ($2)]) shortpath= case "$2" in *\ *) # Only do this if we need to. shortpath=`echo "puts [[file attributes {$2} -shortname]] ; exit" | ${TCLSH_PROG} 2>/dev/null` ;; esac if test "x${shortpath}" = "x" ; then AC_MSG_RESULT([not changed]) else $1=$shortpath AC_MSG_RESULT([${$1}]) fi fi ]) |
From: Stephen D. <sd...@us...> - 2005-10-09 23:44:02
|
Update of /cvsroot/naviserver/naviserver/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18251/include Modified Files: .cvsignore Removed Files: nsconfig.h.in Log Message: * Makefile: * autogen.sh: New script to run the various autotools to generate the build system. * missing: Add this default automake helper script. * configure.in: Initialise automake, even though we don't use it, so that we can use aclocal to manage our m4 scripts. * aclocal.m4: * acinclude.m4: Contents of aclocal.m4 now moved to acinclude.m4. aclocal.m4 is now autogenerated by the aclocal tool, called from within autogen. * configure: * include/nsconfig.h.in: Remove autogenerated scripts from cvs. New strategy is to call autogen.sh on first checkout to intialise the build environment. * tcl.m4: * m4/tcl.m4: Move into m4 subdirectory. Upgrade to revision 1.74 from Tcl cvs. Fully quote macro names (needs to go upstream). * .cvsignore: * include/.cvsignore: Ignore some new autogenerated build scripts, and some old ones we no longer keep in cvs. Index: .cvsignore =================================================================== RCS file: /cvsroot/naviserver/naviserver/include/.cvsignore,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** .cvsignore 9 Oct 2005 04:39:29 -0000 1.2 --- .cvsignore 9 Oct 2005 23:43:57 -0000 1.3 *************** *** 2,3 **** --- 2,4 ---- Makefile.module nsconfig.h + stamp-h1 --- nsconfig.h.in DELETED --- |
From: Stephen D. <sd...@us...> - 2005-10-09 22:54:46
|
Update of /cvsroot/naviserver/naviserver/m4 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3794/m4 Log Message: Directory /cvsroot/naviserver/naviserver/m4 added to the repository |
From: Stephen D. <sd...@us...> - 2005-10-09 22:27:30
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26895/nsd Modified Files: init.tcl modload.c nsd.h nsmain.c server.c tclcallbacks.c tclcmds.c tclmisc.c Log Message: * nsd/nsd.h: * nsd/modload.c: * nsd/nsmain.c: * nsd/server.c: * nsd/init.tcl: Add new Tcl command ns_moduleload which loads a binary module into the server and calls it's initialising function. Remove NsLoadModules and instead call ns_moduleload from the init.tcl bootstrap. Policy about where modules are located and when they are loaded is now easily accessible to Tcl. * nsd/tclcallbacks.c: * nsd/tclmisc.c: * nsd/tclcmds.c: Add new command ns_atprestartup as a simple wrapper for the C equivalent. Add new command ns_runonce which ensures that the given script is run only once, either globally or per virtual server, during the lifetime of the server process. This simplifies initialisation. Index: tclmisc.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/tclmisc.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** tclmisc.c 30 Jul 2005 03:17:50 -0000 1.12 --- tclmisc.c 9 Oct 2005 22:27:24 -0000 1.13 *************** *** 79,82 **** --- 79,137 ---- *---------------------------------------------------------------------- * + * NsTclRunOnceObjCmd -- + * + * Implements ns_runonce. Run the given script only once. + * + * Results: + * Tcl result. + * + * Side effects: + * Depends on script. + * + *---------------------------------------------------------------------- + */ + + int + NsTclRunOnceObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) + { + NsInterp *itPtr = arg; + CONST char *script; + int new, global = NS_FALSE; + static Tcl_HashTable runTable; + static int initialized; + + Ns_ObjvSpec opts[] = { + {"-global", Ns_ObjvBool, &global, (void *) NS_TRUE}, + {"--", Ns_ObjvBreak, NULL, NULL}, + {NULL, NULL, NULL, NULL} + }; + Ns_ObjvSpec args[] = { + {"script", Ns_ObjvString, &script, NULL}, + {NULL, NULL, NULL, NULL} + }; + if (Ns_ParseObjv(opts, args, interp, 1, objc, objv) != NS_OK) { + return TCL_ERROR; + } + + Ns_MasterLock(); + if (!initialized) { + Tcl_InitHashTable(&runTable, TCL_STRING_KEYS); + initialized = NS_TRUE; + } + (void) Tcl_CreateHashEntry(global ? &runTable : &itPtr->servPtr->tcl.runTable, + script, &new); + Ns_MasterUnlock(); + + if (new) { + return Tcl_Eval(interp, script); + } + + return TCL_OK; + } + + + /* + *---------------------------------------------------------------------- + * * Ns_TclLogErrorInfo -- * Index: tclcallbacks.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/tclcallbacks.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tclcallbacks.c 10 Jun 2005 17:58:39 -0000 1.2 --- tclcallbacks.c 9 Oct 2005 22:27:24 -0000 1.3 *************** *** 268,271 **** --- 268,277 ---- int + NsTclAtPreStartupObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) + { + return AtObjCmd(Ns_RegisterAtPreStartup, interp, objc, objv); + } + + int NsTclAtStartupObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { Index: server.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/server.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** server.c 2 Oct 2005 22:39:06 -0000 1.12 --- server.c 9 Oct 2005 22:27:24 -0000 1.13 *************** *** 292,295 **** --- 292,296 ---- Tcl_IncrRefCount(servPtr->tcl.modules); Ns_RWLockInit(&servPtr->tcl.lock); + Tcl_InitHashTable(&servPtr->tcl.runTable, TCL_STRING_KEYS); servPtr->nsv.nbuckets = Ns_ConfigIntRange(path, "nsvbuckets", 8, 1, INT_MAX); servPtr->nsv.buckets = NsTclCreateBuckets(server, servPtr->nsv.nbuckets); *************** *** 488,493 **** CreatePool(servPtr, Ns_SetKey(set, i)); } - NsLoadModules(server); NsTclInitServer(server); initServPtr = NULL; } --- 489,494 ---- CreatePool(servPtr, Ns_SetKey(set, i)); } NsTclInitServer(server); + NsInitStaticModules(server); initServPtr = NULL; } Index: nsmain.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/nsmain.c,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** nsmain.c 8 Oct 2005 16:37:52 -0000 1.21 --- nsmain.c 9 Oct 2005 22:27:24 -0000 1.22 *************** *** 678,685 **** /* ! * Load non-server modules. */ ! NsLoadModules(NULL); /* --- 678,685 ---- /* ! * Initialize non-server static modules. */ ! NsInitStaticModules(NULL); /* Index: modload.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/modload.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** modload.c 9 Oct 2005 22:14:53 -0000 1.6 --- modload.c 9 Oct 2005 22:27:24 -0000 1.7 *************** *** 195,269 **** *---------------------------------------------------------------------- * ! * NsLoadModules -- * ! * Load all modules for given server. * * Results: ! * None. * * Side effects: ! * Will load and initialize modules. * *---------------------------------------------------------------------- */ ! void ! NsLoadModules(CONST char *server) { ! Ns_Set *modules; ! int i; ! char *file, *module, *init = NULL, *s, *e = NULL; ! Module *modPtr, *nextPtr; ! ! modules = Ns_ConfigGetSection(Ns_ConfigGetPath(server, NULL, ! "modules", NULL)); ! for (i = 0; modules != NULL && i < Ns_SetSize(modules); ++i) { ! module = Ns_SetKey(modules, i); ! file = Ns_SetValue(modules, i); ! ! /* ! * Check for specific module init after filename. ! */ ! ! s = strchr(file, '('); ! if (s == NULL) { ! init = "Ns_ModuleInit"; ! } else { ! *s = '\0'; ! init = s + 1; ! e = strchr(init, ')'); ! if (e != NULL) { ! *e = '\0'; ! } ! } ! ! /* ! * Load the module if it's not the reserved "tcl" name. ! */ ! ! if (!STRIEQ(file, "tcl") ! && Ns_ModuleLoad(server, module, file, init) != NS_OK) { ! Ns_Fatal("modload: %s: failed to load module", file); ! } ! /* ! * Add this module to the server Tcl init list. ! */ ! Ns_TclInitModule(server, module); ! if (s != NULL) { ! *s = '('; ! if (e != NULL) { ! *e = ')'; ! } ! } ! } ! /* ! * Initialize the static modules (if any). Note that a static ! * module could add a new static module and so the loop is ! * repeated until they're all gone. ! */ while (firstPtr != NULL) { --- 195,272 ---- *---------------------------------------------------------------------- * ! * NsTclModuleLoadObjCmd -- * ! * Implements ns_moduleload. Load and initilize a binary module. * * Results: ! * Tcl result. * * Side effects: ! * Will exit the server with a fatal error if module fails to load ! * initialize correctly. * *---------------------------------------------------------------------- */ ! int ! NsTclModuleLoadObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ! NsInterp *itPtr = (NsInterp *) arg; ! CONST char *server, *module, *file, *init = "Ns_ModuleInit"; ! int global = NS_FALSE; ! Ns_ObjvSpec opts[] = { ! {"-global", Ns_ObjvBool, &global, (void *) NS_TRUE}, ! {"-init", Ns_ObjvString, &init, NULL}, ! {"--", Ns_ObjvBreak, NULL, NULL}, ! {NULL, NULL, NULL, NULL} ! }; ! Ns_ObjvSpec args[] = { ! {"module", Ns_ObjvString, &module, NULL}, ! {"file", Ns_ObjvString, &file, NULL}, ! {NULL, NULL, NULL, NULL} ! }; ! if (Ns_ParseObjv(opts, args, interp, 1, objc, objv) != NS_OK) { ! return TCL_ERROR; ! } ! if (Ns_InfoStarted()) { ! Tcl_SetResult(interp, "server already started", TCL_STATIC); ! return TCL_ERROR; ! } ! if (global) { ! server = NULL; ! } else { ! server = itPtr->servPtr->server; ! } ! if (Ns_ModuleLoad(server, module, file, init) != NS_OK) { ! Ns_Fatal("modload: failed to load module '%s'", file); ! } ! return TCL_OK; ! } ! ! /* ! *---------------------------------------------------------------------- ! * ! * NsInitStaticModules -- ! * ! * Initialize static modules for given server, or global static ! * modules if no server given. ! * ! * Results: ! * None. ! * ! * Side effects: ! * Static modules may register new static modules, so we loop ! * until they're all gone. ! * ! *---------------------------------------------------------------------- ! */ ! void ! NsInitStaticModules(CONST char *server) ! { ! Module *modPtr, *nextPtr; while (firstPtr != NULL) { Index: nsd.h =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/nsd.h,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** nsd.h 2 Oct 2005 22:39:06 -0000 1.34 --- nsd.h 9 Oct 2005 22:27:24 -0000 1.35 *************** *** 637,640 **** --- 637,641 ---- int epoch; Tcl_Obj *modules; + Tcl_HashTable runTable; CONST char **errorLogHeaders; } tcl; *************** *** 937,940 **** --- 938,942 ---- extern void NsTclInitServer(CONST char *server) NS_GNUC_NONNULL(1); + extern void NsInitStaticModules(CONST char *server); extern NsInterp *NsGetInterpData(Tcl_Interp *interp) NS_GNUC_NONNULL(1); *************** *** 942,946 **** NS_GNUC_NONNULL(1); - extern void NsLoadModules(CONST char *server); extern struct Bucket *NsTclCreateBuckets(char *server, int nbuckets); --- 944,947 ---- Index: tclcmds.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/tclcmds.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** tclcmds.c 8 Oct 2005 12:06:07 -0000 1.20 --- tclcmds.c 9 Oct 2005 22:27:24 -0000 1.21 *************** *** 66,69 **** --- 66,70 ---- NsTclAtCloseObjCmd, NsTclAtExitObjCmd, + NsTclAtPreStartupObjCmd, NsTclAtShutdownObjCmd, NsTclAtSignalObjCmd, *************** *** 102,105 **** --- 103,107 ---- NsTclLogObjCmd, NsTclLogRollObjCmd, + NsTclModuleLoadObjCmd, NsTclModulePathObjCmd, NsTclMutexObjCmd, *************** *** 139,142 **** --- 141,145 ---- NsTclReturnUnauthorizedObjCmd, NsTclRollFileObjCmd, + NsTclRunOnceObjCmd, NsTclSHA1ObjCmd, NsTclSchedDailyObjCmd, *************** *** 233,236 **** --- 236,240 ---- {"ns_after", NULL, NsTclAfterObjCmd}, {"ns_atexit", NULL, NsTclAtExitObjCmd}, + {"ns_atprestartup", NULL, NsTclAtPreStartupObjCmd}, {"ns_atshutdown", NULL, NsTclAtShutdownObjCmd}, {"ns_atsignal", NULL, NsTclAtSignalObjCmd}, *************** *** 374,377 **** --- 378,382 ---- {"ns_ictl", NULL, NsTclICtlObjCmd}, {"ns_library", NsTclLibraryCmd, NULL}, + {"ns_moduleload", NULL, NsTclModuleLoadObjCmd}, {"ns_puts", NULL, NsTclAdpPutsObjCmd}, {"ns_register_adp", NULL, NsTclRegisterAdpObjCmd}, *************** *** 393,396 **** --- 398,402 ---- {"ns_returnredirect", NULL, NsTclReturnRedirectObjCmd}, {"ns_returnunauthorized", NULL, NsTclReturnUnauthorizedObjCmd}, + {"ns_runonce", NULL, NsTclRunOnceObjCmd}, {"ns_server", NULL, NsTclServerObjCmd}, {"ns_setcookie", NULL, NsTclSetCookieObjCmd}, Index: init.tcl =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/init.tcl,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** init.tcl 30 Jul 2005 03:35:10 -0000 1.3 --- init.tcl 9 Oct 2005 22:27:24 -0000 1.4 *************** *** 612,615 **** --- 612,644 ---- } + # + # Load global binary modules. + # + + ns_runonce -global { + ns_atprestartup { + set modules [ns_configsection ns/modules] + if {![string equal $modules ""]} { + foreach {module file} [ns_set array $modules] { + ns_moduleload -global $module $file + } + } + } + } + + # + # Load binary modules for this server. + # + + set modules [ns_configsection ns/server/[ns_info server]/modules] + if {![string equal $modules ""]} { + foreach {module file} [ns_set array $modules] { + if {![string equal [string tolower $module] tcl]} { + ns_moduleload $module $file + } + ns_ictl addmodule $module + } + } + # *************** *** 646,651 **** # set srv [ns_info server] ! if {![nsv_exists _ns_eval_jobq $srv]} { ! nsv_set _ns_eval_jobq $srv [ns_job create "ns_eval_q:$srv" 1] } --- 675,680 ---- # set srv [ns_info server] ! ns_runonce { ! ns_job create "ns_eval_q:$srv" 1 } |
From: Stephen D. <sd...@us...> - 2005-10-09 22:27:29
|
Update of /cvsroot/naviserver/naviserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26895 Modified Files: ChangeLog Log Message: * nsd/nsd.h: * nsd/modload.c: * nsd/nsmain.c: * nsd/server.c: * nsd/init.tcl: Add new Tcl command ns_moduleload which loads a binary module into the server and calls it's initialising function. Remove NsLoadModules and instead call ns_moduleload from the init.tcl bootstrap. Policy about where modules are located and when they are loaded is now easily accessible to Tcl. * nsd/tclcallbacks.c: * nsd/tclmisc.c: * nsd/tclcmds.c: Add new command ns_atprestartup as a simple wrapper for the C equivalent. Add new command ns_runonce which ensures that the given script is run only once, either globally or per virtual server, during the lifetime of the server process. This simplifies initialisation. Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v retrieving revision 1.205 retrieving revision 1.206 diff -C2 -d -r1.205 -r1.206 *** ChangeLog 9 Oct 2005 22:14:52 -0000 1.205 --- ChangeLog 9 Oct 2005 22:27:23 -0000 1.206 *************** *** 1,4 **** --- 1,21 ---- 2005-10-09 Stephen Deasey <sd...@us...> + * nsd/nsd.h: + * nsd/modload.c: + * nsd/nsmain.c: + * nsd/server.c: + * nsd/init.tcl: Add new Tcl command ns_moduleload which loads a + binary module into the server and calls it's initialising + function. Remove NsLoadModules and instead call ns_moduleload + from the init.tcl bootstrap. Policy about where modules are + located and when they are loaded is now easily accessible to Tcl. + * nsd/tclcallbacks.c: + * nsd/tclmisc.c: + * nsd/tclcmds.c: Add new command ns_atprestartup as a simple + wrapper for the C equivalent. Add new command ns_runonce which + ensures that the given script is run only once, either globally or + per virtual server, during the lifetime of the server process. + This simplifies initialisation. + * include/ns.h: * include/nsthread.h: MIN and MAX are defined after all, in |
From: Stephen D. <sd...@us...> - 2005-10-09 22:15:02
|
Update of /cvsroot/naviserver/naviserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22477 Modified Files: ChangeLog Log Message: * include/ns.h: * include/nsthread.h: MIN and MAX are defined after all, in sys/param.h. Include this header. * nsd/modload.c: Don't delete interp, de-allocate. Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v retrieving revision 1.204 retrieving revision 1.205 diff -C2 -d -r1.204 -r1.205 *** ChangeLog 9 Oct 2005 06:09:03 -0000 1.204 --- ChangeLog 9 Oct 2005 22:14:52 -0000 1.205 *************** *** 1,2 **** --- 1,9 ---- + 2005-10-09 Stephen Deasey <sd...@us...> + + * include/ns.h: + * include/nsthread.h: MIN and MAX are defined after all, in + sys/param.h. Include this header. + * nsd/modload.c: Don't delete interp, de-allocate. + 2005-10-08 Stephen Deasey <sd...@us...> |
From: Stephen D. <sd...@us...> - 2005-10-09 22:14:59
|
Update of /cvsroot/naviserver/naviserver/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22477/include Modified Files: ns.h nsthread.h Log Message: * include/ns.h: * include/nsthread.h: MIN and MAX are defined after all, in sys/param.h. Include this header. * nsd/modload.c: Don't delete interp, de-allocate. Index: ns.h =================================================================== RCS file: /cvsroot/naviserver/naviserver/include/ns.h,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** ns.h 9 Oct 2005 04:42:30 -0000 1.52 --- ns.h 9 Oct 2005 22:14:53 -0000 1.53 *************** *** 250,259 **** #define STREQ(a,b) (((*a) == (*b)) && (strcmp((a),(b)) == 0)) #define STRIEQ(a,b) (strcasecmp((a),(b)) == 0) - #ifndef MIN - # define MIN(x,y) ((x) > (y) ? (y) : (x)) - #endif - #ifndef MAX - # define MAX(x,y) ((x) > (y) ? (x) : (y)) - #endif #define Ns_IndexCount(X) ((X)->n) #define Ns_ListPush(elem,list) ((list)=Ns_ListCons((elem),(list))) --- 250,253 ---- Index: nsthread.h =================================================================== RCS file: /cvsroot/naviserver/naviserver/include/nsthread.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** nsthread.h 30 Jul 2005 04:24:34 -0000 1.9 --- nsthread.h 9 Oct 2005 22:14:53 -0000 1.10 *************** *** 144,147 **** --- 144,150 ---- #include <inttypes.h> #endif + #ifdef HAVE_SYS_PARAM_H + #include <sys/param.h> + #endif /* |
From: Stephen D. <sd...@us...> - 2005-10-09 22:14:59
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22477/nsd Modified Files: modload.c Log Message: * include/ns.h: * include/nsthread.h: MIN and MAX are defined after all, in sys/param.h. Include this header. * nsd/modload.c: Don't delete interp, de-allocate. Index: modload.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/modload.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** modload.c 9 Oct 2005 05:41:44 -0000 1.5 --- modload.c 9 Oct 2005 22:14:53 -0000 1.6 *************** *** 169,173 **** if (status != TCL_OK) { Ns_Log(Error, "modload: %s: %s", file, Tcl_GetStringResult(interp)); ! Tcl_DeleteInterp(interp); return NS_ERROR; } --- 169,173 ---- if (status != TCL_OK) { Ns_Log(Error, "modload: %s: %s", file, Tcl_GetStringResult(interp)); ! Ns_TclDeAllocateInterp(interp); return NS_ERROR; } |
From: Stephen D. <sd...@us...> - 2005-10-09 06:09:16
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29407/nsd Modified Files: rollfile.c tclimg.c Log Message: * nsd/rollfile.c (Ns_PurgeFiles): Quiet compiler complaints about an uninitialised variable, which was fine. Add missing error return statement. * nsd/tclimg.c (NsTclGifSizeObjCmd): Clarify signedness of character comparisons to quiten compiler. Index: rollfile.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/rollfile.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** rollfile.c 8 Oct 2005 12:06:07 -0000 1.5 --- rollfile.c 9 Oct 2005 06:09:03 -0000 1.6 *************** *** 171,175 **** Ns_PurgeFiles(CONST char *file, int max) { ! File *files, *fiPtr; int ii, nfiles, status = NS_ERROR; --- 171,175 ---- Ns_PurgeFiles(CONST char *file, int max) { ! File *fiPtr, *files = NULL; int ii, nfiles, status = NS_ERROR; *************** *** 182,185 **** --- 182,186 ---- Ns_Log(Error, "rollfile: failed to match files '%s': %s", file, strerror(Tcl_GetErrno())); + return NS_ERROR; } Index: tclimg.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/tclimg.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tclimg.c 8 Oct 2005 12:06:07 -0000 1.4 --- tclimg.c 9 Oct 2005 06:09:03 -0000 1.5 *************** *** 69,74 **** Tcl_Obj *CONST objv[]) { ! unsigned char buf[0x300], count; ! char *file; int depth, colormap, dx, dy, status; Tcl_Channel chan; --- 69,74 ---- Tcl_Obj *CONST objv[]) { ! char buf[0x300], *file; ! unsigned char count; int depth, colormap, dx, dy, status; Tcl_Channel chan; *************** *** 101,106 **** } ! if (strncmp((char *) buf, "GIF87a", 6) && ! strncmp((char *) buf, "GIF89a", 6)) { badfile: Tcl_AppendResult(interp, "bad gif file \"", file, "\"", NULL); --- 101,106 ---- } ! if (strncmp(buf, "GIF87a", 6) && ! strncmp(buf, "GIF89a", 6)) { badfile: Tcl_AppendResult(interp, "bad gif file \"", file, "\"", NULL); *************** *** 112,120 **** } ! depth = 1 << ((buf[4] & 0x7) + 1); ! colormap = (buf[4] & 0x80 ? 1 : 0); if (colormap) { ! if (Tcl_Read(chan, buf, (size_t)(3*depth)) != (3*depth)) { goto readfail; } --- 112,120 ---- } ! depth = 1 << ((((unsigned char) buf[4]) & 0x7) + 1); ! colormap = (((unsigned char) buf[4]) & 0x80 ? 1 : 0); if (colormap) { ! if (Tcl_Read(chan, buf, (size_t) (3*depth)) != (3*depth)) { goto readfail; } *************** *** 149,154 **** } ! dx = 0x100 * buf[5] + buf[4]; ! dy = 0x100 * buf[7] + buf[6]; if (AppendObjDims(interp, dx, dy) != TCL_OK) { --- 149,154 ---- } ! dx = 0x100 * ((unsigned char) buf[5]) + ((unsigned char) buf[4]); ! dy = 0x100 * ((unsigned char) buf[7]) + ((unsigned char) buf[6]); if (AppendObjDims(interp, dx, dy) != TCL_OK) { |
From: Stephen D. <sd...@us...> - 2005-10-09 06:09:15
|
Update of /cvsroot/naviserver/naviserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29407 Modified Files: ChangeLog Log Message: * nsd/rollfile.c (Ns_PurgeFiles): Quiet compiler complaints about an uninitialised variable, which was fine. Add missing error return statement. * nsd/tclimg.c (NsTclGifSizeObjCmd): Clarify signedness of character comparisons to quiten compiler. Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v retrieving revision 1.203 retrieving revision 1.204 diff -C2 -d -r1.203 -r1.204 *** ChangeLog 9 Oct 2005 05:41:44 -0000 1.203 --- ChangeLog 9 Oct 2005 06:09:03 -0000 1.204 *************** *** 1,4 **** --- 1,10 ---- 2005-10-08 Stephen Deasey <sd...@us...> + * nsd/rollfile.c (Ns_PurgeFiles): Quiet compiler complaints about + an uninitialised variable, which was fine. Add missing error + return statement. + * nsd/tclimg.c (NsTclGifSizeObjCmd): Clarify signedness of + character comparisons to quiten compiler. + * nsd/modload.c (Ns_ModuleLoad): Quiet compiler complaints about pointer aliasing. Allocate interp from per-thread cache. |
From: Stephen D. <sd...@us...> - 2005-10-09 05:41:56
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24749/nsd Modified Files: modload.c Log Message: * nsd/modload.c (Ns_ModuleLoad): Quiet compiler complaints about pointer aliasing. Allocate interp from per-thread cache. Index: modload.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/modload.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** modload.c 8 Oct 2005 12:06:07 -0000 1.4 --- modload.c 9 Oct 2005 05:41:44 -0000 1.5 *************** *** 141,166 **** CONST char *init) { Ns_ModuleInitProc *initProc = NULL; int status, *verPtr = NULL; ! Tcl_Obj *path; Tcl_Interp *interp; Tcl_LoadHandle lh; ! Tcl_FSUnloadFileProc *uPtr = NULL; Ns_Log(Notice, "modload: loading %s", file); ! path = Tcl_NewStringObj(file, -1); ! Tcl_IncrRefCount(path); ! if (Tcl_FSGetNormalizedPath(NULL, path) == NULL) { ! Tcl_DecrRefCount(path); Ns_Log(Error, "modload: %s: invalid path", file); return NS_ERROR; } ! interp = Tcl_CreateInterp(); ! status = Tcl_FSLoadFile(interp, path, init, "Ns_ModuleVersion", ! (Tcl_PackageInitProc**)&initProc, ! (Tcl_PackageInitProc**)&verPtr, &lh, &uPtr); ! Tcl_DecrRefCount(path); if (status != TCL_OK) { Ns_Log(Error, "modload: %s: %s", file, Tcl_GetStringResult(interp)); --- 141,170 ---- CONST char *init) { + Tcl_PackageInitProc *tclInitProc = NULL, *tclVerProc = NULL; Ns_ModuleInitProc *initProc = NULL; int status, *verPtr = NULL; ! Tcl_Obj *pathObj; Tcl_Interp *interp; Tcl_LoadHandle lh; ! Tcl_FSUnloadFileProc *uPtr; Ns_Log(Notice, "modload: loading %s", file); ! pathObj = Tcl_NewStringObj(file, -1); ! Tcl_IncrRefCount(pathObj); ! if (Tcl_FSGetNormalizedPath(NULL, pathObj) == NULL) { ! Tcl_DecrRefCount(pathObj); Ns_Log(Error, "modload: %s: invalid path", file); return NS_ERROR; } ! interp = Ns_TclAllocateInterp(server); ! if (interp == NULL) { ! Ns_Log(Error, "modload: invalid server name: '%s'", server); ! return NS_ERROR; ! } ! status = Tcl_FSLoadFile(interp, pathObj, init, "Ns_ModuleVersion", ! &tclInitProc, &tclVerProc, &lh, &uPtr); ! Tcl_DecrRefCount(pathObj); if (status != TCL_OK) { Ns_Log(Error, "modload: %s: %s", file, Tcl_GetStringResult(interp)); *************** *** 168,172 **** return NS_ERROR; } ! Tcl_DeleteInterp(interp); if (initProc == NULL) { Ns_Log(Error, "modload: %s: %s: symbol not found", file, init); --- 172,180 ---- return NS_ERROR; } ! Ns_TclDeAllocateInterp(interp); ! ! initProc = (Ns_ModuleInitProc *) tclInitProc; ! verPtr = (int *) tclVerProc; ! if (initProc == NULL) { Ns_Log(Error, "modload: %s: %s: symbol not found", file, init); |
From: Stephen D. <sd...@us...> - 2005-10-09 05:41:56
|
Update of /cvsroot/naviserver/naviserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24749 Modified Files: ChangeLog Log Message: * nsd/modload.c (Ns_ModuleLoad): Quiet compiler complaints about pointer aliasing. Allocate interp from per-thread cache. Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v retrieving revision 1.202 retrieving revision 1.203 diff -C2 -d -r1.202 -r1.203 *** ChangeLog 9 Oct 2005 04:42:30 -0000 1.202 --- ChangeLog 9 Oct 2005 05:41:44 -0000 1.203 *************** *** 1,4 **** --- 1,7 ---- 2005-10-08 Stephen Deasey <sd...@us...> + * nsd/modload.c (Ns_ModuleLoad): Quiet compiler complaints about + pointer aliasing. Allocate interp from per-thread cache. + * include/ns.h: * nsd/config.c: |
From: Stephen D. <sd...@us...> - 2005-10-09 04:42:43
|
Update of /cvsroot/naviserver/naviserver/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14787/include Modified Files: ns.h Log Message: * include/ns.h: * nsd/config.c: * nsd/driver.c: Add definition of MIN and MAX macros used by fastpath.c if not already defined, which aren't standard on e.g. Linux. Convert config.c and driver.c to use this common definition. Index: ns.h =================================================================== RCS file: /cvsroot/naviserver/naviserver/include/ns.h,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** ns.h 8 Oct 2005 12:06:07 -0000 1.51 --- ns.h 9 Oct 2005 04:42:30 -0000 1.52 *************** *** 250,253 **** --- 250,259 ---- #define STREQ(a,b) (((*a) == (*b)) && (strcmp((a),(b)) == 0)) #define STRIEQ(a,b) (strcasecmp((a),(b)) == 0) + #ifndef MIN + # define MIN(x,y) ((x) > (y) ? (y) : (x)) + #endif + #ifndef MAX + # define MAX(x,y) ((x) > (y) ? (x) : (y)) + #endif #define Ns_IndexCount(X) ((X)->n) #define Ns_ListPush(elem,list) ((list)=Ns_ListCons((elem),(list))) |
From: Stephen D. <sd...@us...> - 2005-10-09 04:42:43
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14787/nsd Modified Files: config.c driver.c Log Message: * include/ns.h: * nsd/config.c: * nsd/driver.c: Add definition of MIN and MAX macros used by fastpath.c if not already defined, which aren't standard on e.g. Linux. Convert config.c and driver.c to use this common definition. Index: driver.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/driver.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** driver.c 8 Oct 2005 12:06:07 -0000 1.22 --- driver.c 9 Oct 2005 04:42:30 -0000 1.23 *************** *** 38,43 **** NS_RCSID("@(#) $Header$"); - #define _MAX(x,y) ((x) > (y) ? (x) : (y)) - #define _MIN(x,y) ((x) > (y) ? (y) : (x)) /* --- 38,41 ---- *************** *** 1441,1445 **** if (sockPtr->tfd > 0) { buf.iov_base = tbuf; ! buf.iov_len = _MIN(nread,sizeof(tbuf)); } else { Tcl_DStringSetLength(bufPtr, len + nread); --- 1439,1443 ---- if (sockPtr->tfd > 0) { buf.iov_base = tbuf; ! buf.iov_len = MIN(nread, sizeof(tbuf)); } else { Tcl_DStringSetLength(bufPtr, len + nread); Index: config.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/config.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** config.c 8 Oct 2005 12:06:07 -0000 1.5 --- config.c 9 Oct 2005 04:42:30 -0000 1.6 *************** *** 40,45 **** #define ISSLASH(c) ((c) == '/' || (c) == '\\') - #define _MAX(x,y) ((x) > (y) ? (x) : (y)) - #define _MIN(x,y) ((x) > (y) ? (y) : (x)) /* --- 40,43 ---- *************** *** 165,170 **** value = Ns_ConfigInt(section, key, def); ! value = _MAX(value, min); ! value = _MIN(value, max); return value; --- 163,168 ---- value = Ns_ConfigInt(section, key, def); ! value = MAX(value, min); ! value = MIN(value, max); return value; |
From: Stephen D. <sd...@us...> - 2005-10-09 04:42:42
|
Update of /cvsroot/naviserver/naviserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14787 Modified Files: ChangeLog Log Message: * include/ns.h: * nsd/config.c: * nsd/driver.c: Add definition of MIN and MAX macros used by fastpath.c if not already defined, which aren't standard on e.g. Linux. Convert config.c and driver.c to use this common definition. Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v retrieving revision 1.201 retrieving revision 1.202 diff -C2 -d -r1.201 -r1.202 *** ChangeLog 9 Oct 2005 04:39:29 -0000 1.201 --- ChangeLog 9 Oct 2005 04:42:30 -0000 1.202 *************** *** 1,4 **** --- 1,11 ---- 2005-10-08 Stephen Deasey <sd...@us...> + * include/ns.h: + * nsd/config.c: + * nsd/driver.c: Add definition of MIN and MAX macros used by + fastpath.c if not already defined, which aren't standard on + e.g. Linux. Convert config.c and driver.c to use this common + definition. + * include/.cvsignore: Ignore generated nsconfig.h. |
From: Stephen D. <sd...@us...> - 2005-10-09 04:39:37
|
Update of /cvsroot/naviserver/naviserver/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14391/include Modified Files: .cvsignore Log Message: Ignore generated nsconfig.h. Index: .cvsignore =================================================================== RCS file: /cvsroot/naviserver/naviserver/include/.cvsignore,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** .cvsignore 1 Oct 2005 19:50:43 -0000 1.1 --- .cvsignore 9 Oct 2005 04:39:29 -0000 1.2 *************** *** 1,2 **** --- 1,3 ---- Makefile.global Makefile.module + nsconfig.h |
From: Stephen D. <sd...@us...> - 2005-10-09 04:39:37
|
Update of /cvsroot/naviserver/naviserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14391 Modified Files: ChangeLog Log Message: Ignore generated nsconfig.h. Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v retrieving revision 1.200 retrieving revision 1.201 diff -C2 -d -r1.200 -r1.201 *** ChangeLog 8 Oct 2005 16:27:03 -0000 1.200 --- ChangeLog 9 Oct 2005 04:39:29 -0000 1.201 *************** *** 1,2 **** --- 1,6 ---- + 2005-10-08 Stephen Deasey <sd...@us...> + + * include/.cvsignore: Ignore generated nsconfig.h. + 2005-10-08 Zoran Vasiljevic <vas...@us...> |
From: Zoran V. <vas...@us...> - 2005-10-08 22:04:07
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31171/nsd Modified Files: dns.c Log Message: Fixed GetHost to compile in Linux Index: dns.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/dns.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** dns.c 8 Oct 2005 09:26:19 -0000 1.8 --- dns.c 8 Oct 2005 22:03:55 -0000 1.9 *************** *** 259,266 **** static Ns_Cs cs; Ns_CsEnter(&cs); - #endif memset(&sa, 0, sizeof(struct sockaddr_in)); - sa.sin_family = AF_INET; sa.sin_len = sizeof(struct sockaddr_in); sa.sin_addr.s_addr = inet_addr(addr); result = getnameinfo((const struct sockaddr *) &sa, --- 259,268 ---- static Ns_Cs cs; Ns_CsEnter(&cs); memset(&sa, 0, sizeof(struct sockaddr_in)); sa.sin_len = sizeof(struct sockaddr_in); + #else + memset(&sa, 0, sizeof(struct sockaddr_in)); + #endif + sa.sin_family = AF_INET; sa.sin_addr.s_addr = inet_addr(addr); result = getnameinfo((const struct sockaddr *) &sa, |
From: Zoran V. <vas...@us...> - 2005-10-08 16:37:59
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28277/nsd Modified Files: nsmain.c Log Message: Tightened check on process existence in WaitSIGALRMHandler Index: nsmain.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/nsmain.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** nsmain.c 8 Oct 2005 16:26:25 -0000 1.20 --- nsmain.c 8 Oct 2005 16:37:52 -0000 1.21 *************** *** 1177,1181 **** WatchdogSIGALRMHandler(int sig) { ! if (kill((pid_t) nsconf.pid, 0)) { SysLog(LOG_WARNING, "watchdog: server %d terminated?", nsconf.pid); nsconf.pid = 0; --- 1177,1181 ---- WatchdogSIGALRMHandler(int sig) { ! if (kill((pid_t) nsconf.pid, 0) && errno == ESRCH) { SysLog(LOG_WARNING, "watchdog: server %d terminated?", nsconf.pid); nsconf.pid = 0; |
From: Zoran V. <vas...@us...> - 2005-10-08 16:27:11
|
Update of /cvsroot/naviserver/naviserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26100 Modified Files: ChangeLog Log Message: See file. Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v retrieving revision 1.199 retrieving revision 1.200 diff -C2 -d -r1.199 -r1.200 *** ChangeLog 8 Oct 2005 12:14:33 -0000 1.199 --- ChangeLog 8 Oct 2005 16:27:03 -0000 1.200 *************** *** 39,42 **** --- 39,51 ---- * tests/http_byteranges.test: + * nsd/nsmain.c: added alarm of 300 seconds for the watchdog + on Darwin. When the alarm triggers, the watchdog re-checks + the existence of the server process (by sending kill 0) and + clears nsconf-pid value if the process is gone. This is the + signal to re-start the server again. All this mess is needed + because under some strange circumstances, the WaitForServer() + never returns, although the server process is already gone. + This smells of a broken signal delivery to me... + 2005-10-05 Zoran Vasiljevic <vas...@us...> |
From: Zoran V. <vas...@us...> - 2005-10-08 16:26:34
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25813/nsd Modified Files: nsmain.c Log Message: Added alarm of 300 seconds for the watchdog on Darwin. When the alarm triggers, the watchdog re-checks the existence of the server process (by sending kill 0) and clears nsconf-pid value if the process is gone. This is the signal to re-start the server again. All this mess is needed because under some strange circumstances, the WaitForServer() never returns although the server process is already gone. This smells of a broken signal delivery to me... Index: nsmain.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/nsmain.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** nsmain.c 8 Oct 2005 12:06:07 -0000 1.19 --- nsmain.c 8 Oct 2005 16:26:25 -0000 1.20 *************** *** 59,62 **** --- 59,68 ---- #define MAX_NUM_RESTARTS 256 /* Quit after somany unsuccessful restarts */ + #ifdef __APPLE__ + # define WAKEUP_IN_SECONDS 600 /* Wakeup watchdog after somuch seconds */ + #else + # define WAKEUP_IN_SECONDS 0 /* Wakeup watchdog after somuch seconds */ + #endif + /* * Local functions defined in this file. *************** *** 65,69 **** static int StartWatchedServer(void); static void SysLog(int priority, char *fmt, ...); ! static void WatchdogSigtermHandler(int sig); static int WaitForServer(); --- 71,76 ---- static int StartWatchedServer(void); static void SysLog(int priority, char *fmt, ...); ! static void WatchdogSIGTERMHandler(int sig); ! static void WatchdogSIGALRMHandler(int sig); static int WaitForServer(); *************** *** 1128,1132 **** *---------------------------------------------------------------------- * ! * WatchdogSigtermHandler -- * * Handle SIGTERM and pass to server process. --- 1135,1139 ---- *---------------------------------------------------------------------- * ! * WatchdogSIGTERMHandler -- * * Handle SIGTERM and pass to server process. *************** *** 1142,1150 **** static void ! WatchdogSigtermHandler(int sig) { kill((pid_t) nsconf.pid, sig); watchdogExit = 1; } /* --- 1149,1186 ---- static void ! WatchdogSIGTERMHandler(int sig) { kill((pid_t) nsconf.pid, sig); watchdogExit = 1; } + + + /* + *---------------------------------------------------------------------- + * + * WatchdogSIGALRMHandler -- + * + * Handle SIGALRM to check existence of the nsconf.pid server + * process. + * + * Results: + * None. + * + * Side effects: + * Zero-out the nsconf.pid element indicating absence of the + * server process. + * + *---------------------------------------------------------------------- + */ + + static void + WatchdogSIGALRMHandler(int sig) + { + if (kill((pid_t) nsconf.pid, 0)) { + SysLog(LOG_WARNING, "watchdog: server %d terminated?", nsconf.pid); + nsconf.pid = 0; + } + } + /* *************** *** 1168,1180 **** WaitForServer() { ! int ret, status; ! pid_t pid; ! char *msg; do { pid = waitpid(nsconf.pid, &status, 0); ! } while (pid == -1 && errno == EINTR); ! if (WIFEXITED(status)) { ret = WEXITSTATUS(status); msg = "exited"; --- 1204,1219 ---- WaitForServer() { ! int ret, status; ! pid_t pid; ! char *msg; do { pid = waitpid(nsconf.pid, &status, 0); ! } while (pid == -1 && errno == EINTR && nsconf.pid); ! if (nsconf.pid == 0) { ! msg = "terminated"; ! ret = -1; /* Alarm handler found no server present? */ ! } else if (WIFEXITED(status)) { ret = WEXITSTATUS(status); msg = "exited"; *************** *** 1213,1217 **** StartWatchedServer(void) { ! unsigned int setSigterm = 0, startTime, numRestarts = 0, restartWait = 0; SysLog(LOG_NOTICE, "watchdog: started."); --- 1252,1257 ---- StartWatchedServer(void) { ! unsigned int setSigHandlers=0, startTime, numRestarts=0, restartWait=0; ! struct itimerval timer; SysLog(LOG_NOTICE, "watchdog: started."); *************** *** 1240,1250 **** /* * Register SIGTERM handler so we can gracefully stop the server. ! * The watchdog will exit w/o stopping the server if got signalled ! * with any other signal, though. */ ! if (setSigterm == 0) { ! setSigterm = 1; ! ns_signal(SIGTERM, WatchdogSigtermHandler); } --- 1280,1301 ---- /* * Register SIGTERM handler so we can gracefully stop the server. ! * The watchdog passes the signal to the server, if possible. ! * ! * Register SIGALRM handler to wake up the watchdog to check if ! * the server is still present. This tries to solve issues with ! * signal delivery on some systems where waitpid() fails to report ! * process exitus (i.e. it is just stuck). */ ! if (setSigHandlers == 0) { ! setSigHandlers = 1; ! timer.it_interval.tv_sec = WAKEUP_IN_SECONDS; ! timer.it_value.tv_sec = timer.it_interval.tv_sec; ! timer.it_value.tv_usec = timer.it_interval.tv_usec = 0; ! if (timer.it_value.tv_sec || timer.it_value.tv_usec) { ! setitimer(ITIMER_REAL, &timer, NULL); ! ns_signal(SIGALRM, WatchdogSIGALRMHandler); ! } ! ns_signal(SIGTERM, WatchdogSIGTERMHandler); } |
From: Zoran V. <vas...@us...> - 2005-10-08 12:14:43
|
Update of /cvsroot/naviserver/naviserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10000 Modified Files: ChangeLog Log Message: See file Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v retrieving revision 1.198 retrieving revision 1.199 diff -C2 -d -r1.198 -r1.199 *** ChangeLog 8 Oct 2005 09:32:48 -0000 1.198 --- ChangeLog 8 Oct 2005 12:14:33 -0000 1.199 *************** *** 16,19 **** --- 16,42 ---- "nonDarwin". + * include/ns.h: Use (where possible) Tcl wrappers when + * include/nscheck.h: accessing files on the filesystem. + * nsd/adpeval.c: Exceptions are: temp files and logs. + * nsd/adprequest.c: Special cases are in fastpath.c, adpeval.c, + * nsd/binder.c: adprequest.c and urlopen.c where the native + * nsd/config.c: call is performed first, and if failed, the + * nsd/conn.c: Tcl companion is tried next. This way the + * nsd/driver.c: simple but effective VFS fallback is assured. + * nsd/fastpath.c: + * nsd/init.c: Status before those changes is tagged as + * nsd/log.c: "before-tclvfs" in order to simplify backoff + * nsd/modload.c: if needed. + * nsd/nsconf.c: + * nsd/nsmain.c: + * nsd/pidfile.c: + * nsd/rollfile.c: + * nsd/tclcmds.c: + * nsd/tclfile.c: + * nsd/tclimg.c: + * nsd/urlopen.c: + * tcl/compat.tcl: + * tests/http_byteranges.test: + 2005-10-05 Zoran Vasiljevic <vas...@us...> |
From: Zoran V. <vas...@us...> - 2005-10-08 12:06:21
|
Update of /cvsroot/naviserver/naviserver/tcl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7712/tcl Modified Files: compat.tcl Log Message: Applied TclVFS changes. Use (where possible) Tcl_FS wrappers when handling files on the filesystem. Index: compat.tcl =================================================================== RCS file: /cvsroot/naviserver/naviserver/tcl/compat.tcl,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** compat.tcl 16 Feb 2005 16:45:44 -0000 1.2 --- compat.tcl 8 Oct 2005 12:06:07 -0000 1.3 *************** *** 35,47 **** # compat.tcl -- # ! # Procs for backwards compatibility. # # # ns_getchannels -- # ! # Return all open channels. # proc ns_getchannels {} { ! return [file channels] } --- 35,269 ---- # compat.tcl -- # ! # Procs for backwards compatibility. # # + + # # ns_getchannels -- # ! # Return all open channels. # proc ns_getchannels {} { ! file channels ! } ! ! # ! # ns_cpfp -- ! # ! # Copies ncopy bytes from input to output channel. ! # Returns number of bytes copied. ! # ! ! proc ns_cpfp {chanin chanout {ncopy -1}} { ! fcopy $chanin $chanout -size $ncopy ! } ! ! # ! # ns_cp -- ! # ! # Copies srcfile to dstfile, optionally assuring that ! # the dstfile has the same modification, access time ! # and attributes as the srcfile. ! # ! ! proc ns_cp {args} { ! set nargs [llength $args] ! if {$nargs == 2} { ! set pre 0 ! set src [lindex $args 0] ! set dst [lindex $args 1] ! } elseif {$nargs == 3 && [string match "-pre*" [lindex $args 0]]} { ! set pre 1 ! set src [lindex $args 1] ! set dst [lindex $args 2] ! } else { ! error "wrong # args: should be \"ns_cp ?-preserve? srcfile dstfile\"" ! } ! file copy -force -- $src $dst ! if {$pre} { ! file stat $src sbuf ! file mtime $dst $sbuf(mtime) ! file atime $dst $sbuf(atime) ! eval file attributes $dst [file attributes $src] ! } ! } ! ! # ! # ns_mkdir -- ! # ! # Creates a directory. ! # ! ! proc ns_mkdir {dir} { ! file mkdir $dir ! } ! ! # ! # ns_rmdir -- ! # ! # Deletes a directory, complaining if the passed path does not ! # point to an empty directory. ! # ! ! proc ns_rmdir {dir} { ! if {![file isdirectory $dir]} { ! error "error deleting \"$dir\": not a directory" ! } ! file delete $dir ! } ! ! # ! # ns_unlink -- ! # ! # Deletes a file, optionaly complaining if the file is missing. ! # It always complains if the passed path points to a directory. ! # ! ! proc ns_unlink {args} { ! set nargs [llength $args] ! if {$nargs == 1} { ! set complain 1 ! set filepath [lindex $args 0] ! } elseif {$nargs == 2 && [string match "-no*" [lindex $args 0]]} { ! set complain 0 ! set filepath [lindex $args 1] ! } else { ! error "wrong # args: should be \"ns_unlink ?-nocomplain? file\"" ! } ! if {[file isdirectory $filepath]} { ! error "error deleting \"$filepath\": file is a directory" ! } ! if {$complain && ![file exists $filepath]} { ! error "error deleting \"$filepath\": no such file" ! } ! file delete $filepath ! } ! ! # ! # ns_normalizepath -- ! # ! # Normalize the path. WATCH: this procedure is actually broken ! # because it will normalize "a/b/c" to "/a/b/c" which is WRONG. ! # This is because it mimics the broken Ns_NormalizePath C-API. ! # ! # Please use Tcl [file normalize] instead. This always return ! # properly normalized absolute path, as expected. ! # ! ! proc ns_normalizepath {path} { ! if {[file pathtype $path] == "relative"} { ! ns_log warning "normalizepath: $path; broken for relative paths" ! ns_log warning "normalizepath: use \[file normalize\] instead" ! set path /$path ! } ! file normalize $path ! } ! ! # ! # ns_link -- ! # ! # Hard-link the path to a link, eventually complaining. ! # ! ! proc ns_link {args} { ! set nargs [llength $args] ! if {$nargs == 2} { ! set cpl 1 ! set src [lindex $args 0] ! set lnk [lindex $args 1] ! } elseif {$nargs == 3 && [string match "-no*" [lindex $args 0]]} { ! set cpl 0 ! set src [lindex $args 1] ! set lnk [lindex $args 2] ! } else { ! error "wrong # args: should be \"ns_link ?-nocomplain? path link\"" ! } ! if {$cpl} { ! file link -hard $lnk $src ! } else { ! catch {file link -hard $lnk $src} ! } ! ! return ! } ! ! # ! # ns_rename -- ! # ! # As we are re-implementing the ns_rename (which actually calls rename()) ! # with Tcl [file]. lets spend couple of words on the compatibility... ! # ! # This is what "man 2 rename" says (among other things): ! # ! # The rename() causes the link named from to be renamed as to. ! # If to exists, it is first removed. ! # Both from and to must be of the same type (that is, both directories ! # or both non-directories), and must reside on the same file system. ! # ! # What we cannot guarantee is: ! # ! # "must reside on the same file system" ! # ! # because there is no portable means in Tcl to assure this and ! # because Tcl [file rename] is clever enough to copy-then-delete ! # when renaming files residing on different filesystems. ! # ! ! proc ns_rename {from to} { ! if {[file exists $to]} { ! if {[file type $from] != [file type $to]} { ! error "rename (\"$from\", \"$to\"): not of the same type" ! } ! file delete $to ! } ! file rename $from $to } + + # + # ns_chmod -- + # + # Sets permissions mask of the "file" to "mode". + # + + proc ns_chmod {file mode} { + file attributes $file -permissions $mode + } + + # + # ns_truncate -- + # + # This is still implement in the server code. The reason is that + # the Tcl has no portable equivalent; nsd/tclfile.c:NsTclFTruncateObjCmd() + # + + # + # ns_ftruncate -- + # + # This is still implement in the server code. The reason is that + # the Tcl has no portable equivalent; nsd/tclfile.c:NsTclTruncateObjCmd() + # + + # + # ns_mktemp -- + # + # This is still implement in the server code. The reason is that + # the Tcl has no portable equivalent; nsd/tclfile.c:NsTclMkTempObjCmd() + # + + # + # ns_tempnam -- + # + # This is still implement in the server code. The reason is that + # the Tcl has no portable equivalent; nsd/tclfile.c:NsTclTempNamObjCmd() + # + + # + # ns_symlink -- + # + # This is still implement in the server code. The reason is that + # the Tcl [file link] command always creates link target with + # absolute path to the linked file; nsd/tclfile.c:NsTclSymlinkObjCmd() + # + + |
From: Zoran V. <vas...@us...> - 2005-10-08 12:06:21
|
Update of /cvsroot/naviserver/naviserver/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7712/include Modified Files: ns.h nscheck.h Log Message: Applied TclVFS changes. Use (where possible) Tcl_FS wrappers when handling files on the filesystem. Index: nscheck.h =================================================================== RCS file: /cvsroot/naviserver/naviserver/include/nscheck.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** nscheck.h 5 Jul 2005 23:07:49 -0000 1.5 --- nscheck.h 8 Oct 2005 12:06:07 -0000 1.6 *************** *** 57,61 **** --- 57,65 ---- #if __GNUC_PREREQ(3,3) # define NS_GNUC_NONNULL(ARGS) __attribute__((__nonnull__(ARGS))) + #ifndef __APPLE__ # define NS_GNUC_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) + #else + # define NS_GNUC_WARN_UNUSED_RESULT + #endif # define NS_GNUC_MAYALIAS __attribute__((__may_alias__)) #else Index: ns.h =================================================================== RCS file: /cvsroot/naviserver/naviserver/include/ns.h,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** ns.h 2 Oct 2005 22:23:09 -0000 1.50 --- ns.h 8 Oct 2005 12:06:07 -0000 1.51 *************** *** 1189,1200 **** NS_GNUC_NONNULL(2) NS_GNUC_NONNULL(3) NS_GNUC_NONNULL(4); - NS_EXTERN void * - Ns_ModuleSymbol(CONST char *file, CONST char *name) - NS_GNUC_NONNULL(1) NS_GNUC_NONNULL(2); - - NS_EXTERN void * - Ns_ModuleGetSymbol(CONST char *name) - NS_GNUC_NONNULL(1); - /* * nsthread.c: --- 1189,1192 ---- |
From: Zoran V. <vas...@us...> - 2005-10-08 12:06:21
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7712/nsd Modified Files: adpeval.c adprequest.c binder.c config.c conn.c driver.c fastpath.c init.c log.c modload.c nsconf.c nsmain.c pidfile.c rollfile.c tclcmds.c tclfile.c tclimg.c urlopen.c Log Message: Applied TclVFS changes. Use (where possible) Tcl_FS wrappers when handling files on the filesystem. Index: init.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/init.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** init.c 10 Jun 2005 17:58:39 -0000 1.4 --- init.c 8 Oct 2005 12:06:07 -0000 1.5 *************** *** 52,55 **** --- 52,59 ---- * Side effects: * Numerous. + * Also, note that this one is called prior getting the Tcl library + * initialized by calling Tcl_FindExecutable() in nsmain(). + * Therefore, no Tcl VFS calls to the filesystem should be done in + * any of the NsInitX() below. * *---------------------------------------------------------------------- Index: urlopen.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/urlopen.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** urlopen.c 10 Jun 2005 17:58:41 -0000 1.3 --- urlopen.c 8 Oct 2005 12:06:07 -0000 1.4 *************** *** 1,7 **** /* ! * The contents of this file are subject to the AOLserver Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at ! * http://aolserver.com/. * * Software distributed under the License is distributed on an "AS IS" --- 1,7 ---- /* ! * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at ! * http://mozilla.org/. * * Software distributed under the License is distributed on an "AS IS" *************** *** 31,35 **** * urlopen.c -- * ! * Make outgoing HTTP requests. */ --- 31,35 ---- * urlopen.c -- * ! * Make outgoing HTTP requests. */ *************** *** 42,50 **** typedef struct Stream { ! SOCKET sock; ! int error; ! int cnt; char *ptr; ! char buf[BUFSIZE+1]; } Stream; --- 42,50 ---- typedef struct Stream { ! SOCKET sock; ! int error; ! int cnt; char *ptr; ! char buf[BUFSIZE+1]; } Stream; *************** *** 62,73 **** * Ns_FetchPage -- * ! * Fetch a page off of this very server. Url must reference a ! * file in the filesystem. * * Results: ! * NS_OK or NS_ERROR. * * Side effects: ! * The file contents will be put into the passed-in dstring. * *---------------------------------------------------------------------- --- 62,73 ---- * Ns_FetchPage -- * ! * Fetch a page off of this very server. Url must reference a ! * file in the filesystem. * * Results: ! * NS_OK or NS_ERROR. * * Side effects: ! * The file contents will be put into the passed-in dstring. * *---------------------------------------------------------------------- *************** *** 77,96 **** Ns_FetchPage(Ns_DString *dsPtr, char *url, char *server) { ! Ns_DString path; ! int fd; ! int nread; ! char buf[1024]; ! Ns_DStringInit(&path); ! Ns_UrlToFile(&path, server, url); ! fd = open(path.string, O_RDONLY|O_BINARY); ! Ns_DStringFree(&path); ! if (fd < 0) { ! return NS_ERROR; } ! while ((nread = read(fd, buf, sizeof(buf))) > 0) { ! Ns_DStringNAppend(dsPtr, buf, nread); } ! close(fd); return NS_OK; } --- 77,106 ---- Ns_FetchPage(Ns_DString *dsPtr, char *url, char *server) { ! Ns_DString ds; ! Tcl_Channel chan = NULL; ! int nread, fd = -1; ! char buf[1024]; ! Ns_DStringInit(&ds); ! Ns_UrlToFile(&ds, server, url); ! fd = open(ds.string, O_RDONLY|O_BINARY); ! if (fd == -1) { ! chan = Tcl_OpenFileChannel(NULL, ds.string, "r", 0); } ! Ns_DStringFree(&ds); ! if (fd >= 0) { ! while ((nread = read(fd, buf, sizeof(buf))) > 0) { ! Ns_DStringNAppend(dsPtr, buf, nread); ! } ! close(fd); ! } else if (chan) { ! while ((nread = Tcl_Read(chan, buf, sizeof(buf))) > 0) { ! Ns_DStringNAppend(dsPtr, buf, nread); ! } ! Tcl_Close(NULL, chan); ! } else { ! return NS_ERROR; } ! return NS_OK; } *************** *** 102,114 **** * Ns_FetchURL -- * ! * Open up an HTTP connection to an arbitrary URL. * * Results: ! * NS_OK or NS_ERROR. * * Side effects: ! * Page contents will be appended to the passed-in dstring. ! * Headers returned to us will be put into the passed-in Ns_Set. ! * The set name will be changed to a copy of the HTTP status line. * *---------------------------------------------------------------------- --- 112,124 ---- * Ns_FetchURL -- * ! * Open up an HTTP connection to an arbitrary URL. * * Results: ! * NS_OK or NS_ERROR. * * Side effects: ! * Page contents will be appended to the passed-in dstring. ! * Headers returned to us will be put into the passed-in Ns_Set. ! * The set name will be changed to a copy of the HTTP status line. * *---------------------------------------------------------------------- *************** *** 118,127 **** Ns_FetchURL(Ns_DString *dsPtr, char *url, Ns_Set *headers) { ! SOCKET sock; ! char *p; Ns_DString ds; ! Stream stream; Ns_Request *request; ! int status, n; unsigned int tosend; --- 128,137 ---- Ns_FetchURL(Ns_DString *dsPtr, char *url, Ns_Set *headers) { ! SOCKET sock; ! char *p; Ns_DString ds; ! Stream stream; Ns_Request *request; ! int status, n; unsigned int tosend; *************** *** 137,141 **** request = Ns_ParseRequest(ds.string); if (request == NULL || request->protocol == NULL || ! !STREQ(request->protocol, "http") || request->host == NULL) { Ns_Log(Notice, "urlopen: invalid url '%s'", url); goto done; --- 147,151 ---- request = Ns_ParseRequest(ds.string); if (request == NULL || request->protocol == NULL || ! !STREQ(request->protocol, "http") || request->host == NULL) { Ns_Log(Notice, "urlopen: invalid url '%s'", url); goto done; *************** *** 146,152 **** sock = Ns_SockConnect(request->host, request->port); if (sock == INVALID_SOCKET) { ! Ns_Log(Error, "urlopen: failed to connect to '%s': '%s'", ! url, ns_sockstrerror(ns_sockerrno)); ! goto done; } --- 156,162 ---- sock = Ns_SockConnect(request->host, request->port); if (sock == INVALID_SOCKET) { ! Ns_Log(Error, "urlopen: failed to connect to '%s': '%s'", ! url, ns_sockstrerror(ns_sockerrno)); ! goto done; } *************** *** 167,175 **** if (n == SOCKET_ERROR) { Ns_Log(Error, "urlopen: failed to send data to '%s': '%s'", ! url, ns_sockstrerror(ns_sockerrno)); goto done; } tosend -= n; ! p += n; } --- 177,185 ---- if (n == SOCKET_ERROR) { Ns_Log(Error, "urlopen: failed to send data to '%s': '%s'", ! url, ns_sockstrerror(ns_sockerrno)); goto done; } tosend -= n; ! p += n; } *************** *** 184,218 **** stream.sock = sock; if (!GetLine(&stream, &ds)) { ! goto done; } if (headers != NULL && strncmp(ds.string, "HTTP", 4) == 0) { ! if (headers->name != NULL) { ! ns_free(headers->name); ! } ! headers->name = Ns_DStringExport(&ds); } do { ! if (!GetLine(&stream, &ds)) { ! goto done; ! } ! if (ds.length > 0 ! && headers != NULL ! && Ns_ParseHeader(headers, ds.string, Preserve) != NS_OK) { ! goto done; ! } } while (ds.length > 0); ! /* * Without any check on limit or total size, foolishly read * the remaining content into the dstring. */ ! do { ! Ns_DStringNAppend(dsPtr, stream.ptr, stream.cnt); } while (FillBuf(&stream)); if (!stream.error) { ! status = NS_OK; } ! done: if (request != NULL) { --- 194,228 ---- stream.sock = sock; if (!GetLine(&stream, &ds)) { ! goto done; } if (headers != NULL && strncmp(ds.string, "HTTP", 4) == 0) { ! if (headers->name != NULL) { ! ns_free(headers->name); ! } ! headers->name = Ns_DStringExport(&ds); } do { ! if (!GetLine(&stream, &ds)) { ! goto done; ! } ! if (ds.length > 0 ! && headers != NULL ! && Ns_ParseHeader(headers, ds.string, Preserve) != NS_OK) { ! goto done; ! } } while (ds.length > 0); ! /* * Without any check on limit or total size, foolishly read * the remaining content into the dstring. */ ! do { ! Ns_DStringNAppend(dsPtr, stream.ptr, stream.cnt); } while (FillBuf(&stream)); if (!stream.error) { ! status = NS_OK; } ! done: if (request != NULL) { *************** *** 223,226 **** --- 233,237 ---- } Ns_DStringFree(&ds); + return status; } *************** *** 232,242 **** * NsTclGetUrlObjCmd -- * ! * Implements ns_geturl. * * Results: ! * Tcl result. * * Side effects: ! * See docs. * *---------------------------------------------------------------------- --- 243,253 ---- * NsTclGetUrlObjCmd -- * ! * Implements ns_geturl. * * Results: ! * Tcl result. * * Side effects: ! * See docs. * *---------------------------------------------------------------------- *************** *** 244,250 **** int ! NsTclGetUrlObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ! NsInterp *itPtr = arg; Ns_DString ds; Ns_Set *headers; --- 255,262 ---- int ! NsTclGetUrlObjCmd(ClientData arg, Tcl_Interp *interp, int objc, ! Tcl_Obj *CONST objv[]) { ! NsInterp *itPtr = arg; Ns_DString ds; Ns_Set *headers; *************** *** 264,293 **** } Ns_DStringInit(&ds); ! url = Tcl_GetString(objv[1]); if (url[1] == '/') { ! status = Ns_FetchPage(&ds, Tcl_GetString(objv[1]), itPtr->servPtr->server); } else { ! status = Ns_FetchURL(&ds, Tcl_GetString(objv[1]), headers); } if (status != NS_OK) { ! Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "could not fetch: ", ! Tcl_GetString(objv[1]), NULL); ! if (headers != NULL) { ! Ns_SetFree(headers); ! } ! goto done; } if (objc == 3) { Ns_TclEnterSet(interp, headers, NS_TCL_SET_DYNAMIC); if (Tcl_ObjSetVar2(interp, objv[2], NULL, Tcl_GetObjResult(interp), ! TCL_LEAVE_ERR_MSG) == NULL) { ! goto done; ! } } Tcl_SetResult(interp, ds.string, TCL_VOLATILE); code = TCL_OK; - done: Ns_DStringFree(&ds); return code; } --- 276,305 ---- } Ns_DStringInit(&ds); ! url = Tcl_GetString(objv[1]); if (url[1] == '/') { ! status = Ns_FetchPage(&ds, url, itPtr->servPtr->server); } else { ! status = Ns_FetchURL(&ds, url, headers); } if (status != NS_OK) { ! Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "could not fetch: ", ! Tcl_GetString(objv[1]), NULL); ! if (headers != NULL) { ! Ns_SetFree(headers); ! } ! goto done; } if (objc == 3) { Ns_TclEnterSet(interp, headers, NS_TCL_SET_DYNAMIC); if (Tcl_ObjSetVar2(interp, objv[2], NULL, Tcl_GetObjResult(interp), ! TCL_LEAVE_ERR_MSG) == NULL) { ! goto done; ! } } Tcl_SetResult(interp, ds.string, TCL_VOLATILE); code = TCL_OK; done: Ns_DStringFree(&ds); + return code; } *************** *** 299,309 **** * FillBuf -- * ! * Fill the socket stream buffer. * * Results: ! * 1 if fill ok, 0 otherwise. * * Side effects: ! * None. * *---------------------------------------------------------------------- --- 311,321 ---- * FillBuf -- * ! * Fill the socket stream buffer. * * Results: ! * 1 if fill ok, 0 otherwise. * * Side effects: ! * None. * *---------------------------------------------------------------------- *************** *** 317,330 **** n = recv(sPtr->sock, sPtr->buf, BUFSIZE, 0); if (n <= 0) { ! if (n < 0) { ! Ns_Log(Error, "urlopen: " ! "failed to fill socket stream buffer: '%s'", strerror(errno)); ! sPtr->error = 1; ! } ! return 0; } sPtr->buf[n] = '\0'; sPtr->ptr = sPtr->buf; sPtr->cnt = n; return 1; } --- 329,345 ---- n = recv(sPtr->sock, sPtr->buf, BUFSIZE, 0); if (n <= 0) { ! if (n < 0) { ! Ns_Log(Error, "urlopen: " ! "failed to fill socket stream buffer: '%s'", ! strerror(errno)); ! sPtr->error = 1; ! } ! return 0; } + sPtr->buf[n] = '\0'; sPtr->ptr = sPtr->buf; sPtr->cnt = n; + return 1; } *************** *** 336,347 **** * GetLine -- * ! * Copy the next line from the stream to a dstring, trimming ! * the \n and \r. * * Results: ! * 1 or 0. * * Side effects: ! * The dstring is truncated on entry. * *---------------------------------------------------------------------- --- 351,362 ---- * GetLine -- * ! * Copy the next line from the stream to a dstring, trimming ! * the \n and \r. * * Results: ! * 1 or 0. * * Side effects: ! * The dstring is truncated on entry. * *---------------------------------------------------------------------- *************** *** 356,379 **** Ns_DStringTrunc(dsPtr, 0); do { ! if (sPtr->cnt > 0) { ! eol = strchr(sPtr->ptr, '\n'); ! if (eol == NULL) { ! n = sPtr->cnt; ! } else { ! *eol++ = '\0'; ! n = eol - sPtr->ptr; ! } ! Ns_DStringNAppend(dsPtr, sPtr->ptr, n - 1); ! sPtr->ptr += n; ! sPtr->cnt -= n; ! if (eol != NULL) { ! n = dsPtr->length; ! if (n > 0 && dsPtr->string[n-1] == '\r') { ! Ns_DStringTrunc(dsPtr, n-1); ! } ! return 1; ! } ! } } while (FillBuf(sPtr)); return 0; } --- 371,395 ---- Ns_DStringTrunc(dsPtr, 0); do { ! if (sPtr->cnt > 0) { ! eol = strchr(sPtr->ptr, '\n'); ! if (eol == NULL) { ! n = sPtr->cnt; ! } else { ! *eol++ = '\0'; ! n = eol - sPtr->ptr; ! } ! Ns_DStringNAppend(dsPtr, sPtr->ptr, n - 1); ! sPtr->ptr += n; ! sPtr->cnt -= n; ! if (eol != NULL) { ! n = dsPtr->length; ! if (n > 0 && dsPtr->string[n-1] == '\r') { ! Ns_DStringTrunc(dsPtr, n-1); ! } ! return 1; ! } ! } } while (FillBuf(sPtr)); + return 0; } Index: adprequest.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/adprequest.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** adprequest.c 2 Oct 2005 22:23:09 -0000 1.7 --- adprequest.c 8 Oct 2005 12:06:07 -0000 1.8 *************** *** 105,109 **** */ ! if (access(file, R_OK) != 0) { return Ns_ConnReturnNotFound(conn); } --- 105,109 ---- */ ! if (access(file, R_OK) != 0 && Tcl_Access(file, R_OK) != 0) { return Ns_ConnReturnNotFound(conn); } Index: pidfile.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/pidfile.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pidfile.c 10 Jun 2005 17:58:39 -0000 1.2 --- pidfile.c 8 Oct 2005 12:06:07 -0000 1.3 *************** *** 1,7 **** /* ! * The contents of this file are subject to the AOLserver Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at ! * http://aolserver.com/. * * Software distributed under the License is distributed on an "AS IS" --- 1,7 ---- /* ! * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at ! * http://mozilla.org/. * * Software distributed under the License is distributed on an "AS IS" *************** *** 32,36 **** * pidfile.c -- * ! * Implement the PID file routines. */ --- 32,36 ---- * pidfile.c -- * ! * Implement the PID file routines. */ *************** *** 49,61 **** *---------------------------------------------------------------------- * ! * NsCreatePidFile, NsRemovePidFile -- * ! * Create/remove file with current pid. * * Results: ! * None. * * Side effects: ! * None. * *---------------------------------------------------------------------- --- 49,61 ---- *---------------------------------------------------------------------- * ! * NsCreatePidFile -- * ! * Create file with current pid. * * Results: ! * None. * * Side effects: ! * None. * *---------------------------------------------------------------------- *************** *** 65,95 **** NsCreatePidFile(char *procname) { ! int fd, n; ! char buf[10]; ! char *file = GetFile(procname); ! fd = open(file, O_WRONLY|O_TRUNC|O_CREAT, 0644); ! if (fd < 0) { Ns_Log(Error, "pidfile: failed to open pid file '%s': '%s'", ! file, strerror(errno)); } else { ! sprintf(buf, "%d\n", nsconf.pid); ! n = strlen(buf); ! if (write(fd, buf, (size_t)n) != n) { ! Ns_Log(Error, "pidfile: write() failed: '%s'", strerror(errno)); ! } ! close(fd); } } void NsRemovePidFile(char *procname) { ! char *file = GetFile(procname); ! if (unlink(file) != 0) { Ns_Log(Error, "pidfile: failed to remove '%s': '%s'", ! file, strerror(errno)); } } --- 65,118 ---- NsCreatePidFile(char *procname) { ! Tcl_Channel chan; ! int towrite; ! char *file, buf[10]; ! file = GetFile(procname); ! chan = Tcl_OpenFileChannel(NULL, file, "w", 0644); ! if (chan == NULL) { Ns_Log(Error, "pidfile: failed to open pid file '%s': '%s'", ! file, strerror(Tcl_GetErrno())); } else { ! sprintf(buf, "%d\n", nsconf.pid); ! towrite = strlen(buf); ! if (Tcl_WriteChars(chan, buf, towrite) != towrite) { ! Ns_Log(Error, "pidfile: failed to write pid file '%s': '%s'", ! file, strerror(Tcl_GetErrno())); ! } ! Tcl_Close(NULL, chan); } } + + /* + *---------------------------------------------------------------------- + * + * NsRemovePidFile -- + * + * Remove file with current pid. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ void NsRemovePidFile(char *procname) { ! Tcl_Obj *path; ! char *file; ! file = GetFile(procname); ! path = Tcl_NewStringObj(file, -1); ! Tcl_IncrRefCount(path); ! if (Tcl_FSDeleteFile(path) != 0) { Ns_Log(Error, "pidfile: failed to remove '%s': '%s'", ! file, strerror(Tcl_GetErrno())); } + Tcl_DecrRefCount(path); } *************** *** 97,113 **** GetFile(char *procname) { static char *file; if (file == NULL) { file = Ns_ConfigGetValue(NS_CONFIG_PARAMETERS, "pidfile"); ! if (file == NULL) { Ns_DString ds; ! ! Ns_DStringInit(&ds); ! Ns_HomePath(&ds, "log/nspid.", NULL); ! Ns_DStringAppend(&ds, procname); ! file = Ns_DStringExport(&ds); ! } } return file; } --- 120,140 ---- GetFile(char *procname) { + /* + * FIXME: MT-UNSAFE + */ + static char *file; if (file == NULL) { file = Ns_ConfigGetValue(NS_CONFIG_PARAMETERS, "pidfile"); ! if (file == NULL) { Ns_DString ds; ! Ns_DStringInit(&ds); ! Ns_HomePath(&ds, "log/nspid.", NULL); ! Ns_DStringAppend(&ds, procname); ! file = Ns_DStringExport(&ds); ! } } + return file; } Index: tclimg.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/tclimg.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tclimg.c 13 Jun 2005 06:14:26 -0000 1.3 --- tclimg.c 8 Oct 2005 12:06:07 -0000 1.4 *************** *** 1,7 **** /* ! * The contents of this file are subject to the AOLserver Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at ! * http://aolserver.com/. * * Software distributed under the License is distributed on an "AS IS" --- 1,7 ---- /* ! * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at ! * http://mozilla.org/. * * Software distributed under the License is distributed on an "AS IS" *************** *** 54,64 **** * NsTclGifSizeObjCmd -- * ! * Implements ns_gifsize, returning a list of width and height. * * Results: ! * Tcl result. * * Side effects: ! * See docs. * *---------------------------------------------------------------------- --- 54,64 ---- * NsTclGifSizeObjCmd -- * ! * Implements ns_gifsize, returning a list of width and height. * * Results: ! * Tcl result. * * Side effects: ! * See docs. * *---------------------------------------------------------------------- *************** *** 66,86 **** int ! NsTclGifSizeObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ! int fd; ! unsigned char buf[0x300]; ! int depth, colormap, dx, dy, status; if (objc != 2) { ! Tcl_WrongNumArgs(interp, 1, objv, "gif"); return TCL_ERROR; } ! fd = open(Tcl_GetString(objv[1]), O_RDONLY|O_BINARY); ! if (fd == -1) { ! Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "could not open \"", ! Tcl_GetString(objv[1]), ! "\": ", Tcl_PosixError(interp), NULL); return TCL_ERROR; } status = TCL_ERROR; --- 66,91 ---- int ! NsTclGifSizeObjCmd(ClientData arg, Tcl_Interp *interp, int objc, ! Tcl_Obj *CONST objv[]) { ! unsigned char buf[0x300], count; ! char *file; ! int depth, colormap, dx, dy, status; ! Tcl_Channel chan; if (objc != 2) { ! Tcl_WrongNumArgs(interp, 1, objv, "gif_file"); return TCL_ERROR; } ! file = Tcl_GetString(objv[1]); ! chan = Tcl_OpenFileChannel(interp, file, "r", 0); ! if (chan == NULL) { return TCL_ERROR; } + if (Tcl_SetChannelOption(interp, chan, "-translation", "binary") + != TCL_OK) { + return TCL_ERROR; + } + status = TCL_ERROR; *************** *** 89,117 **** */ ! if (read(fd, buf, 6) != 6) { readfail: ! Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "could not read \"", ! Tcl_GetString(objv[1]), ! "\": ", Tcl_PosixError(interp), NULL); ! goto done; } if (strncmp((char *) buf, "GIF87a", 6) && ! strncmp((char *) buf, "GIF89a", 6)) { ! badfile: ! Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "invalid gif file: ", ! Tcl_GetString(objv[1]), NULL); goto done; } ! if (read(fd, buf, 7) != 7) { ! goto readfail; } ! depth = 1 << ((buf[4] & 0x7) + 1); colormap = (buf[4] & 0x80 ? 1 : 0); if (colormap) { ! if (read(fd, buf, (size_t)(3*depth)) != (3*depth)) { goto readfail; } --- 94,120 ---- */ ! if (Tcl_Read(chan, buf, 6) != 6) { readfail: ! Tcl_AppendResult(interp, "could not read \"", file, "\": ", ! Tcl_PosixError(interp), NULL); ! goto done; } if (strncmp((char *) buf, "GIF87a", 6) && ! strncmp((char *) buf, "GIF89a", 6)) { ! badfile: ! Tcl_AppendResult(interp, "bad gif file \"", file, "\"", NULL); goto done; } ! if (Tcl_Read(chan, buf, 7) != 7) { ! goto readfail; } ! depth = 1 << ((buf[4] & 0x7) + 1); colormap = (buf[4] & 0x80 ? 1 : 0); if (colormap) { ! if (Tcl_Read(chan, buf, (size_t)(3*depth)) != (3*depth)) { goto readfail; } *************** *** 119,134 **** outerloop: ! if (read(fd, buf, 1) != 1) { goto readfail; } if (buf[0] == '!') { ! unsigned char count; ! ! if (read(fd, buf, 1) != 1) { goto readfail; } ! innerloop: ! if (read(fd, (char *) &count, 1) != 1) { goto readfail; } --- 122,135 ---- outerloop: ! if (Tcl_Read(chan, buf, 1) != 1) { goto readfail; } if (buf[0] == '!') { ! if (Tcl_Read(chan, buf, 1) != 1) { goto readfail; } ! innerloop: ! if (Tcl_Read(chan, (char *) &count, 1) != 1) { goto readfail; } *************** *** 136,140 **** goto outerloop; } ! if (read(fd, buf, count) != count) { goto readfail; } --- 137,141 ---- goto outerloop; } ! if (Tcl_Read(chan, buf, count) != count) { goto readfail; } *************** *** 143,160 **** goto badfile; } ! ! if (read(fd,buf,9) != 9) { goto readfail; } ! dx = 0x100 * buf[5] + buf[4]; dy = 0x100 * buf[7] + buf[6]; ! if(AppendObjDims(interp, dx, dy) != TCL_OK) { return TCL_ERROR; ! }; status = TCL_OK; done: ! close(fd); return status; } --- 144,164 ---- goto badfile; } ! ! if (Tcl_Read(chan, buf, 9) != 9) { goto readfail; } ! dx = 0x100 * buf[5] + buf[4]; dy = 0x100 * buf[7] + buf[6]; ! ! if (AppendObjDims(interp, dx, dy) != TCL_OK) { return TCL_ERROR; ! } ! status = TCL_OK; done: ! Tcl_Close(interp, chan); ! return status; } *************** *** 166,176 **** * NsTclJpegSizeObjCmd -- * ! * Implements ns_jpegsize as obj command. * * Results: ! * Tcl result. * * Side effects: ! * See docs. * *---------------------------------------------------------------------- --- 170,180 ---- * NsTclJpegSizeObjCmd -- * ! * Implements ns_jpegsize as obj command. * * Results: ! * Tcl result. * * Side effects: ! * See docs. * *---------------------------------------------------------------------- *************** *** 178,198 **** int ! NsTclJpegSizeObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ! int code, w = 0, h = 0; Tcl_Channel chan; if (objc != 2) { ! Tcl_WrongNumArgs(interp, 1, objv, "file"); ! return TCL_ERROR; } ! ! chan = Tcl_OpenFileChannel(interp, Tcl_GetString(objv[1]), "r", 0); if (chan == NULL) { - /* Tcl function will leave error message in interp's result */ return TCL_ERROR; } ! if (Tcl_SetChannelOption(interp, chan, "-translation", "binary") != TCL_OK) { ! /* Tcl function will leave error message in interp's result */ return TCL_ERROR; } --- 182,203 ---- int ! NsTclJpegSizeObjCmd(ClientData arg, Tcl_Interp *interp, int objc, ! Tcl_Obj *CONST objv[]) { ! char *file; ! int code, w = 0, h = 0; Tcl_Channel chan; if (objc != 2) { ! Tcl_WrongNumArgs(interp, 1, objv, "jpeg_file"); ! return TCL_ERROR; } ! file = Tcl_GetString(objv[1]); ! chan = Tcl_OpenFileChannel(interp, file, "r", 0); if (chan == NULL) { return TCL_ERROR; } ! if (Tcl_SetChannelOption(interp, chan, "-translation", "binary") ! != TCL_OK) { return TCL_ERROR; } *************** *** 200,210 **** Tcl_Close(interp, chan); if (code != TCL_OK) { ! Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "invalid jpeg file: ", ! Tcl_GetString(objv[1]), NULL); ! return TCL_ERROR; } ! if(AppendObjDims(interp, w, h) != TCL_OK) { ! return TCL_ERROR; ! }; return TCL_OK; } --- 205,215 ---- Tcl_Close(interp, chan); if (code != TCL_OK) { ! Tcl_AppendResult(interp, "invalid jpeg file \"", file, "\"", NULL); ! return TCL_ERROR; } ! if (AppendObjDims(interp, w, h) != TCL_OK) { ! return TCL_ERROR; ! } ! return TCL_OK; } *************** *** 221,245 **** if (ChanGetc(chan) == 0xFF && ChanGetc(chan) == M_SOI) { ! while (1) { ! i = JpegNextMarker(chan); ! if (i == EOF || i == M_SOS || i == M_EOI) { ! break; ! } if (0xC0 <= i && i <= 0xC3) { ! if (JpegRead2Bytes(chan) != EOF && ChanGetc(chan) != EOF ! && (h = JpegRead2Bytes(chan)) != EOF ! && (w = JpegRead2Bytes(chan)) != EOF) { ! *wPtr = w; ! *hPtr = h; ! return TCL_OK; ! } ! break; ! } ! numbytes = JpegRead2Bytes(chan); ! if (numbytes < 2 || Tcl_Seek(chan, numbytes - 2, SEEK_CUR) == -1) { ! break; ! } ! } } return TCL_ERROR; } --- 226,251 ---- if (ChanGetc(chan) == 0xFF && ChanGetc(chan) == M_SOI) { ! while (1) { ! i = JpegNextMarker(chan); ! if (i == EOF || i == M_SOS || i == M_EOI) { ! break; ! } if (0xC0 <= i && i <= 0xC3) { ! if (JpegRead2Bytes(chan) != EOF && ChanGetc(chan) != EOF ! && (h = JpegRead2Bytes(chan)) != EOF ! && (w = JpegRead2Bytes(chan)) != EOF) { ! *wPtr = w; ! *hPtr = h; ! return TCL_OK; ! } ! break; ! } ! numbytes = JpegRead2Bytes(chan); ! if (numbytes < 2 || Tcl_Seek(chan, numbytes - 2, SEEK_CUR) == -1) { ! break; ! } ! } } + return TCL_ERROR; } *************** *** 271,276 **** c2 = ChanGetc(chan); if (c1 == EOF || c2 == EOF) { ! return -1; } return (int)(((unsigned int) c1) << 8) + ((unsigned int) c2); } --- 277,283 ---- c2 = ChanGetc(chan); if (c1 == EOF || c2 == EOF) { ! return -1; } + return (int)(((unsigned int) c1) << 8) + ((unsigned int) c2); } *************** *** 311,326 **** c = ChanGetc(chan); while (c != EOF && c != 0xFF) { ! c = ChanGetc(chan); } if (c != EOF) { ! /* ! * Get marker code byte, swallowing any duplicate FF bytes. ! */ ! ! do { ! c = ChanGetc(chan); ! } while (c == 0xFF); } ! return c; } --- 318,332 ---- c = ChanGetc(chan); while (c != EOF && c != 0xFF) { ! c = ChanGetc(chan); } if (c != EOF) { ! /* ! * Get marker code byte, swallowing any duplicate FF bytes. ! */ ! do { ! c = ChanGetc(chan); ! } while (c == 0xFF); } ! return c; } *************** *** 349,354 **** if (Tcl_Read(chan, (char *) buf, 1) != 1) { ! return EOF; } return (int) buf[0]; } --- 355,361 ---- if (Tcl_Read(chan, (char *) buf, 1) != 1) { ! return EOF; } + return (int) buf[0]; } *************** *** 385,389 **** return TCL_ERROR; } ! Tcl_SetObjResult(interp, result); --- 392,396 ---- return TCL_ERROR; } ! Tcl_SetObjResult(interp, result); Index: rollfile.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/rollfile.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** rollfile.c 2 Oct 2005 22:23:10 -0000 1.4 --- rollfile.c 8 Oct 2005 12:06:07 -0000 1.5 *************** *** 1,7 **** /* ! * The contents of this file are subject to the AOLserver Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at ! * http://aolserver.com/. * * Software distributed under the License is distributed on an "AS IS" --- 1,7 ---- /* ! * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at ! * http://mozilla.org/. * * Software distributed under the License is distributed on an "AS IS" *************** *** 39,44 **** typedef struct File { ! time_t mtime; ! char name[4]; } File; --- 39,44 ---- typedef struct File { ! time_t mtime; ! Tcl_Obj *path; } File; *************** *** 47,51 **** */ ! static int AppendFile(Ns_DString *dsPtr, CONST char *dir, CONST char *tail); static int CmpFile(const void *p1, const void *p2); static int Rename(CONST char *from, CONST char *to); --- 47,51 ---- */ ! static int MatchFiles(CONST char *file, File **files); static int CmpFile(const void *p1, const void *p2); static int Rename(CONST char *from, CONST char *to); *************** *** 81,90 **** { char *first, *next, *dot; ! int num; ! int err; if (max < 0 || max > 999) { Ns_Log(Error, "rollfile: invalid max parameter '%d'; " ! "must be > 0 and < 999", max); return NS_ERROR; } --- 81,89 ---- { char *first, *next, *dot; ! int num, err; if (max < 0 || max > 999) { Ns_Log(Error, "rollfile: invalid max parameter '%d'; " ! "must be > 0 and < 999", max); return NS_ERROR; } *************** *** 93,107 **** sprintf(first, "%s.000", file); err = Exists(first); if (err > 0) { next = ns_strdup(first); num = 0; do { dot = strrchr(next, '.') + 1; sprintf(dot, "%03d", num++); } while ((err = Exists(next)) == 1 && num < max); ! num--; if (err == 1) { ! err = Unlink(next); } while (err == 0 && num-- > 0) { dot = strrchr(first, '.') + 1; --- 92,119 ---- sprintf(first, "%s.000", file); err = Exists(first); + if (err > 0) { next = ns_strdup(first); num = 0; + + /* + * Find the highest version + */ + do { dot = strrchr(next, '.') + 1; sprintf(dot, "%03d", num++); } while ((err = Exists(next)) == 1 && num < max); ! ! num--; /* After this, num holds the max version found */ ! if (err == 1) { ! err = Unlink(next); /* The excessive version */ } + + /* + * Shift *.010 -> *.011, *:009 -> *.010, etc + */ + while (err == 0 && num-- > 0) { dot = strrchr(first, '.') + 1; *************** *** 113,116 **** --- 125,129 ---- ns_free(next); } + if (err == 0) { err = Exists(file); *************** *** 119,122 **** --- 132,136 ---- } } + ns_free(first); *************** *** 124,127 **** --- 138,142 ---- return NS_ERROR; } + return NS_OK; } *************** *** 134,138 **** * * Purge files by date, keeping max files. The file parameter is ! * used a basename to select files to purge. Ns_RollFileByDate * is a poorly named wrapper for historical reasons (rolling * implies rotating filenames). --- 149,153 ---- * * Purge files by date, keeping max files. The file parameter is ! * used as a basename to select files to purge. Ns_RollFileByDate * is a poorly named wrapper for historical reasons (rolling * implies rotating filenames). *************** *** 156,241 **** Ns_PurgeFiles(CONST char *file, int max) { ! char *slash, *tail; ! DIR *dp; ! struct dirent *ent; ! File **files; ! int tlen, i, nfiles, status; ! Ns_DString dir, list; ! ! status = NS_ERROR; ! Ns_DStringInit(&dir); ! Ns_DStringInit(&list); /* ! * Determine the directory component. */ ! Ns_NormalizePath(&dir, file); ! slash = strrchr (dir.string, '/'); ! if (slash == NULL || slash[1] == '\0') { ! Ns_Log (Error, "rollfile: failed to purge files: invalid path '%s'", ! file); ! goto err; ! } ! *slash = '\0'; ! tail = slash + 1; ! tlen = strlen(tail); ! ! dp = opendir(dir.string); ! if (dp == NULL) { ! Ns_Log(Error, "rollfile: failed to purge files:opendir(%s) failed: '%s'", ! dir.string, strerror(errno)); ! goto err; ! } ! while ((ent = ns_readdir(dp)) != NULL) { ! if (strncmp(tail, ent->d_name, (size_t)tlen) != 0) { ! continue; ! } ! if (!AppendFile(&list, dir.string, ent->d_name)) { ! closedir(dp); ! goto err; ! } } - closedir(dp); ! nfiles = list.length / sizeof(File *); if (nfiles >= max) { ! files = (File **) list.string; ! qsort(files, (size_t)nfiles, sizeof(File *), CmpFile); ! for (i = max; i < nfiles; ++i) { ! if (Unlink(files[i]->name) != 0) { goto err; } } } - status = NS_OK; ! err: ! nfiles = list.length / sizeof(File *); if (nfiles > 0) { ! files = (File **) list.string; ! for (i = 0; i < nfiles; ++i) { ! ns_free(files[i]); } } - Ns_DStringFree(&list); - Ns_DStringFree(&dir); return status; } - /* *---------------------------------------------------------------------- * ! * AppendFile -- * ! * Append a file entry with mtime to the list kept in the dstring. * * Results: ! * 1 if file added, 0 otherwise. * * Side effects: ! * Allocates memory for entry. * *---------------------------------------------------------------------- --- 171,230 ---- Ns_PurgeFiles(CONST char *file, int max) { ! File *files, *fiPtr; ! int ii, nfiles, status = NS_ERROR; /* ! * Get all files matching "file*" pattern. */ ! nfiles = MatchFiles(file, &files); ! if (nfiles == -1) { ! Ns_Log(Error, "rollfile: failed to match files '%s': %s", ! file, strerror(Tcl_GetErrno())); } ! /* ! * Purge (any) excessive files after sorting them ! * on descening file mtime. ! */ ! if (nfiles >= max) { ! qsort(files, (size_t)nfiles, sizeof(File), CmpFile); ! for (ii = max, fiPtr = files + ii; ii < nfiles; ii++, fiPtr++) { ! if (Unlink(Tcl_GetString(fiPtr->path)) != 0) { goto err; } } } ! status = NS_OK; ! ! err: if (nfiles > 0) { ! for (ii = 0, fiPtr = files + ii; ii < nfiles; ii++, fiPtr++) { ! Tcl_DecrRefCount(fiPtr->path); } + ns_free(files); } return status; } /* *---------------------------------------------------------------------- * ! * MatchFiles -- * ! * Find plain files in the file's parent directory matching the ! * "filename*" pattern. * * Results: ! * Number of files found, or -1 on error. If any files found, ! * pointer to allocated array of File structures is left in ! * the passed "files" argument. * * Side effects: ! * Allocates the memory for files array which must be freed ! * by the caller. * *---------------------------------------------------------------------- *************** *** 243,263 **** static int ! AppendFile(Ns_DString *dsPtr, CONST char *dir, CONST char *tail) { ! File *fPtr; ! struct stat st; ! fPtr = ns_malloc(sizeof(File) + strlen(dir) + strlen(tail)); ! sprintf(fPtr->name, "%s/%s", dir, tail); ! if (stat(fPtr->name, &st) != 0) { ! Ns_Log(Error, "rollfile: failed to append to file '%s': '%s'", ! fPtr->name, strerror(errno)); ! ns_free(fPtr); ! return 0; } - fPtr->mtime = st.st_mtime; - Ns_DStringNAppend(dsPtr, (char *) &fPtr, sizeof(File *)); ! return 1; } --- 232,319 ---- static int ! MatchFiles(CONST char *filename, File **files) { ! Tcl_Obj *path, *pathElems, *parent, *patternObj; ! Tcl_Obj *matched, **matchElems; ! Tcl_GlobTypeData types; ! File *fiPtr; ! int numElems, code, ii, jj; ! char *pattern; ! /* ! * Obtain fully qualified path of the passed filename ! */ ! ! path = Tcl_NewStringObj(filename, -1); ! Tcl_IncrRefCount(path); ! if (Tcl_FSGetNormalizedPath(NULL, path) == NULL) { ! Tcl_DecrRefCount(path); ! return -1; } ! /* ! * Get the parent directory of the passed filename ! */ ! ! pathElems = Tcl_FSSplitPath(path, &numElems); ! parent = Tcl_FSJoinPath(pathElems, numElems - 1); ! Tcl_IncrRefCount(parent); ! ! /* ! * Construct the glob pattern for lookup. ! */ ! ! Tcl_ListObjIndex(NULL, pathElems, numElems - 1, &patternObj); ! Tcl_AppendToObj(patternObj, "*", 1); ! pattern = Tcl_GetString(patternObj); ! ! /* ! * Now, do the match on files only. ! */ ! ! memset(&types, 0, sizeof(Tcl_GlobTypeData)); ! types.type = TCL_GLOB_TYPE_FILE; ! ! matched = Tcl_NewObj(); ! Tcl_IncrRefCount(matched); ! ! code = Tcl_FSMatchInDirectory(NULL, matched, parent, pattern, &types); ! if (code != TCL_OK) { ! numElems = -1; ! } else { ! ! /* ! * Construct array of File's to pass to caller ! */ ! ! Tcl_ListObjGetElements(NULL, matched, &numElems, &matchElems); ! ! if (numElems > 0) { ! Tcl_StatBuf *stPtr; ! *files = ns_malloc(sizeof(File) * numElems); ! stPtr = Tcl_AllocStatBuf(); ! for (ii = 0, fiPtr = *files; ii < numElems; ii++, fiPtr++) { ! if (Tcl_FSStat(matchElems[ii], stPtr) != 0) { ! for (jj = 0, fiPtr = *files; jj < ii; jj++, fiPtr++) { ! Tcl_DecrRefCount(fiPtr->path); ! } ! ns_free(*files); ! numElems = -1; ! break; ! } ! fiPtr->mtime = stPtr->st_mtime; ! fiPtr->path = matchElems[ii]; ! Tcl_IncrRefCount(fiPtr->path); ! } ! Tcl_Free((char*)stPtr); ! } ! } ! ! Tcl_DecrRefCount(path); ! Tcl_DecrRefCount(parent); ! Tcl_DecrRefCount(pathElems); ! Tcl_DecrRefCount(matched); ! ! return numElems; } *************** *** 282,287 **** CmpFile(const void *arg1, const void *arg2) { ! File *f1Ptr = *((File **) arg1); ! File *f2Ptr = *((File **) arg2); if (f1Ptr->mtime < f2Ptr->mtime) { --- 338,343 ---- CmpFile(const void *arg1, const void *arg2) { ! File *f1Ptr = (File *) arg1; ! File *f2Ptr = (File *) arg2; if (f1Ptr->mtime < f2Ptr->mtime) { *************** *** 289,293 **** } else if (f1Ptr->mtime > f2Ptr->mtime) { return -1; ! } return 0; } --- 345,350 ---- } else if (f1Ptr->mtime > f2Ptr->mtime) { return -1; ! } ! return 0; } *************** *** 314,323 **** { int err; ! err = unlink(file); if (err != 0) { Ns_Log(Error, "rollfile: failed to delete file '%s': '%s'", ! file, strerror(errno)); } return err; } --- 371,385 ---- { int err; + Tcl_Obj *fileObj; ! fileObj = Tcl_NewStringObj(file, -1); ! Tcl_IncrRefCount(fileObj); ! err = Tcl_FSDeleteFile(fileObj); if (err != 0) { Ns_Log(Error, "rollfile: failed to delete file '%s': '%s'", ! file, strerror(Tcl_GetErrno())); } + Tcl_DecrRefCount(fileObj); + return err; } *************** *** 327,336 **** { int err; ! ! err = rename(from, to); if (err != 0) { Ns_Log(Error, "rollfile: failed to rename file '%s' to '%s': '%s'", ! from, to, strerror(errno)); } return err; } --- 389,409 ---- { int err; ! Tcl_Obj *fromObj, *toObj; ! ! fromObj = Tcl_NewStringObj(from, -1); ! Tcl_IncrRefCount(fromObj); ! ! toObj = Tcl_NewStringObj(to, -1); ! Tcl_IncrRefCount(toObj); ! ! err = Tcl_FSRenameFile(fromObj, toObj); ! ! Tcl_DecrRefCount(fromObj); ! Tcl_DecrRefCount(toObj); if (err != 0) { Ns_Log(Error, "rollfile: failed to rename file '%s' to '%s': '%s'", ! from, to, strerror(Tcl_GetErrno())); } + return err; } *************** *** 340,353 **** { int exists; ! ! if (access(file, F_OK) == 0) { exists = 1; ! } else if (errno == ENOENT) { exists = 0; } else { ! Ns_Log(Error, "rollfile: failed to determine if file '%s' exists: '%s'", ! file, strerror(errno)); exists = -1; } return exists; } --- 413,427 ---- { int exists; ! ! if (Tcl_Access(file, F_OK) == 0) { exists = 1; ! } else if (Tcl_GetErrno() == ENOENT) { exists = 0; } else { ! Ns_Log(Error, "rollfile: failed to determine if file '%s' " ! "exists: '%s'", file, strerror(Tcl_GetErrno())); exists = -1; } + return exists; } Index: config.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/config.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** config.c 4 Aug 2005 04:52:12 -0000 1.4 --- config.c 8 Oct 2005 12:06:07 -0000 1.5 *************** *** 486,493 **** * * Results: ! * Pointer to the config buffer of an ns_malloc'ed string. * * Side Effects: ! * Server aborts if file cannot be read for any reason. * *--------------------------------------------------------------------- --- 486,493 ---- * * Results: ! * Pointer to the config buffer in an ns_malloc'ed string. * * Side Effects: ! * Server aborts if the file cannot be read for any reason. * *--------------------------------------------------------------------- *************** *** 497,525 **** NsConfigRead(CONST char *file) { ! struct stat st; ! int fd; ! char *buf; ! size_t n; ! if (stat(file, &st) != 0) { ! Ns_Fatal("config: stat(%s) failed: %s", file, strerror(errno)); } ! if (S_ISREG(st.st_mode) == 0) { ! Ns_Fatal("config: not regular file: %s", file); } ! fd = open(file, O_RDONLY); ! if (fd < 0) { ! Ns_Fatal("config: open(%s) failed: %s", file, strerror(errno)); } ! n = st.st_size; ! buf = ns_malloc(n + 1); ! n = read(fd, buf, n); ! if (n < 0) { ! Ns_Fatal("config: read(%s) failed: %s", file, strerror(errno)); } ! buf[n] = '\0'; ! close(fd); ! return buf; } --- 497,544 ---- NsConfigRead(CONST char *file) { ! Tcl_Channel chan = NULL; ! Tcl_Obj *buf = NULL; ! char *call, *data, *conf = NULL; ! int length; ! /* ! * Open the channel for reading the config file ! */ ! ! chan = Tcl_OpenFileChannel(NULL, file, "r", 0); ! if (chan == NULL) { ! call = "open"; ! goto err; } ! ! /* ! * Slurp entire file in memory ! */ ! ! buf = Tcl_NewObj(); ! Tcl_IncrRefCount(buf); ! if (Tcl_ReadChars(chan, buf, -1, 0) == -1) { ! call = "read"; ! goto err; } ! ! Tcl_Close(NULL, chan); ! data = Tcl_GetStringFromObj(buf, &length); ! conf = strcpy(ns_malloc(length + 1), data); ! Tcl_DecrRefCount(buf); ! ! return conf; ! ! err: ! if (chan) { ! Tcl_Close(NULL, chan); } ! if (buf) { ! Tcl_DecrRefCount(buf); } ! Ns_Fatal("config: can't %s file '%s': '%s'", call, file, ! strerror(Tcl_GetErrno())); ! return NULL; /* Keep the compiler happy */ } Index: binder.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/binder.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** binder.c 6 Jul 2005 08:45:52 -0000 1.12 --- binder.c 8 Oct 2005 12:06:07 -0000 1.13 *************** *** 412,423 **** } if (file != NULL) { ! FILE *fp; ! fp = fopen(file, "r"); ! if (fp != NULL) { ! char line[1024]; ! while (fgets(line, sizeof(line), fp) != NULL) { ! PreBind(line); } ! fclose(fp); } } --- 412,430 ---- } if (file != NULL) { ! Tcl_Channel chan = Tcl_OpenFileChannel(NULL, file, "r", 0); ! if (chan == NULL) { ! Ns_Log(Error, "binder: can't open file '%s': '%s'", file, ! strerror(Tcl_GetErrno())); ! } else { ! Tcl_DString line; ! Tcl_DStringInit(&line); ! while(!Tcl_Eof(chan)) { ! Tcl_DStringSetLength(&line, 0); ! if (Tcl_Gets(chan, &line) > 0) { ! PreBind(Tcl_DStringValue(&line)); ! } } ! Tcl_DStringFree(&line); ! Tcl_Close(NULL, chan); } } Index: fastpath.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/fastpath.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** fastpath.c 2 Oct 2005 22:23:09 -0000 1.20 --- fastpath.c 8 Oct 2005 12:06:07 -0000 1.21 *************** *** 40,59 **** /* ! * The following structure defines the offsets parsed ! * from Range: request header */ ! #define MAX_RANGES (NS_CONN_MAXBUFS/3) typedef struct { ! int status; /* Return status updated, 206 or 416 */ [...1132 lines suppressed...] ! ! iovPtr += 2; ! result = Ns_ConnSend(conn, iovPtr, 1); ! if (result == NS_ERROR) { ! break; ! } ! } ! } + Ns_DStringFree(&ds); break; *************** *** 983,986 **** --- 1143,1147 ---- result = Ns_ConnClose(conn); } + return result; } Index: log.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/log.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** log.c 2 Oct 2005 22:39:06 -0000 1.8 --- log.c 8 Oct 2005 12:06:07 -0000 1.9 *************** *** 92,97 **** /* ! * Keep the following in sync with the ! * Ns_LogSeverity enum. */ --- 92,96 ---- /* ! * Keep the following in sync with the Ns_LogSeverity enum. */ *************** *** 109,113 **** }; - /* --- 108,111 ---- *************** *** 213,218 **** * Ns_LogRoll -- * ! * Signal handler for SIG_HUP which will roll the files. Also a ! * tasty snack from Stuckey's. * * Results: --- 211,215 ---- * Ns_LogRoll -- * ! * Signal handler for SIG_HUP which will roll the files. * * Results: *************** *** 237,240 **** --- 234,238 ---- } } + return NS_OK; } *************** *** 442,450 **** int ! NsTclLogRollObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { if (Ns_LogRoll() != NS_OK) { Tcl_SetResult(interp, "could not roll server log", TCL_STATIC); } return TCL_OK; } --- 440,450 ---- int ! NsTclLogRollObjCmd(ClientData arg, Tcl_Interp *interp, int objc, ! Tcl_Obj *CONST objv[]) { if (Ns_LogRoll() != NS_OK) { Tcl_SetResult(interp, "could not roll server log", TCL_STATIC); } + return TCL_OK; } *************** *** 469,473 **** int ! NsTclLogCtlObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { LogCache *cachePtr; --- 469,474 ---- int ! NsTclLogCtlObjCmd(ClientData arg, Tcl_Interp *interp, int objc, ! Tcl_Obj *CONST objv[]) { LogCache *cachePtr; *************** *** 475,482 **** static CONST char *opts[] = { ! "hold", "count", "get", "peek", "flush", "release", "truncate", NULL }; enum { ! CHoldIdx, CCountIdx, CGetIdx, CPeekIdx, CFlushIdx, CReleaseIdx, CTruncIdx }; --- 476,485 ---- static CONST char *opts[] = { ! "hold", "count", "get", "peek", "flush", "release", ! "truncate", NULL }; enum { ! CHoldIdx, CCountIdx, CGetIdx, CPeekIdx, CFlushIdx, CReleaseIdx, ! CTruncIdx }; *************** *** 527,530 **** --- 530,534 ---- break; } + return TCL_OK; } *************** *** 548,556 **** int ! NsTclLogObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ! Ns_LogSeverity severity; ! Ns_DString ds; ! int i; struct { --- 552,561 ---- int ! NsTclLogObjCmd(ClientData arg, Tcl_Interp *interp, int objc, ! Tcl_Obj *CONST objv[]) { ! Ns_LogSeverity severity; ! Ns_DString ds; ! int i; struct { *************** *** 579,583 **** severity = i; } else { ! Tcl_AppendResult(interp, "unknown severity: \"", Tcl_GetString(objv[1]), "\": should be notice, warning, error, " "fatal, bug, debug, dev or integer value", NULL); --- 584,589 ---- severity = i; } else { ! Tcl_AppendResult(interp, "unknown severity: \"", ! Tcl_GetString(objv[1]), "\": should be notice, warning, error, " "fatal, bug, debug, dev or integer value", NULL); *************** *** 680,685 **** Ns_DStringPrintf(&cachePtr->buffer, ".%ld]", usec); } ! Ns_DStringPrintf(&cachePtr->buffer, "[%d.%lu][%s] %s: ", ! Ns_InfoPid(), (unsigned long) Ns_ThreadId(), Ns_ThreadGetName(), severityStr); if (flags & LOG_EXPAND) { Ns_DStringAppend(&cachePtr->buffer, "\n "); --- 686,692 ---- Ns_DStringPrintf(&cachePtr->buffer, ".%ld]", usec); } ! Ns_DStringPrintf(&cachePtr->buffer, "[%d.%lu][%s] %s: ", Ns_InfoPid(), ! (unsigned long) Ns_ThreadId(), Ns_ThreadGetName(), ! severityStr); if (flags & LOG_EXPAND) { Ns_DStringAppend(&cachePtr->buffer, "\n "); *************** *** 774,787 **** LogReOpen(void) { ! int fd; ! int status; - status = NS_OK; fd = open(file, O_WRONLY|O_APPEND|O_CREAT, 0644); ! if (fd < 0) { ! Ns_Log(Error, "log: failed to re-open log file '%s': '%s'", file, strerror(errno)); status = NS_ERROR; } else { /* * Route stderr to the file --- 781,793 ---- LogReOpen(void) { ! int fd, status = NS_OK; fd = open(file, O_WRONLY|O_APPEND|O_CREAT, 0644); ! if (fd == -1) { ! Ns_Log(Error, "log: failed to re-open log file '%s': '%s'", file, strerror(errno)); status = NS_ERROR; } else { + /* * Route stderr to the file *************** *** 807,811 **** * Clean up dangling 'open' reference to the fd */ ! if (fd != STDERR_FILENO && fd != STDOUT_FILENO) { close(fd); --- 813,817 ---- * Clean up dangling 'open' reference to the fd */ ! if (fd != STDERR_FILENO && fd != STDOUT_FILENO) { close(fd); *************** *** 972,973 **** --- 978,980 ---- abort(); } + Index: tclfile.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/tclfile.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tclfile.c 30 Jul 2005 04:06:02 -0000 1.5 --- tclfile.c 8 Oct 2005 12:06:07 -0000 1.6 *************** *** 36,44 **** #include "nsd.h" - #ifdef _WIN32 - #include <sys/utime.h> - #else - #include <utime.h> - #endif NS_RCSID("@(#) $Header$"); --- 36,39 ---- *************** *** 144,413 **** *---------------------------------------------------------------------- * - * NsTclCpFpObjCmd -- - * - * Implements ns_cpfp as obj command. - * - * Results: - * Tcl result. - * - * Side effects: - * See docs. - * - *---------------------------------------------------------------------- - */ - - int - NsTclCpFpObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) - { - Tcl_Channel in, out; - char buf[2048]; - char *p; - int tocopy, nread, nwrote, toread, ntotal; - - if (objc != 3 && objc != 4) { - Tcl_WrongNumArgs(interp, 1, objv, "inChan outChan ?ncopy?"); - return TCL_ERROR; - } - if (GetOpenChannel(interp, objv[1], 0, 1, &in) != TCL_OK || - GetOpenChannel(interp, objv[2], 1, 1, &out) != TCL_OK) { - return TCL_ERROR; - } - if (objc == 3) { - tocopy = -1; - } else { - if (Tcl_GetInt(interp, Tcl_GetString(objv[3]), &tocopy) != TCL_OK) { - return TCL_ERROR; - } - if (tocopy < 0) { - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "invalid length \"", - Tcl_GetString(objv[3]), - "\": must be >= 0", NULL); - return TCL_ERROR; - } - } - - ntotal = 0; - while (tocopy != 0) { - toread = sizeof(buf); - if (tocopy > 0 && toread > tocopy) { - toread = tocopy; - } - nread = Tcl_Read(in, buf, toread); - if (nread == 0) { - break; - } else if (nread < 0) { - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "read failed: ", - Tcl_PosixError(interp), NULL); - return TCL_ERROR; - } - if (tocopy > 0) { - tocopy -= nread; - } - p = buf; - while (nread > 0) { - nwrote = Tcl_Write(out, p, nread); - if (nwrote < 0) { - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), ... [truncated message content] |