From: Zoran V. <zv...@ar...> - 2005-06-15 08:06:50
|
Am 15.06.2005 um 09:26 schrieb Stephen Deasey: > On 6/15/05, Zoran Vasiljevic <zv...@ar...> wrote: > >> >> Am 15.06.2005 um 08:54 schrieb Stephen Deasey: >> >>> >>> How will you load modules at startup? dlopen() etc. take a file =20 >>> name. >>> >>> >> >> I will start with this and see if it suffices: >> >> Tcl_FSLoadFile dynamically loads a binary code file into >> memory and >> returns the addresses of two procedures within that file, if >> they are >> defined. The appropriate function for the filesystem to >> which pathPtr >> belongs will be called. If that filesystem does not >> implement this >> function (most virtual filesystems will not, because of OS >> limitations >> in dynamically loading binary code), Tcl will attempt to copy >> the file >> to a temporary directory and load that temporary file. >> > > > Oh, that'll work. > > How about registering your own handler on /* just as the core server > does at startup? That way the fastpath code won't be called unless > you explicitly call it. You can send files using > Ns_ConnSendChannel(). I believe we are basically talking about this code in fastpath.c: if (servPtr->fastpath.mmap && NsMemMap(file, stPtr->st_size, NS_MMAP_READ, &fmap) =20 =3D=3D NS_OK) { result =3D Ns_ConnReturnData(conn,status, =20 fmap.addr,fmap.size, type); NsMemUmap(&fmap); } else { fd =3D open(file, O_RDONLY | O_BINARY); if (fd =3D=3D -1) { Ns_Log(Warning, "fastpath: open(%s) failed: %s", file, strerror(errno)); goto notfound; } result =3D Ns_ConnReturnOpenFd(conn, status,type, fd,stPtr-=20= >st_size); close(fd); } I recently added wrappers for platform-neutral mmap. I can imagine something like: if (servPtr->fastpath.mmap && NsMemMap(file, stPtr->st_size, NS_MMAP_READ, &fmap) =20 =3D=3D NS_OK) { result =3D Ns_ConnReturnData(conn,status, =20 fmap.addr,fmap.size, type); NsMemUmap(&fmap); =10=10=10=10=10=10=10=10=10=10=10=10=10=10=10=10} else if = (servPtr->fastpath.vfs && NsVfsLoad(file, buf) =3D=3D NS_OK) { result =3D Ns_ConnReturnData(conn, status, buf, stPtr-=20 >st_size, type); } else { fd =3D open(file, O_RDONLY | O_BINARY); if (fd =3D=3D -1) { Ns_Log(Warning, "fastpath: open(%s) failed: %s", file, strerror(errno)); goto notfound; } result =3D Ns_ConnReturnOpenFd(conn, status,type, fd,stPtr-=20= >st_size); close(fd); } This will induce absolutely no performance hit and it is about only place where speed matters, AFAIK. Zoran |