Apache modification questions

2008-09-04 Thread Andrej van der Zee
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-

Re: Apache modification questions

2008-09-05 Thread Andrej van der Zee
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

Re: Apache modification questions

2008-09-05 Thread Andrej van der Zee
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

Re: Apache modification questions

2008-09-05 Thread Andrej van der Zee
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-

apr_open_file and apr_write_file in post_read_request and log_transaction

2008-09-09 Thread Andrej van der Zee
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

Re: apr_open_file and apr_write_file in post_read_request and log_transaction

2008-09-09 Thread Andrej van der Zee
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,

Re: Apache modification questions

2008-09-09 Thread Andrej van der Zee
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

Re: Apache modification questions

2008-09-10 Thread Andrej van der Zee
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

Access configuration variable in other modules

2008-09-13 Thread Andrej van der Zee
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

Access configuration variable in other modules

2008-09-13 Thread Andrej van der Zee
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

Re: Access configuration variable in other modules

2008-09-13 Thread Andrej van der Zee
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

writing to database in Apache module

2008-10-02 Thread Andrej van der Zee
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

mod_dbd/apr_dbd and "Commands out of sync"

2008-10-03 Thread Andrej van der Zee
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

Re: mod_dbd/apr_dbd and "Commands out of sync"

2008-10-03 Thread Andrej van der Zee
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

number of bytes/packets sent/received

2008-10-09 Thread Andrej van der Zee
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

APR_DECLARE_OPTIONAL_FN and APR_RETRIEVE_OPTIONAL_FN

2008-10-09 Thread Andrej van der Zee
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

Re: APR_DECLARE_OPTIONAL_FN and APR_RETRIEVE_OPTIONAL_FN

2008-10-09 Thread Andrej van der Zee
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

mod_dbd and prepared statements (httpd-2.2.9)

2008-10-13 Thread Andrej van der Zee
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

mpm worker and mod_cgi

2008-10-16 Thread Andrej van der Zee
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

Re: mod_dbd and prepared statements (httpd-2.2.9)

2008-10-18 Thread Andrej van der Zee
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

Re: mod_dbd and prepared statements (httpd-2.2.9)

2008-10-18 Thread Andrej van der Zee
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

how to get zipped post data in ap_hook_log_transaction?

2008-11-04 Thread Andrej van der Zee
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

override apr_proc_create in own module

2008-11-18 Thread Andrej van der Zee
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

load modules at run-time without restarting httpd

2008-11-19 Thread Andrej van der Zee
Hi, I was wondering if it is possible to load modules at run-time, without restarting httpd? Cheers, Andrej

connection speed / data transfer time

2008-11-25 Thread Andrej van der Zee
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

Re: connection speed / data transfer time

2008-11-25 Thread Andrej van der Zee
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

process initialisation in prefork-MPM

2008-12-22 Thread Andrej van der Zee
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

Re: process initialisation in prefork-MPM

2008-12-22 Thread Andrej van der Zee
> > 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

Re: process initialisation in prefork-MPM

2008-12-22 Thread Andrej van der Zee
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

Re: process initialisation in prefork-MPM

2008-12-22 Thread Andrej van der Zee
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

custom background thread and module sharing a data structure

2009-03-10 Thread Andrej van der Zee
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

Re: custom background thread and module sharing a data structure

2009-03-11 Thread Andrej van der Zee
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

Re: custom background thread and module sharing a data structure

2009-03-12 Thread Andrej van der Zee
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

post_config on reload

2009-03-13 Thread Andrej van der Zee
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

Re: custom background thread and module sharing a data structure

2009-03-13 Thread Andrej van der Zee
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

Re: post_config on reload

2009-03-13 Thread Andrej van der Zee
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

Re: custom background thread and module sharing a data structure

2009-03-13 Thread Andrej van der Zee
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

Re: post_config on reload

2009-03-13 Thread Andrej van der Zee
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

Re: custom background thread and module sharing a data structure

2009-03-13 Thread Andrej van der Zee
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

Re: hook before receiving HTTP request

2009-03-16 Thread Andrej van der Zee
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

child_init for threads?

2009-03-17 Thread Andrej van der Zee
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

start httpd with one child for debugging

2009-03-17 Thread Andrej van der Zee
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

How to find out which MPM process model?

2009-03-17 Thread Andrej van der Zee
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.

Re: child_init for threads?

2009-03-18 Thread Andrej van der Zee
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

Re: child_init for threads?

2009-03-18 Thread Andrej van der Zee
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

Re: child_init for threads?

2009-03-18 Thread Andrej van der Zee
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 *

Re: child_init for threads?

2009-03-18 Thread Andrej van der Zee
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

Re: child_init for threads?

2009-03-19 Thread Andrej van der Zee
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

MaxRequestsPerChild for MPM worker threads?

2009-03-19 Thread Andrej van der Zee
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

load mod_php.so for each child separately

2009-03-26 Thread Andrej van der Zee
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

ap_hook_child_init

2009-07-26 Thread Andrej van der Zee
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

Re: ap_hook_child_init

2009-07-26 Thread Andrej van der Zee
Hi, > > Register a cleanup on the pool passed to your child_init function. > Yes of course, thank you. Cheers, Andrej

detect disconnect in CGI

2009-10-23 Thread Andrej van der Zee
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

LD_PRELOAD for modules

2010-03-26 Thread Andrej van der Zee
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

Re: LD_PRELOAD for modules

2010-03-27 Thread Andrej van der Zee
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,

Re: LD_PRELOAD for modules

2010-03-27 Thread Andrej van der Zee
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

Re: LD_PRELOAD for modules

2010-03-27 Thread Andrej van der Zee
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

Re: LD_PRELOAD for modules

2010-03-27 Thread Andrej van der Zee
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

mod_proxy_balancer and HTTP response header

2010-04-11 Thread Andrej van der Zee
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

*** glibc detected *** double free or corruption (!prev) in cleanup function

2010-04-21 Thread Andrej van der Zee
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

Re: *** glibc detected *** double free or corruption (!prev) in cleanup function

2010-04-22 Thread Andrej van der Zee
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

Re: *** glibc detected *** double free or corruption (!prev) in cleanup function

2010-04-22 Thread Andrej van der Zee
Hi, > > This and try running httpd through valgrind. > How can I do that? Thanks, Andrej

Re: *** glibc detected *** double free or corruption (!prev) in cleanup function

2010-04-22 Thread Andrej van der Zee
Hi Bronto, > > http://lmgtfy.com/?q=apache+httpd+valgrind > Thank you for the tip :) You are funny! Cheers, Andrej

mod cgi

2012-04-19 Thread Andrej van der Zee
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