From: Zoran V. <vas...@us...> - 2005-10-10 13:20:36
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15276/nsd Modified Files: adpeval.c fastpath.c Log Message: Use Tcl_FSStat and Tcl_StatBuf instead of the Tcl_Stat compat wrapper. Index: fastpath.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/fastpath.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** fastpath.c 10 Oct 2005 09:32:04 -0000 1.22 --- fastpath.c 10 Oct 2005 13:20:31 -0000 1.23 *************** *** 80,84 **** static void DecrEntry (File *filePtr); static int UrlIs (CONST char *server, CONST char *url, int dir); ! static int FastStat (CONST char *file, struct stat *stPtr); static int FastGetRestart (Ns_Conn *conn, CONST char *page); static int ParseRange (Ns_Conn *conn, Range *rangesPtr); --- 80,84 ---- static void DecrEntry (File *filePtr); static int UrlIs (CONST char *server, CONST char *url, int dir); ! static int FastStat (CONST char *file, Tcl_StatBuf *stPtr); static int FastGetRestart (Ns_Conn *conn, CONST char *page); static int ParseRange (Ns_Conn *conn, Range *rangesPtr); *************** *** 86,90 **** static int FastReturn (NsServer *servPtr, Ns_Conn *conn, int status, CONST char *type, CONST char *file, ! struct stat *stPtr); static int ReturnRange (Ns_Conn *conn, Range *rangesPtr, Tcl_Channel chan, --- 86,90 ---- static int FastReturn (NsServer *servPtr, Ns_Conn *conn, int status, CONST char *type, CONST char *file, ! Tcl_StatBuf *stPtr); static int ReturnRange (Ns_Conn *conn, Range *rangesPtr, Tcl_Channel chan, *************** *** 146,150 **** Ns_ConnReturnFile(Ns_Conn *conn, int status, CONST char *type, CONST char *file) { ! struct stat st; char *server; NsServer *servPtr; --- 146,150 ---- Ns_ConnReturnFile(Ns_Conn *conn, int status, CONST char *type, CONST char *file) { ! Tcl_StatBuf st; char *server; NsServer *servPtr; *************** *** 269,282 **** UrlIs(CONST char *server, CONST char *url, int dir) { ! Ns_DString ds; ! int is = NS_FALSE; ! struct stat st; Ns_DStringInit(&ds); ! if (Ns_UrlToFile(&ds, server, url) == NS_OK ! && Tcl_Stat(ds.string, &st) == 0 ! && ((dir && S_ISDIR(st.st_mode)) ! || (dir == NS_FALSE && S_ISREG(st.st_mode)))) { ! is = NS_TRUE; } Ns_DStringFree(&ds); --- 269,288 ---- UrlIs(CONST char *server, CONST char *url, int dir) { ! Ns_DString ds; ! int status, is = NS_FALSE; ! Tcl_Obj *path; ! Tcl_StatBuf st; Ns_DStringInit(&ds); ! if (Ns_UrlToFile(&ds, server, url) == NS_OK) { ! path = Tcl_NewStringObj(ds.string, -1); ! Tcl_IncrRefCount(path); ! status = Tcl_FSStat(path, &st); ! Tcl_DecrRefCount(path); ! if (status == 0 ! && ((dir && S_ISDIR(st.st_mode)) ! || (dir == NS_FALSE && S_ISREG(st.st_mode)))) { ! is = NS_TRUE; ! } } Ns_DStringFree(&ds); *************** *** 334,342 **** NsFastGet(void *arg, Ns_Conn *conn) { ! Ns_DString ds; ! NsServer *servPtr = arg; ! char *url = conn->request->url; ! int result, i; ! struct stat st; Ns_DStringInit(&ds); --- 340,349 ---- NsFastGet(void *arg, Ns_Conn *conn) { ! Ns_DString ds; ! NsServer *servPtr = arg; ! char *url = conn->request->url; ! int status, result, i; ! Tcl_Obj *path; ! Tcl_StatBuf st; Ns_DStringInit(&ds); *************** *** 365,369 **** } Ns_DStringVarAppend(&ds, "/", servPtr->fastpath.dirv[i], NULL); ! if (Tcl_Stat(ds.string, &st) == 0 && S_ISREG(st.st_mode)) { if (url[strlen(url) - 1] != '/') { Ns_DStringTrunc(&ds, 0); --- 372,380 ---- } Ns_DStringVarAppend(&ds, "/", servPtr->fastpath.dirv[i], NULL); ! path = Tcl_NewStringObj(ds.string, -1); ! Tcl_IncrRefCount(path); ! status = Tcl_FSStat(path, &st); ! Tcl_DecrRefCount(path); ! if (status == 0 && S_ISREG(st.st_mode)) { if (url[strlen(url) - 1] != '/') { Ns_DStringTrunc(&ds, 0); *************** *** 466,470 **** static int ! FastStat(CONST char *file, struct stat *stPtr) { if (Tcl_Stat(file, stPtr) != 0) { --- 477,481 ---- static int ! FastStat(CONST char *file, Tcl_StatBuf *stPtr) { if (Tcl_Stat(file, stPtr) != 0) { *************** *** 498,502 **** static int FastReturn(NsServer *servPtr, Ns_Conn *conn, int status, CONST char *type, ! CONST char *file, struct stat *stPtr) { int new, nread, result = NS_ERROR; --- 509,513 ---- static int FastReturn(NsServer *servPtr, Ns_Conn *conn, int status, CONST char *type, ! CONST char *file, Tcl_StatBuf *stPtr) { int new, nread, result = NS_ERROR; Index: adpeval.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/adpeval.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** adpeval.c 10 Oct 2005 09:32:03 -0000 1.7 --- adpeval.c 10 Oct 2005 13:20:31 -0000 1.8 *************** *** 94,98 **** */ ! static Page *ParseFile(NsInterp *itPtr, CONST char *file, struct stat *stPtr); static void PushFrame(NsInterp *itPtr, Frame *framePtr, CONST char *file, int objc, Tcl_Obj *objv[], Tcl_DString *outputPtr); --- 94,98 ---- */ ! static Page *ParseFile(NsInterp *itPtr, CONST char *file, Tcl_StatBuf *stPtr); static void PushFrame(NsInterp *itPtr, Frame *framePtr, CONST char *file, int objc, Tcl_Obj *objv[], Tcl_DString *outputPtr); *************** *** 280,285 **** Tcl_Interp *interp = itPtr->interp; Tcl_HashEntry *hPtr; ! struct stat st; ! Ns_DString tmp, path; Frame frame; InterpPage *ipagePtr; --- 280,286 ---- Tcl_Interp *interp = itPtr->interp; Tcl_HashEntry *hPtr; ! Tcl_StatBuf st; ! Tcl_Obj *path; ! Ns_DString tmp, ds; Frame frame; InterpPage *ipagePtr; *************** *** 292,298 **** ipagePtr = NULL; pagePtr = NULL; - status = TCL_ERROR; /* Assume error until accomplished success */ Ns_DStringInit(&tmp); ! Ns_DStringInit(&path); key = (char *) &ukey; --- 293,298 ---- ipagePtr = NULL; pagePtr = NULL; Ns_DStringInit(&tmp); ! Ns_DStringInit(&ds); key = (char *) &ukey; *************** *** 302,312 **** if (Ns_PathIsAbsolute(file)) { ! Ns_NormalizePath(&path, file); } else { Ns_MakePath(&tmp, itPtr->adp.cwd, file, NULL); ! Ns_NormalizePath(&path, tmp.string); Ns_DStringTrunc(&tmp, 0); } ! file = path.string; /* --- 302,312 ---- if (Ns_PathIsAbsolute(file)) { ! Ns_NormalizePath(&ds, file); } else { Ns_MakePath(&tmp, itPtr->adp.cwd, file, NULL); ! Ns_NormalizePath(&ds, tmp.string); Ns_DStringTrunc(&tmp, 0); } ! file = ds.string; /* *************** *** 331,334 **** --- 331,335 ---- (char *) Tcl_GetStringResult(interp)); itPtr->adp.exception = ADP_ABORT; + status = TCL_ERROR; goto done; } *************** *** 353,357 **** */ ! if (Tcl_Stat(file, &st) != 0) { Tcl_AppendResult(interp, "could not stat \"", file, "\": ", Tcl_PosixError(interp), NULL); --- 354,363 ---- */ ! path = Tcl_NewStringObj(file, -1); ! Tcl_IncrRefCount(path); ! status = Tcl_FSStat(path, &st); ! Tcl_DecrRefCount(path); ! ! if (status != 0) { Tcl_AppendResult(interp, "could not stat \"", file, "\": ", Tcl_PosixError(interp), NULL); *************** *** 463,466 **** --- 469,474 ---- ++ipagePtr->pagePtr->evals; Ns_MutexUnlock(&servPtr->adp.pagelock); + } else { + status = TCL_ERROR; } if (itPtr->adp.debugLevel > 0) { *************** *** 469,473 **** done: ! Ns_DStringFree(&path); Ns_DStringFree(&tmp); --- 477,481 ---- done: ! Ns_DStringFree(&ds); Ns_DStringFree(&tmp); *************** *** 689,697 **** static Page * ! ParseFile(NsInterp *itPtr, CONST char *file, struct stat *stPtr) { Tcl_Interp *interp = itPtr->interp; Tcl_Encoding encoding; Tcl_DString utf; char *page, *buf; int n, trys, status; --- 697,706 ---- static Page * ! ParseFile(NsInterp *itPtr, CONST char *file, Tcl_StatBuf *stPtr) { Tcl_Interp *interp = itPtr->interp; Tcl_Encoding encoding; Tcl_DString utf; + Tcl_Obj *path; char *page, *buf; int n, trys, status; *************** *** 719,723 **** */ ! status = Tcl_Stat(file, stPtr); if (status != 0) { Tcl_AppendResult(interp, "could not stat \"", file, "\": ", --- 728,736 ---- */ ! path = Tcl_NewStringObj(file, -1); ! Tcl_IncrRefCount(path); ! status = Tcl_FSStat(path, stPtr); ! Tcl_DecrRefCount(path); ! if (status != 0) { Tcl_AppendResult(interp, "could not stat \"", file, "\": ", |