Writing a monitoring thread in apache filter moudle

2014-04-20 Thread Hassan Monfared
Dear members,
I have global static array in my module which needs to be updated in every
5 seconds in my apache input filter.
I wrote a monitoring thread with boost::thread which runs in background and
updates the list every 5 seconds.
But this works only when I run apache in single thread mode with apachectl-X
in normal execution of apache my thread doesn't work.
The thread is created in register_hooks() function.

Can anybody help me to figure out my problem ?
Thanks.


Hassan H. Monfared
http://www.linkedin.com/pub/hassan-monfared/55/1b6/33
*I*men  *R*ayaneh  *S*hargh,+9821-26219590
CEO and technical manager

My Public Key :
-BEGIN PGP PUBLIC KEY BLOCK-
Version: OpenPGP.js v.1.20130420
Comment: http://openpgpjs.org

xsBNBFKAhwkBB/9vzP/63Qi92K1awWjmzUq9/Ik4ehgkr6wsTzcEu+7RSOM/
bObUKUtt8hEtvXcAuhtQp6SvSZt0QWIsKYYIS4k3FayGpDDyCZkfu7D5gGDg
RoE9aLtVt/FEcECVA7id6jBzWXcw5wPW6edR1Xys3isGoUuXTGN3vuLgAD1z
W5J9sCz+QcxJfzqDvyHT/LKU63tQ9qKqTom33tZeElulPSg3qrUw3MoWkNHH
+W4Igo18JE3TUqFRQnrk9G+PgjJvmGlW9da/RsmOC0v1pbeGD8XHWIc6uj85
6dNK5Kg9QFLnKWOtqAjq0hdkOmfnp972hOeIB61/WQhus0XPqoAQyo1HABEB
AAHNKEhhc3NhbiBILiBNb25mYXJlZCA8aG1vbmZhcmVkQGdtYWlsLmNvbT7C
wFwEEAEIABAFAlKAhwsJEJokPHSAHUdmAADMBwf9GM+NSWGztN85zKSowrE3
cQMkaoWjMJDGCATBAcy2cEMrr3DEzy7RD5yuQWuJ37fyE0lz36QMNjee1ylG
Y3fS7uR95rSJeFjW1/JpQC/q8edmzh1UTwLVJYae0Cp2w9IXY5GH1hCxjL8I
kizaAjh2/MGDmD0+Nd+o2S0sBR9/yubhFQLFLDQfjUJHQjUGoL+kEVPM+nT6
ASscvo05lfjiVS2NeFOKLn2LI1LGCXgtz05hWPLgg6aE6v5VTA2ttF213dFA
s1yUUeIEbDrDPuz5lg/w1CmeTrgMJNxBOCx6WaIKGInDQIQnJumAnwVa34Mw
U7R60ek0jKKeRhbrOAag4w==
=bOWD
-END PGP PUBLIC KEY BLOCK-


Re: Writing a monitoring thread in apache filter moudle

2014-04-20 Thread Nick Kew

On 20 Apr 2014, at 09:05, Hassan Monfared wrote:

 Dear members,
 I have global static array in my module

What do you mean by a global static array?

In normal operation, apache runs multi-process.
So what looks like global static is actually per-process.
Think that through and it'll probably tell you what's wrong.

 I wrote a monitoring thread with boost::thread which runs in background and
 updates the list every 5 seconds.

You'd probably be better off with apr threads: two separate
threading models will add complexity and detract from
portability and maintainability.

Either run the update per-process or use shared memory.
In the latter case, use apache's (and apr's) mechanisms
for shared memory and timed monitoring to avoid introducing
new complexity.

-- 
Nick Kew


Re: svn commit: r1588704 - in /httpd/httpd/trunk: CHANGES modules/cache/cache_util.c

2014-04-20 Thread Marion Christophe JAILLET

Hi,

The description and the CHANGES are about AH00784 but the patch is only 
about adding 'status' to AH00783.


