|
Home > Archive > Web Servers General Talk > September 2004 > File handling in apache - HELP!!!!
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
File handling in apache - HELP!!!!
|
|
| marsou 2004-09-28, 4:14 am |
| Hello all,
Help me please...
This is going on on WIndows
In my apache module's fixup function I am opening a file(with fopen)
and getting its descriptor(with fileno). The value is 3. If I open 9
files its value is 12. Everything is clear and OK. Then without
closing the files I am adding the same thing (fopen() and fileno())in
apache sources, in the point when the request output is sent.
I assumed that the descriptor will be 13(because both were opened with
fopen not ap_pfopen).
BUT the descriptor is 5.
Everything is going on in the same process and the same thread.
Can anyone explain me what's going on here??
PLEASE?
Regards
M
| |
| marsou 2004-09-28, 4:14 am |
| Thank you for your reply,
> Does Windows even guarantee that _open ... and _dup will return the lowest >available "handle" ... value? I don't see any such
> guarantee in the Windows documentation....
I really don't need the value to be the lowest. The only thing that I
need is that I could use the descriptor returned to me by fopen to
write into that file. And apparently I couldn't do that inside the
apache sources. When I tried it returned me -1 with errno = EBADF
>
> - Handle 5 was closed prior to the fopen call in Apache. You say
> you didn't close it, but are you completely sure that nothing else
> did?
I can say that nothing closed my file because after the apache codes
in my logger function I could normally write to file using the same
handle
regarding the 2 different librarys issue - I then tried to use only
_open(you are right I just accidentally didn't copy the underscore)
but the result is the same

| |
| Michael Wojcik 2004-09-28, 5:59 pm |
|
In article <17f3052f.0409222333.599839b0@posting.google.com>, m_a_r_s_o_u@yahoo.com (marsou) writes:
>
> regarding the 2 different librarys issue - I then tried to use only
> _open(you are right I just accidentally didn't copy the underscore)
> but the result is the same
On Windows, _open is implemented in the C runtime library, so the
two-libraries issue remains. If your code is linked against one C
runtime and the Apache code is linked against another, then the
descriptors probably can't be shared.
In fact, they almost certainly can't, since it appears from the
Microsoft stdio.h that they're indices into the _iob array, which
will be private to each copy of the C runtime.
You'll have to ensure that your code is linked against the same C
runtime as the Apache code. This is a well-understood problem in
Windows development; I recommend consulting MSDN or one of the
Windows programming groups.
Note that the "depends" utility should be able to tell you which C
runtime you're using, and which one Apache is using.
--
Michael Wojcik michael.wojcik@microfocus.com
Pseudoscientific Nonsense Quote o' the Day:
From the scientific standpoint, until these energies are directly
sensed by the evolving perceptions of the individual, via the right
brain, inner-conscious, intuitive faculties, scientists will never
grasp the true workings of the universe's ubiquitous computer system.
-- Noel Huntley
|
|
|
|
|