--- Jim Davidson <[EMAIL PROTECTED]> wrote: > Hi, > > You're right -- it's not thread safe. Two options: > > 1. Add the offset & length parameters and have the > server use pread > as you suggest (not sure about the equivalent on > win32). I suppose > this would technically not be backward compatible in > case someone was > expecting the current seek position to change as a > result of the call > so perhaps a new API such as Ns_ConnReturnSharedFd > may make more sense. > > 2. Mmap the file and allow multiple threads to use > Ns_ConnReturnData. You should be able to do this in > user code now. >
Unfortunately, the files I'm using are quite large, so under 32 bit OSes, I don't have the address space to mmap the whole file. A new API would work best for my particular application. If you like, I can do the coding and send you diffs from 4.0.10 and/or the current CVS trunk. Windows does suck in not having pread, but if people want the functionality under Windows, I suppose it could be done by mmap()ing the portion of the file to sent, temporarily. Not being a Windows coder (voluntarily), I'm not sure if there's something special you have to do to use large files. Presumably, the right thing to do is have configure check for pread, and fall back to mmap()ing the portion of the file. Fred > > -Jim > > > > > On Jul 12, 2005, at 1:05 AM, Fred Cox wrote: > > > If multiple threads have the same file open, and > would > > like to send portions of it back to the clients, > > Ns_ConnReturnOpenFd() is close to being useful, > but it > > fails because a seek() must be done before before > > calling the API. Also, the documentation > incorrectly > > states that the full file will be sent, ignoring > the > > length parameter. > > > > A version that ultimately uses pread() instead of > > read() would be useful in this case, but I suppose > it > > doesn't fit the FILE * paradigm. I don't know > about > > Tcl channels, so I can't say whether it makes from > > that perspective. > > > > For now, I'm working around this by reading the > > portion of the file into a buffer on the stack and > > doing Ns_ConnReturnData(). > > > > Would it be worth while to append an offset > parameter > > just for the FD case? > > > > Fred > > > > > > > > > ____________________________________________________ > > Sell on Yahoo! Auctions no fees. Bid on great > items. > > http://auctions.yahoo.com/ > > > > > > -- > > AOLserver - http://www.aolserver.com/ > > > > To Remove yourself from this list, simply send an > email to > > <[EMAIL PROTECTED]> with the > > body of "SIGNOFF AOLSERVER" in the email message. > You can leave the > > Subject: field of your email blank. > > > > > -- > AOLserver - http://www.aolserver.com/ > > To Remove yourself from this list, simply send an > email to <[EMAIL PROTECTED]> with the > body of "SIGNOFF AOLSERVER" in the email message. > You can leave the Subject: field of your email > blank. > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- AOLserver - http://www.aolserver.com/ To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> with the body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of your email blank.