-else if (APR_EEXIST == status) {
+else if (APR_STATUS_IS_EEXIST(status)) {
seems not to change anything.

#define APR_STATUS_IS_EEXIST(s)   ((s) == APR_EEXIST)


So, is something missing in the patch or the CHANGES entry should be 
tweaked?



CJ


Le 19/04/2014 22:21, cove...@apache.org a écrit :

Author: covener
Date: Sat Apr 19 20:21:01 2014
New Revision: 1588704

URL: http://svn.apache.org/r1588704
Log:
Fix errors with CacheLock on Windows:

cache_util.c(757): (OS 80)The file exists.  : [client 127.0.0.1:63889]
AH00784: Attempt to obtain a cache lock for stale cached URL failed,
revalidating entry anyway:

Modified:
 httpd/httpd/trunk/CHANGES
 httpd/httpd/trunk/modules/cache/cache_util.c

Modified: httpd/httpd/trunk/CHANGES
URL: 
http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1588704r1=1588703r2=1588704view=diff
==
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Sat Apr 19 20:21:01 2014
@@ -1,6 +1,9 @@
   -*- coding: utf-8 -*-
  Changes with Apache 2.5.0
  
+  *) mod_cache: Fix AH00784 errors on Windows when the the CacheLock directive

+ is enabled.  [Eric Covener]
+
*) mod_proxy: Preserve original request headers even if they differ
   from the ones to be forwarded to the backend. PR 45387.
   [Yann Ylavic]

Modified: httpd/httpd/trunk/modules/cache/cache_util.c
URL: 
http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/cache_util.c?rev=1588704r1=1588703r2=1588704view=diff
==
--- httpd/httpd/trunk/modules/cache/cache_util.c (original)
+++ httpd/httpd/trunk/modules/cache/cache_util.c Sat Apr 19 20:21:01 2014
@@ -240,7 +240,7 @@ CACHE_DECLARE(apr_int64_t) ap_cache_curr
   * Try obtain a cache wide lock on the given cache key.
   *
   * If we return APR_SUCCESS, we obtained the lock, and we are clear to
- * proceed to the backend. If we return APR_EEXISTS, then the lock is
+ * proceed to the backend. If we return APR_EEXIST, then the lock is
   * already locked, someone else has gone to refresh the backend data
   * already, so we must return stale data with a warning in the mean
   * time. If we return anything else, then something has gone pear
@@ -735,9 +735,9 @@ int cache_check_freshness(cache_handle_t
  r-unparsed_uri);
  return 0;
  }
-else if (APR_EEXIST == status) {
+else if (APR_STATUS_IS_EEXIST(status)) {
  /* lock already exists, return stale data anyway, with a warning */
-ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(00783)
+ap_log_rerror(APLOG_MARK, APLOG_DEBUG, status, r, APLOGNO(00783)
  Cache already locked for stale cached URL, 
  pretend it is fresh: %s,
  r-unparsed_uri);







Re: svn commit: r1588704 - in /httpd/httpd/trunk: CHANGES modules/cache/cache_util.c

2014-04-20 Thread Christophe JAILLET

Le 20/04/2014 08:52, Marion  Christophe JAILLET a écrit :

Hi,

The description and the CHANGES are about AH00784 but the patch is 
only about adding 'status' to AH00783.


-else if (APR_EEXIST == status) {
+else if (APR_STATUS_IS_EEXIST(status)) {
seems not to change anything.

#define APR_STATUS_IS_EEXIST(s)   ((s) == APR_EEXIST)



Oops, just forget my comment.
I based it on on-line APR doc 
(http://apr.apache.org/docs/apr/1.5/group___a_p_r___s_t_a_t_u_s___i_s.html).

APR_STATUS_IS_EEXIST is more subtle than that.


Sorry for the noise.

CJ


Re: Any reason why building with OpenSSL shouldn't add its lib dir to rpath?

2014-04-20 Thread Rainer Jung
On 14.04.2014 13:08, Jeff Trawick wrote:
 (not to say there aren't complications, like trying to keep system
 directories out of rpath)

Adding my current workarounds for 2.4 here for reference.

Here openssl_libs is either -ldl -lz (Linux) or -lz -ldl -lsocket
-lnsl (Solaris). The value of variables like mysql_path, oracle_path
etc. is always the path to the main installation directory of the component.

One caveat: When building against a non-platform OpenSSL one can run
into a runtime linker problem whenever some other library needed by
httpd has a dependency on the platform OpenSSL. An example is the ldap
library, which is often taken from the platform and is lined against
platform OpenSSL. In that case, both OpenSSL versions are loaded.

So which one is used? Whenever an object (module, library) references a
symbol from OpenSSL the runtime linker searches all loaded objects in
load order, so first the httpd binary, then the libs on which httpd
itself depends, then the modules and there dependencies. The first
symbol definition found will be used. So if there are multiple versions
being loaded, then it is quite possible, that although mod_ssl might
trigger loading of a non-platform OpenSSL lib, the code actually running
later is still the platform OpenSSL code. Let me state it again: a
symbol definition needed by a module will *not* be first searched in
that module or its dependencies, but instead in all loaded objects in
load order.

I personally use -Bsymbolic on the Solaris platform and that plus static
linking on Linux to work around this. But that's possibly to complex for
an average user.


A) apr-util (bundled or standalone):


1) Env Vars

export LDADD_crypto_openssl=$openssl_libs -R${openssl_path}/lib
export LDADD_crypto_nss=-R${nss_path}/lib
export LDADD_dbd_mysql=-R${mysql_path}/lib
export LDADD_dbd_oracle=-R${oracle_path}/lib

Only during configure run (bdb = Berkeley DB)

export LD_LIBRARY_PATH=${bdb_path}/lib

Only during make check run (Oracle libclnt needs libnnz but has no
PATH set itself)

export LD_LIBRARY_PATH=${oracle_path}/lib


2) configure script

For APU crypto support changing all lines of type

LIBS=-lssl -lcrypto ...

to

LIBS=-lssl -lcrypto $openssl_libs ...

(for $openssl_libs see above)



3) Makefile - only when building without dso support
   (--disable-util-dso)

Adding rpath, replace

$(LINK) -rpath $(libdir) ...

by

$(LINK) -rpath $(libdir) ${global_rpath} ...

where global_rpath contains - depending on configure flags -

-R${openssl_path}/lib
-R${sqlite_path}/lib
-R${mysql_path}/lib
-R${nss_path}/lib


4) test/Makefile - only when building without dso support
   (--disable-util-dso)

