Am 15.06.2005 um 09:26 schrieb Stephen Deasey:
On 6/15/05, Zoran Vasiljevic <[EMAIL PROTECTED]> wrote:
Am 15.06.2005 um 08:54 schrieb Stephen Deasey:
How will you load modules at startup? dlopen() etc. take a file
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)
== NS_OK) {
result = Ns_ConnReturnData(conn,status,
fmap.addr,fmap.size, type);
NsMemUmap(&fmap);
} else {
fd = open(file, O_RDONLY | O_BINARY);
if (fd == -1) {
Ns_Log(Warning, "fastpath: open(%s) failed: %s", file,
strerror(errno));
goto notfound;
}
result = Ns_ConnReturnOpenFd(conn, status,type, fd,stPtr-
>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)
== NS_OK) {
result = Ns_ConnReturnData(conn,status,
fmap.addr,fmap.size, type);
NsMemUmap(&fmap);
} else if (servPtr->fastpath.vfs
&& NsVfsLoad(file, buf) == NS_OK) {
result = Ns_ConnReturnData(conn, status, buf, stPtr-
>st_size, type);
} else {
fd = open(file, O_RDONLY | O_BINARY);
if (fd == -1) {
Ns_Log(Warning, "fastpath: open(%s) failed: %s", file,
strerror(errno));
goto notfound;
}
result = Ns_ConnReturnOpenFd(conn, status,type, fd,stPtr-
>st_size);
close(fd);
}
This will induce absolutely no performance hit and it is about only
place where speed matters, AFAIK.
Zoran