Bluehost.com Web Hosting $6.95

File handling in apache - HELP!!!!

This is a discussion on File handling in apache - HELP!!!! within the Windows Web Servers forums, part of the Web Server and Related Forums category; Hello all, Help me please... This is going on on WIndows In my apache module's fixup function I am ...


Go Back   Usenet Forums > Web Server and Related Forums > Windows Web Servers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-22-2004
marsou
 
Posts: n/a
Default File handling in apache - HELP!!!!

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
  #2 (permalink)  
Old 09-23-2004
Michael Wojcik
 
Posts: n/a
Default Re: File handling in apache - HELP!!!!


In article <17f3052f.0409220131.11305c39@posting.google.com >, m_a_r_s_o_u@yahoo.com (marsou) writes:
>
> 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??


Does Windows even guarantee that _open (note that there is no "open"
or "fileno" in Windows; there are, however, "_open" and "_fileno")
and _dup will return the lowest available "handle" (how the MS
documentation refers to its descriptors - not to be confused with
the many other uses of "handle" therein) value? I don't see any such
guarantee in the Windows documentation. (Unix makes this guarantee
for historical reasons; prior to dup2, the only way to force a
particular descriptor value was to make sure it was closed, then dup
until you got the value you wanted.)

If Windows *does* happen to always return the lowest available
handle, though, then I can think of a couple of possibilities:

- 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?

- You're calling more than one of the MS C runtime libraries. This
can be caused by linking DLLs against different C runtimes, and it
produces all sorts of strange effects, because static data in the C
runtime is duplicated.

No doubt there are others.

--
Michael Wojcik michael.wojcik@microfocus.com

[After the lynching of George "Big Nose" Parrot, Dr. John] Osborne
had the skin tanned and made into a pair of shoes and a medical bag.
Osborne, who became governor, frequently wore the shoes.
-- _Lincoln [Nebraska] Journal Star_
  #3 (permalink)  
Old 09-23-2004
marsou
 
Posts: n/a
Default Re: File handling in apache - HELP!!!!

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

:(
  #4 (permalink)  
Old 09-23-2004
marsou
 
Posts: n/a
Default Re: File handling in apache - HELP!!!!

Here is another idea.(Thanks to V.S.)
As you know one should add a DLL to Apache with LoadModule. And the
part that is working with it is also DLL. So maybe the problem is
there?
Different heaps etc..
  #5 (permalink)  
Old 09-23-2004
Michael Wojcik
 
Posts: n/a
Default Re: File handling in apache - HELP!!!!


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
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 11:20 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0