Hi,
Based on some previous discussions here is the simplest one sample I've
ripped off from my tree.
Basically the Apache acts as RPC client sending error messages to some
monitoring app. The monitoring app calls the callback function in apache
depending on the error message. The callback itself calls the Sleep() for 10
seconds, resulting that GET takes 10 seconds if case of bad URL request.
Of course the concept is based on RPC which is WIN specific, but I'm sure
that we have the infrastructure (APR) upon which the concept can be built.
It could use either shmem or sockets to build something like RPC. I think
that there is a portable package called XML-RPC that uses sockets for IPC.
Perhaps all that doesn't make sense at all, but I've enclosed the sample
code.
MT.
aprpc.acf
aprpc.h
aprpc.idl
aprpc_c.c
aprpc_s.c
aprpcp.c
aprpcsrv.c
aprpcsrv.mak
Index: log.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/log.c,v
retrieving revision 1.98
diff -u -r1.98 log.c
--- log.c 2001/10/08 23:28:57 1.98
+++ log.c 2001/10/21 08:58:02
@@ -90,7 +90,16 @@
#include "http_core.h"
#include "http_log.h"
#include "http_main.h"
+#include "aprpc.h"
+#ifdef APACHE_HAS_RPC
+apr_status_t ap_start_rpc(unsigned char *protocol, unsigned char *endpoint,
+ unsigned char *address, unsigned char *binding);
+
+apr_status_t ap_shutdown_rpc(unsigned char *binding);
+static unsigned char *string_binding;
+#endif
+
typedef struct {
char *t_name;
int t_val;
@@ -286,6 +295,11 @@
apr_file_t *errfile = NULL;
open_error_log(s_main, p);
+#ifdef APACHE_HAS_RPC
+ {
+ ap_start_rpc("ncacn_np", "\\pipe\\apachecallback", NULL, string_binding);
+ }
+#endif
replace_stderr = 1;
if (s_main->error_log) {
@@ -333,6 +347,7 @@
}
}
+
static void log_error_core(const char *file, int line, int level,
apr_status_t status, const server_rec *s,
const request_rec *r, apr_pool_t *pool,
@@ -447,6 +462,16 @@
", referer: %s", referer);
}
+#ifdef APACHE_HAS_RPC
+ RpcTryExcept {
+ ap_log_error_rpc((unsigned char *)errstr);
+ }
+ RpcExcept(1) {
+ len += apr_snprintf(errstr + len, MAX_STRING_LEN - len,
+ "\nRPC Runtime reported exception %ld\n", RpcExceptionCode());
+ }
+ RpcEndExcept
+#endif
/* NULL if we are logging to syslog */
if (logf) {
/* Truncate for the terminator (as apr_snprintf does) */
@@ -455,6 +480,7 @@
strcpy(errstr + len, APR_EOL_STR);
apr_file_puts(errstr, logf);
apr_file_flush(logf);
+
}
#ifdef HAVE_SYSLOG
else {