Adding rpath, replacing

APRUTIL_LDFLAGS =...

by

APRUTIL_LDFLAGS =... ${global_rpath}

(for global_rpath see 3))


B) HTTPD 2.4


1) Env Vars

Probably not all -L are currently needed:

   export MOD_SSL_LDADD=-L${openssl_path}/lib -R${openssl_path}/lib
   export MOD_LUA_LDADD=-L${lua_path}/lib -R${lua_path}/lib
   export MOD_XML2ENC_LDADD=-L${libxml2_path}/lib -R${libxml2_path}/lib
   export MOD_PROXY_HTML_LDADD=-L${libxml2_path}/lib -R${libxml2_path}/lib

   export LD_LIBRARY_PATH=${mysql_path}/lib:${oracle_path}/lib


2) configure

Add -lz (OpenSSL dependency), replacing

LIBS=-lssl -lcrypto ...

by

LIBS=-lssl -lcrypto -lz ...

and

ap_openssl_libs=.*apr_config.*

by

ap_openssl_libs=.*apr_config.* -lz


3) support/Makefile

Add -lz (OpenSSL dependency), replacing

ab_LDADD ...

by

ab_LDADD = ... -lz

and because of https support in ab also adding -R${openssl_path}/lib.


Regards,

Rainer


helping users navigate build oddities (e.g., non-standard lib loc) with wizards/recipes

2014-04-20 Thread Jeff Trawick
Maybe there's some infrastructure for this already???

Install location:/usr/local/webstack   (everything goes here -- much
simpler)
Software download location: /home/foo/opensource
Build directory: /home/foo/webstack-build

httpd features:  [X] mod_ssl  [ ] mod_lua [X] mod_proxy_html [X] mod_ldap
.. (those with dependencies)

(this is httpd-centric, so we don't choose/enable random support library
features; we automatically enable the ones required for chosen httpd
features)

Dependencies:

apr: [ ] system [X] use latest in download directory (1.5.0)
apr-util: [ ] system [X] use latest in download directory (1.5.3)
PCRE: [X] system [ ] use latest in download directory
OpenSSL: [] system [X] use latest in download directory (1.0.1g)
libxml2: [X] system [ ] use latest in download directory
zlib: [X] system [ ] use latest in download directory
OpenLDAP: [] system [] use latest in download directory
(dynamic based on httpd and support library features selected)

Build type:

[X] Debug symbols
[ ] Highly optimized
[X] Use architecture-specific code

* setup can be coded in a file too, of course
* profile for httpd, httpd mods with extra dependent libraries, and each
dependent library to indicate what options mean in terms of configure
envvars, configure options, make envvars, etc.
* profiles for third-party modules too
* among other things, this can serve as the traditional Makefile.win
wrapper on Windows that pulls together different projects (using cmake
under the covers where appropriate)
* shouldn't support every variation
* just support rebuilding everything when updating something

Following the 80/20 rule this can be relatively simple, and solve the
chosen problem as much by guiding users into simple choices as by enabling
magic build options/variables.

-- 
Born in Roswell... married an alien...
http://emptyhammock.com/
http://edjective.org/


Re: svn commit: r1588704 - in /httpd/httpd/trunk: CHANGES modules/cache/cache_util.c

2014-04-20 Thread Eric Covener
On Sun, Apr 20, 2014 at 3:07 AM, Christophe JAILLET
christophe.jail...@wanadoo.fr wrote:
 Sorry for the noise.

