Re: modify request_rec->args

2016-03-24 Thread Luca Toscano
Hello Justin!

2016-03-25 0:59 GMT+01:00 Justin Kennedy :

> Hello,
>
> I have a simple module, with just a quick_hander, it's sole function is to
> check if there is a specific key=value on the query string, and modify the
> value, so it gets picked up by a separate module.
>
> For example: if "foo=1" is in r->args, then replace it with "foo=0",
> decline the request so it gets picked up by the other module.
>
> In my first attempt, I created a new string and assigned the pointer to
> r->args, but it doesn't seem to "stick" when it gets to the second module.
> Do I have to modify r->args directly, without changing the pointer? It's
> been awhile since I've worked with C strings.
>
>
Have you read
https://httpd.apache.org/docs/2.4/developer/modguide.html#handling? There
is an interesting section about memory management and an example about
query strings.

Hope that helps!

Luca


modify request_rec->args

2016-03-24 Thread Justin Kennedy
Hello,

I have a simple module, with just a quick_hander, it's sole function is to
check if there is a specific key=value on the query string, and modify the
value, so it gets picked up by a separate module.

For example: if "foo=1" is in r->args, then replace it with "foo=0",
decline the request so it gets picked up by the other module.

In my first attempt, I created a new string and assigned the pointer to
r->args, but it doesn't seem to "stick" when it gets to the second module.
Do I have to modify r->args directly, without changing the pointer? It's
been awhile since I've worked with C strings.

Thank you,

-Justin


Re: apr_global_mutex_create vs apr_proc_mutex_create

2016-03-24 Thread William A Rowe Jr
proc_mutex can only be used to block on a cross process event.  It can be
used in a threaded server, but cannot be held in multiple threads, you
might use it to block in a single thread queue per-process.

Thread_mutex will not block between processes, this is used for the
mutex-per-process logic such as a across accept wait queues.

Global_mutex will block, across threads and across processes, as
appropriate.
On Mar 24, 2016 04:08, "Luca Toscano"  wrote:

> +httpd-dev@
>
> Hello!
>
> 2016-03-23 21:49 GMT+01:00 Ali Shah :
>
>> Hi Module maintainers,
>>
>> I'm writing a simple apache module and I'd like to aggregate some
>> statistics.
>> I saw an example module that does this (
>> https://wiki.apache.org/httpd/ModuleLife) using shared memory.
>>
>> My question for those on this list following:
>>
>> What is the main difference between using mutexes created
>> via apr_global_mutex_create and apr_proc_mutex_create in terms of
>> performance and safety of the resource that being protected?
>>
>> The docs seem to discourage usage of apr_global_mutex_create:
>> "There is considerable overhead in using this API if only cross-process or
>> cross-thread mutual exclusion is required."
>>
>> Is the overhead purely in code setup (since global mutex should be
>> initialized in post_config), or is this describing some performance
>> penalties as well?
>>
>
> From what I can see in [1] a global lock uses both apr_proc_mutex_create
> and apr_thread_mutex_create, so this is why the documentation suggests the
> use of a more specialized one if only cross-process or cross-thread sync is
> needed.
>
> Not a great explanation I know, somebody else with more experience will
> give you a better answer on this list :)
>
> Luca
>
>
>
> [1]:
> https://github.com/apache/apr/blob/7951861fb029fd0fb60e5ec8da73015d03afa28d/locks/unix/global_mutex.c#L46
>
>
>