On 2013-09-24 13:04, Christoph Gröver wrote:
Hello Sorin,
I suppose you use the server field of the request_rec structure and
not some stored server_rec that was passed to you in post_config or
somewhere else.
Definitely. I have adopted this from some other module and didn't know
there was another way to obtain a server_rec structure.
So I should be looking for a better way to find the right structure.
Thank you very much. This sounds as if it will be the right way.
I fear there's a misunderstanding here: The right way to get the
server_rec is, in my opinion, from the request_rec structure, i.e. I
think you should use req->server->server_hostname.
So, given that you already do this, it is puzzling for me why you don't
get the result that you want.
Apache sets the req->server pointer to the right server_rec structure
after it has parsed the request headers. (It cannot guess correctly
before it parses the Host header.)
So make sure you check req->server _after_ apache has initialised it to
the right server_rec. Apache sets it in the ap_read_request method.
Almost all of the callbacks provided to the module developers are called
_after_ ap_read_request, so you should be ok. I think only the
create_connection callback is run before ap_read_request.
As a "poor man's debugger" technique you could write a post_config
callback. The last argument of the post_config callback is the head of
the list of server_recs. You could traverse the list and log to a file
the server_hostname of all server_recs in the list. Just to check that
you have the right number of server_recs and that they are correctly
initialised.
Sorin
Apache keeps a linked list of server_rec structures. The head of the
list is the server_rec of the whole apache server. The rest of the
list contains one server_rec structure per vhost. For each request
apache picks the right server_rec from the list according to the Host
header and sets r->server to point to the picked object.
This information will also help. Thank you.
Also make sure that your request really arrives in the vhost you
intended. Typically I check this by logging to different files (see
the CustomLog directive) in each vhost.
This is actually the case. I receive the requests in the right vhost.
I have separate logfiles for each vhost.
Thanks for your answers. I guess I will be able to solve the issue with
these informations.
With kind regards,