Review appreciated nonetheless.


Problem of URL in bugzilla

2014-04-20 Thread Christophe JAILLET

Hi,

When browsing https://issues.apache.org/bugzilla/show_bug.cgi?id=56371, 
in the top most frame, we can see:
ASF Bugzilla – Bug 56371 Please merge r1576233 into the next 
httpd-2.4.10 version, the fix is missing in httpd-2.4.9


But below, we only have:
Bug 56371 - Please merge 0 into the next httpd-2.4.10 version, the fix 
is missing in httpd-2.4.9 (edit)


link to r1576233 has been turned into 0.


In the comment below, we have the same issue, the link to r1576233 is 
turned into 0.



same kind of issue can be seen in the 2nd comment of 
https://issues.apache.org/bugzilla/show_bug.cgi?id=56235




I think it is a bug in bugzilla. We are using version 4.4.4 which has 
been released just 2 days ago.
This release is just a day after 4.4.3. It is a quick fix because of URL 
broken in comments. That is to say, more or less what is described above.

So I guess, that the issue is in bugzilla.


However, before posting a bug report, I wanted to have your feedback.
Is there some custom code in our installation that turns rxx into a 
link to svn repository that should be updated to match changes in 4.4.4 
release?


Best regards,

CJ



Re: Problem of URL in bugzilla

2014-04-20 Thread Rainer Jung
CCing Mark our Bugzilla (and much more) champion, hoping he knows more
or at least needs the info.

@Mark: I think the transform svn revision to link feature is a
Bugzilla global one, not specific to httpd. It seems partially broken
after the recent update, see below for details.

Regards,

Rainer

On 20.04.2014 19:36, Christophe JAILLET wrote:
 Hi,
 
 When browsing https://issues.apache.org/bugzilla/show_bug.cgi?id=56371,
 in the top most frame, we can see:
 ASF Bugzilla – Bug 56371 Please merge r1576233 into the next
 httpd-2.4.10 version, the fix is missing in httpd-2.4.9
 
 But below, we only have:
 Bug 56371 - Please merge 0 into the next httpd-2.4.10 version, the fix
 is missing in httpd-2.4.9 (edit)
 
 link to r1576233 has been turned into 0.
 
 
 In the comment below, we have the same issue, the link to r1576233 is
 turned into 0.
 
 
 same kind of issue can be seen in the 2nd comment of
 https://issues.apache.org/bugzilla/show_bug.cgi?id=56235
 
 
 
 I think it is a bug in bugzilla. We are using version 4.4.4 which has
 been released just 2 days ago.
 This release is just a day after 4.4.3. It is a quick fix because of URL
 broken in comments. That is to say, more or less what is described above.
 So I guess, that the issue is in bugzilla.
 
 
 However, before posting a bug report, I wanted to have your feedback.
 Is there some custom code in our installation that turns rxx into a
 link to svn repository that should be updated to match changes in 4.4.4
 release?
 
 Best regards,
 
 CJ


Re: Problem of URL in bugzilla

2014-04-20 Thread olli hauer
On 2014-04-20 19:36, Christophe JAILLET wrote:
 Hi,
 
 When browsing https://issues.apache.org/bugzilla/show_bug.cgi?id=56371, in 
 the top most frame, we can see:
 ASF Bugzilla – Bug 56371 Please merge r1576233 into the next httpd-2.4.10 
 version, the fix is missing in httpd-2.4.9
 
 But below, we only have:
 Bug 56371 - Please merge 0 into the next httpd-2.4.10 version, the fix is 
 missing in httpd-2.4.9 (edit)
 
 link to r1576233 has been turned into 0.
 
 
 In the comment below, we have the same issue, the link to r1576233 is turned 
 into 0.
 
 
 same kind of issue can be seen in the 2nd comment of 
 https://issues.apache.org/bugzilla/show_bug.cgi?id=56235
 
 
 
 I think it is a bug in bugzilla. We are using version 4.4.4 which has been 
 released just 2 days ago.
 This release is just a day after 4.4.3. It is a quick fix because of URL 
 broken in comments. That is to say, more or less what is described above.
 So I guess, that the issue is in bugzilla.
 
 
 However, before posting a bug report, I wanted to have your feedback.
 Is there some custom code in our installation that turns rxx into a link 
 to svn repository that should be updated to match changes in 4.4.4 release?
 
 Best regards,
 

Hi Christophe,

now I can see the first time on a real example what the latest bugzilla version 
fixes ...

BTW:
Also in the Bug Description r1576233 has changed to '0'.

-- 
Regards,

olli