e ap_hook_child_init() function
but no similar exit()-function. Moreover, I need to access the request
identifier and log to a file. Can all this be done in an Apache
module?
Hope you can help!
Cheers,
Andrej
--
Andrej van der Zee
2-40-19 Koenji-minami
Suginami-ku, Tokyo
166-0003 JAPAN
Mobile: 0031-
bsite, but
the link for "Autogenerated Apache 2 code documentation" is not
working.
Thank you,
Andrej
--
Andrej van der Zee
2-40-19 Koenji-minami
Suginami-ku, Tokyo
166-0003 JAPAN
Mobile: 0031-(0)80-65251092
Phone/Fax: 0031-(0)3-3318-3155
he fixups
> and log_transaction events. Next you implement the two callbacks and
> that's it.
>
That's clear.
Cheers,
Andrej
--
Andrej van der Zee
2-40-19 Koenji-minami
Suginami-ku, Tokyo
166-0003 JAPAN
Mobile: 0031-(0)80-65251092
Phone/Fax: 0031-(0)3-3318-3155
the module.
Does anybody know if the hook functions of such modules usually
spawning a new thread/process? My guess is that at least for compiled
CGI application written in C/C++ a new process is forked in the hook
function.
Cheers,
Andrej
--
Andrej van der Zee
2-40-19 Koenji-minami
Suginami-
Hi,
I am new to Apache modules and I am trying to open a file in the hook
post_read_request and write to the file in log_transaction. The file
is supposed to be only valid for the duration of the request and is
named with a unique identifier (created by mod_unique_id). The
apr_file_t is carried, w
Hi,
Thanks for your reply.
I found that I memset() the req_cfg to 0 *after *I open the file. I am sorry
for wasting your time Anyway, please read on for more comments
>
> Maybe you fail to open the file and the error is not logged correctly.
Write
>
> ap_log_error(APLOG_MARK, APLOG_ERR,
Hi,
> > 1) What is the "recommended" way to carry the
> > GET/POST request identifier (inserted by the
> > developer of the web page) from the client
> > to Apache?
>
>You're not going to get the browser to send
> a custom header by any changes you make to the
> page, except possibly using Aj
Hi,
A post doesn't normally have anything in the
> QUERY_STRING. Rather a POSTed form has the stuff
> being sent in the request body, which is read from
> STDIN by a script. QUERY_STRING is still available
> for use. Consider this form:
>
> form method=post action=myscript.cgi
> input name=em
Hi,
I am writing my first Apache module for monitoring resource usage of
embedded interpreters and CGI applications on Linux (I am also adapting
mod_cgi and the apr-library). The problem is that my own module has some
server-level configuration options that I can initialize and use in my own
modul
Hi,
I am writing my first Apache module for monitoring resource usage of
embedded interpreters and CGI applications on Linux (I am also adapting
mod_cgi and the apr-library). The problem is that my own module has some
server-level configuration options that I can initialize and use in my own
modul
7;t acquire mod_cache server configuration
> structure.",
>__func__);
>return;
> }
>
> On 9/13/08, Andrej van der Zee <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I am writing my first Apache module for monitoring resourc
Hi,
I wrote my first Apache module that gathers performance data of each
request. Currently, I write the information to a log file in the
log_transaction hook function. I would like to write this to a MySQL
database instead. What is the recommended way to do this?
Cheers,
Andrej
--
Andrej van
Hi,
I am using mod_dbd for the first time and get into trouble when I
execute the following in sequence:
1) do an INSERT
2) do a SELECT
3) do another INSERT
On 3) I get the error "Commands out of sync; you can't run this
command now". This is what MySQL sais:
"If you get Commands out of sync; y
Hi,
When I execute two SELECT statements after each other I do not get the
"Comamnd out of sync" error anymore if I iterate through all the rows
in the apr_dbd_results_t, but I do get all emty values and column
names for the 2nd SELECT.
>
> Can you please post your code ?
>
Below the code. The s
Hi,
I was wondering what would be the right way to get the number of bytes
/ packets that are sent / received in an Apache module for httpd-2.1
and higher (including the HTTP headers).
Cheers,
Andrej
Hi,
I was wondering what the purpose is of the macros
APR_DECLARE_OPTIONAL_FN and APR_RETRIEVE_OPTIONAL_FN. For example, in
mod_authn_dbd APR_RETRIEVE_OPTIONAL_FN is used to get a hold on the
functions ap_dbd_acquire and ap_dbd_prepare declared in in mod_dbd
with APR_DECLARE_OPTIONAL_FN. I could a
Hi,
> Without them, it became impossible to build plugable frameworks without
> linking one module to another.
Yes of course, that would be necessary if you compile your module
outside the httpd source tree with apxs I guess.
Thanks a lot,
Andrej
Hi,
I am trying to use prepared INSERT statements for mod_dbd with the
mysql driver, but somehow always a 0 is written to the database
instead of a string. This is what I do:
// In configuration directives stage
ap_dbd_prepare(s, "INSERT INTO request_type (name) VALUES (%s) "
"ON DUPLICATE KE
Hi,
I am compiling mod_cgi with apxs outside the httpd-2.2.9 source tree.
When I choose --with-mpm=prefork this works fine, but when I use
--with-mpm=worker it seems not to use the implementation in the module
at all (the cgi_handler hook method is never called, but CGI
applications seem to work f
Hi,
You call ap_dbd_prepare from prep_stmt_config_set_prep_stmt_on. This
> function is called during the conf parsing phase when there are no
> apache children processes. cmd->server refers to the server structure
> of the root apache process (the parent of all future apache children).
> Then the
Hi,
* apr_dbd_pvquery is only for string values.
>
> You must use apr_dbd_pvbquery (with a "b") for binary values.
>
> see:
> http://apr.apache.org/docs/apr-util/1.3/group___a_p_r___util___d_b_d.html
I tried both versions, but without success. But that was because I did not
pass pointers to fl
Hi,
I was wondering if it is possible to get a hold on the data that is actually
sent back to the client, preferably in the hook ap_hook_log_transaction. In
our case we sent back XML data that might be zipped by mod_deflate. If it is
zipped, I would like to get a hold on the zipped XML data, other
Hi,
I was wondering if it is possible to override the function
"apr_proc_create" with my own version in my own module. This function
is eventually called by "ap_os_create_privilileged_process" in my own
module. I rather do not want to change the apr-source code, therefor I
am looking for a solutio
Hi,
I was wondering if it is possible to load modules at run-time, without
restarting httpd?
Cheers,
Andrej
Hi,
I was wondering if it is possible to get the connection speed in an
Apache module. Actually, I can get to the actual bytes transferred
to/from the client, so the transfer time would also do.
Thank you,
Andrej
Hi Ray,
Thanks for your reply.
> see mog_logio for the actual bytes transferred
> and mod_status or others for examples of the time
> required.
I need the duration of network transfer per HTTP request and response,
but I cannot find this information in mod_status. Are there any
specific points i
by the process. How should I do this?
Thank you,
Andrej
--
Andrej van der Zee
2-40-19 Koenji-minami
Suginami-ku, Tokyo
166-0003 JAPAN
Mobile: +81-(0)80-65251092
Phone/Fax: +81-(0)3-3318-3155
>
> You hook child_init (ap_hook_child_init) and store your data in global
> variables that are accessed by post_read_request and log_transaction.
>
Easy enough.
Thanks,
Andrej
Hi,
>
> You hook child_init (ap_hook_child_init) and store your data in global
> variables that are accessed by post_read_request and log_transaction.
>
BTW, in a worker-MPM, is child_init executed for every created
worker-thread? Or is it per process?
Thank you,
Andrej
Hi,
>
> Global variables are fine if your module will never run multithreaded, or
> you won't write to the data structures from any potentially threaded
> situation.
>
> If you want to be able to run multithreaded, you can mutex access to the
> globals. If you want to decide at runtime, you can f
Hi,
I need to modify Apache and run one custom background thread. In addition,
my custom modules have to be able to share a data structure with this
background thread. Did anybody do this before? Is there an example I can use
as a starting point?
Thank you,
Andrej
--
Andrej van der Zee
2-40
Hi,
> Yes, I did this. I will send you a commented source file sometimes
> today or early tomorrow (Central European Time), I don't really have
> time now.
>
>
Great, I will be waiting for that!
Thanks,
Andrej
Hi,
Thanks for the info.
For the worker mpm, both cross thread and cross process protection will be
> needed. apr_proc_mutex.h family supplies cross-process protection,
> apr_thread_mutex.h provides cross thread protection.
>
> You "locking" method would be a wrapper method that first obtains a p
Hi,
I found this piece of code for dealing with the post_config issue (it is
called twice, while I need to initialise my stuff only once):
void *data;
const char *userdata_key = "post_config_only_once_key";
apr_pool_userdata_get(&data, userdata_key, s->process->pool);
if (!data) {
apr
Hi Saju,
For the worker mpm, both cross thread and cross process protection will be
> needed. apr_proc_mutex.h family supplies cross-process protection,
> apr_thread_mutex.h provides cross thread protection.
>
> You "locking" method would be a wrapper method that first obtains a process
> level lo
Hi,
Do not do this - a restart should be a restart, not a half of a restart.
> You should be reinitializing whatever you do on a restart as well as a
> start. That's the whole point.
>
> I have one phrase that should illustrate why : memory leak.
>
> For example, if your extension creates anoth
Hi,
Thanks for your comments. See below...
Worker mpm is a multithreaded, multiprocess mpm. Multiple child processes
> host multiple worker threads that run your module code.
>
> If your module services 2 concurrent requests in 2 different threads in the
> same process and both the threads need t
Hi,
Register a function with the cleanup of the conf pool. The conf pool
>> is destroyed prior to a restart/kill/reload.
>>
>> You have an example in the code I've sent you.
>>
>> S
>>
>>
>>
> Perfect answer! Unfortunately, the post_config is called twice on a
> restart, and with different memor
Hi,
> My point is that within a single process, multiple threads can service
> requests that can end up firing your module code. If you only do process
> locking you can still have more than 1 thread executing your module code at
> the same time.
>
> Just a process level lock will *not* guarante
Hi,
>
> http://httpd.apache.org/docs/2.2/developer/modules.html
>
> ap_hook_pre_connection
> do any setup required just before processing, but after accepting
>
> ap_hook_create_request
> ??
>
> (Assuming) ap_hook_create_request will be called when creating a request_rec
> * for each request
Hi,
I was wondering if there is an analogue hook like child_init() for
threads that I can use for doing some time-consuming
thread-initialisation that should not slow down an HTTP request
handler. More specific, I want to initialise some per-thread variables
that come from a database. Does the APR
Hi,
I believe I read some while ago that it is possible to start httpd
with only one child (a special for debugging httpd). I am not able to
find this option anymore. Does such an option really exist?
Thank you,
Andrej
Hi,
I am looking for a way to find out if I need to set thread-based
mutexes in case of MPM worker. I see that most modules use the define
APR_HAS_THREADS. I was using this, but I found that it is defined even
when I am using MPM prefork. I was hoping somebody could shed some
light on this issue.
Hi,
Thanks for your reply.
>
> AFAIK there's no support for such thing in apache. Have a look
> yourself in server/mpm/worker/worker.c.
>
> You can hook create_connection (the first hook offered by apache in a
> thread after its creation). However, create_connection is called
> several times duri
Hi,
Thanks.
>
> Yes. create_connection() is the first hook run as part of request
> processing, a delay in create_connection() will result in a delay in HTTP
> processing.
>
That's too bad. I guess I have to hack this into the MPM then.
One more question, what would be the way to store thread-s
Hi,
Thanks, that helps!
Since I am developing my modules in C++, I think I should be using this one:
apr_status_t apr_thread_data_set( void * data,
const char *key,
apr_status_t(*)(void *) cleanup,
apr_thread_t *
Hi,
>
> Note that there is a difference between the apr_thread_data_*() methods and
> the apr_threadkey_private_*() methods. The apr_thread_data_*() methods
> actually associate your data with the thread->pool. Since each new apr
> thread has it's own private thread->pool everything should work fi
Hi,
>
> apr_os_thread_t os_thd = apr_os_thread_current ();
> apr_thread_t *apr_thd;
> apr_status_t apr_os_thread_put(&apr_thd, &os_thd, r->pool);
>
Okay, this clearly doesn't work. I misunderstood the documentation,
but the sources don't lie. Anyway, how can I get the apr_thread_t for
the curren
Hi,
Is there a way to let a MPM worker thread exit after serving X requests? I
need to do some tests that requires checking if my custom hook
ap_hook_thread_exit() is called properly. I found a directive to have one
thread per child that gets me in the right direction (ThreadsPerChild 1).
Now I ne
Hi,
If I am correct, on Linux all childs in MPM prefork share the same
mod_php.so which is loaded in the parent process. Is there a way to
load mod_php.so separately for each forked child? Can I force such a
thing in httpd.conf or maybe in the child_init() hook in a module?
Cheers,
Andrej
Hi,
I have an Apache module for mpm-prefork that runs a background thread.
The thread is initialized in ap_hook_child_init() which works just
fine. But, I have to finish the thread neatly when the process exits.
How can I force this? I could not find any hook-method that is called
before the proce
Hi,
>
> Register a cleanup on the pool passed to your child_init function.
>
Yes of course, thank you.
Cheers,
Andrej
Hi,
I am using mod_cgi using Cgicc with C++ on Linux. I need a way to detect
disconnects from the client. I think I have a way to do this, but I wanted
to make sure if there is no easier way.
I am writing a space back to the client every second as part if a custom
HTTP response header. When the c
Hi,
I want to override a library that is linked with an Apache module,
i.e. I want to use my modified version of the MySQL client library for
example for mod_php. I would like to do this without relinking or even
modifying the mod_php lib. I was hoping that I could use something
like LD_PRELOAD to
Hi William,
>
> LoadFile
>
Saving on ink aren't you ;) Thanks for the advise, I will give it a go soon.
Just one question you might be able to answer. From the documentation
it looks like LoadFile is used to add additional code. In my case, I
need to override existing functionality. For example,
Hi,
>
> When mod_php is loaded into httpd, it's mysql dependencies/symbols will get
> resolved against the mysql client you have already LoadFile'd into httpd.
>
Thanks that is could news, so the libraries in LoadFile directives are
loaded first.
Thanks,
Andrej
Hi,
Maybe a bit off-topic for this mailing list, but I need to do the same
preload-trick for CGI applications written in C++. I was thinking
about a wrapper bash-script that usese LD_PRELOAD in addition to a
rewrite rule in Apache directive. I have some problems with the
wrapper script:
#!/bin/ba
Hi Sorin,
>
> In the Debian package of apache there's /etc/apache2/envvars. I'm not
> sure if this file appears in an out-of-the-box compilation of apache2.
> Anyway, /usr/sbin/apache2ctl looks for it and loads it before
> launching the server.
>
> The server in launched in the environment that is
Hi,
I am looking for way to examine the HTTP response generated by
BalanceMember in my module that runs on the load balancer. I would
like to read a custom HTTP response header that is added by the
application, but I would like to read it on the load-balancer. I tried
to read it in the ap_hook_log
Hi,
I have a question about apr_pool_cleanup_register for a child's pool.
I register a cleanup function that is called when the pool is
destroyed. In the cleanup function, I join a background thread that
first writes some log to a database:
static void mbrace_child_init(apr_pool_t *pool, server_r
Hi,
> Do you create a background thread per apache process? Or do you have a
> single background thread that is used by all apache processes? Which
> hook creates the background thread?
The background thread is created by ap_hook_child_init, thus every
child process has one running background thr
Hi,
>
> This and try running httpd through valgrind.
>
How can I do that?
Thanks,
Andrej
Hi Bronto,
>
> http://lmgtfy.com/?q=apache+httpd+valgrind
>
Thank you for the tip :) You are funny!
Cheers,
Andrej
Hi,
I have a question about mod_cgi. How does it react if the client
breaks the connection with Apache? In Wireshark I see that the client
sends a FIN and the server responds with an ACK. But the server only
sends the FIN after the CGI script actually finishes and sends it
data. In my setup, this
64 matches
Mail list logo