fred-mod-corba-1.4.2
Data Structures | Macros | Functions | Variables
mod_corba.c File Reference

mod_corba.c manages corba object references. More...

#include "httpd.h"
#include "http_log.h"
#include "http_config.h"
#include "http_connection.h"
#include "apr_pools.h"
#include "apr_strings.h"
#include "apr_hash.h"
#include "apr_tables.h"
#include <orbit/orbit.h>
#include <ORBitservices/CosNaming.h>

Data Structures

struct  corba_conf
 Configuration structure of corba module. More...
 
struct  cache_t
 Per-child cache structure. More...
 
struct  reference_cleanup_arg
 This structure is passed to reference cleanup routine. More...
 
struct  get_reference_ctx
 Context structure passed between get_reference_from_() and connection handler. More...
 

Macros

#define ap_log_cerror(mark, level, status, c, ...)   ap_log_error(mark, level, status, (c)->base_server, __VA_ARGS__)
 ap_log_cerror is defined only if apache version is 2.0 because 2.0 contrary to 2.2 does not have this function.
 
#define raised_exception(ev)   ((ev)->_major != CORBA_NO_EXCEPTION)
 Quick test if corba exception was raised. More...
 

Functions

static apr_status_t reference_cleanup (void *raw_arg)
 Cleanup routine releases corba object reference. More...
 
static void * get_reference_for_service (void *pctx, const char *alias, const char *name)
 Context structure passed between get_ior_from_nameservice() and post config hook. More...
 
static int get_reference_from_nameservice (void *pctx, const char *alias, const char *name)
 Function obtains one reference from corba nameservice and sticks the reference to connection. More...
 
static int get_ior_from_nameservice (void *pctx, const char *alias, const char *name)
 Function obtains IOR string for one object registered in mod_corba and assign it to IOR cache table. More...
 
static int ior_cache_fill (void *pctx)
 Caching support functions. More...
 
static int get_reference_from_ior (void *pctx, const char *alias, const char *name)
 Function obtains one reference from IOR string and sticks the reference to connection. More...
 
static int corba_process_connection (conn_rec *c)
 Connection handler. More...
 
static apr_status_t corba_cleanup (void *par_orb)
 Cleanup routine releases ORB. More...
 
static int corba_postconfig_hook (apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
 In post config hook we initialize ORB. More...
 
static const char * set_corba (cmd_parms *cmd, void *dummy, int flag)
 Handler for apache's configuration directive "CorbaEnable". More...
 
static const char * set_ior_cache (cmd_parms *cmd, void *dummy, int flag)
 Handler for apache's configuration directive "CorbaEnable". More...
 
static const char * set_nameservice (cmd_parms *cmd, void *dummy, const char *ns_loc)
 Handler for apache's configuration directive "CorbaNameservice". More...
 
static const char * set_object (cmd_parms *cmd, void *dummy, const char *object, const char *alias)
 Handler for apache's configuration directive "CorbaObject". More...
 
static void * create_corba_config (apr_pool_t *p, server_rec *s)
 Initialization of of mod_corba's configuration structure.
 
static void * merge_corba_config (apr_pool_t *p, void *base_par, void *override_par)
 Merge of of mod_corba's configuration structure.
 
static void corba_child_init (apr_pool_t *p, server_rec *s)
 Child init function.
 
static void register_hooks (apr_pool_t *p)
 Registration of various hooks which the mod_corba is interested in.
 

Variables

module AP_MODULE_DECLARE_DATA corba_module
 corba_module declaration. More...
 
static cache_tcache
 
static const command_rec corba_cmds []
 Structure containing mod_corba's configuration directives and their handler references. More...
 

Detailed Description

mod_corba.c manages corba object references.

The management is at this time rather primitive. For each connection, for which this module was enabled, are created configured object references, which are saved in connection notes and available for later use by other modules. The references are automaticaly cleaned up upon connection pool destruction.

Macro Definition Documentation

#define raised_exception (   ev)    ((ev)->_major != CORBA_NO_EXCEPTION)

Function Documentation

static apr_status_t corba_cleanup ( void *  par_orb)
static

Cleanup routine releases ORB.

This routine is called upon destroying configuration pool (which is at restarts).

Parameters
par_orbThe ORB.

References get_reference_ctx::orb, and raised_exception.

Referenced by corba_postconfig_hook().

static int corba_postconfig_hook ( apr_pool_t *  p,
apr_pool_t *  plog,
apr_pool_t *  ptemp,
server_rec *  s 
)
static

In post config hook we initialize ORB.

Parameters
pMemory pool.
plogMemory pool used for logging.
ptempMemory pool destroyed right after postconfig phase.
sServer record.
Returns
Status.

References corba_cleanup(), corba_module, corba_conf::enabled, corba_conf::ns_loc, corba_conf::objects, corba_conf::orb, get_reference_ctx::orb, and raised_exception.

Referenced by register_hooks().

static int corba_process_connection ( conn_rec *  c)
static

Connection handler.

Connection handler obtains object references from IOR string for configured objects. These object references are sticked to connection for later use by other modules. Cleanup routine which handles reference's release is bound to connection.

Parameters
cIncoming connection.
Returns
Return code

References ap_log_cerror, get_reference_ctx::c, corba_module, corba_conf::enabled, get_reference_from_ior(), get_reference_from_nameservice(), corba_conf::ior_cache_enabled, get_reference_ctx::nameservice, corba_conf::ns_loc, corba_conf::objects, get_reference_ctx::objects, corba_conf::orb, get_reference_ctx::orb, and raised_exception.

Referenced by register_hooks().

static int get_ior_from_nameservice ( void *  pctx,
const char *  alias,
const char *  name 
)
static

Function obtains IOR string for one object registered in mod_corba and assign it to IOR cache table.

Parameters
pctxContext pointer.
aliasAlias of object.
nameName of object.
Returns
1 if successfull, 0 in case of failure.

References ap_log_cerror, get_reference_ctx::c, get_reference_for_service(), cache_t::iors, get_reference_ctx::orb, and raised_exception.

Referenced by ior_cache_fill().

static void* get_reference_for_service ( void *  pctx,
const char *  alias,
const char *  name 
)
static

Context structure passed between get_ior_from_nameservice() and post config hook.

Function returns reference from nameservice (defined at context structure) for object given by name

Parameters
pctxContext pointer.
aliasAlias of object.
nameName of object.
Returns
service if successfull, NULL in case of failure.

References ap_log_cerror, get_reference_ctx::c, get_reference_ctx::nameservice, and raised_exception.

Referenced by get_ior_from_nameservice(), and get_reference_from_nameservice().

static int get_reference_from_ior ( void *  pctx,
const char *  alias,
const char *  name 
)
static

Function obtains one reference from IOR string and sticks the reference to connection.

Parameters
pctxContext pointer.
aliasAlias of object.
nameName of object.
Returns
1 if successfull, 0 in case of failure.

Try cache then nameservice (also overwrite cache for futher use) if nameservice is unavailable retry 3 times then fails.

References ap_log_cerror, get_reference_ctx::c, ior_cache_fill(), cache_t::iors, get_reference_ctx::objects, get_reference_ctx::orb, raised_exception, and reference_cleanup().

Referenced by corba_process_connection().

static int get_reference_from_nameservice ( void *  pctx,
const char *  alias,
const char *  name 
)
static

Function obtains one reference from corba nameservice and sticks the reference to connection.

Parameters
pctxContext pointer.
nameName of object.
aliasAlias of object.
Returns
1 if successfull, 0 in case of failure.

References ap_log_cerror, get_reference_ctx::c, get_reference_for_service(), get_reference_ctx::objects, and reference_cleanup().

Referenced by corba_process_connection().

static int ior_cache_fill ( void *  pctx)
static

Caching support functions.

Function should delete whole cache and allocate new one. This is not used because if we refilling cache we just replace IOR string for new one for same object alias. Deletion is delegated to apr_table_set function.

static int ior_cache_garbage() { if (cache) { #if APR_HAS_THREADS apr_thread_mutex_lock(cache->mutex); #endif apr_pool_clear(cache->pool); cache->iors = apr_table_make(cache->pool, 5); #if APR_HAS_THREADS apr_thread_mutex_unlock(cache->mutex); #endif return 1; } return 0; } Function fills IOR cache with IOR strings configured for given server

Parameters
sServer structure pointer.
Returns
1 if successfull, 0 in case of failure.

References ap_log_cerror, get_reference_ctx::c, corba_module, get_ior_from_nameservice(), cache_t::iors, get_reference_ctx::nameservice, corba_conf::ns_loc, corba_conf::objects, get_reference_ctx::orb, and raised_exception.

Referenced by get_reference_from_ior().

static apr_status_t reference_cleanup ( void *  raw_arg)
static

Cleanup routine releases corba object reference.

This routine is called upon destroying connection pool.

Parameters
objectThe object reference.

References ap_log_cerror, and raised_exception.

Referenced by get_reference_from_ior(), and get_reference_from_nameservice().

static const char* set_corba ( cmd_parms *  cmd,
void *  dummy,
int  flag 
)
static

Handler for apache's configuration directive "CorbaEnable".

Parameters
cmdCommand structure.
dummyNot used parameter.
flag1 means Corba is turned on, 0 means turned off.
Returns
Error string in case of failure otherwise NULL.

References corba_module, and corba_conf::enabled.

static const char* set_ior_cache ( cmd_parms *  cmd,
void *  dummy,
int  flag 
)
static

Handler for apache's configuration directive "CorbaEnable".

Parameters
cmdCommand structure.
dummyNot used parameter.
flag1 means Corba is turned on, 0 means turned off.
Returns
Error string in case of failure otherwise NULL.

References corba_module, and corba_conf::ior_cache_enabled.

static const char* set_nameservice ( cmd_parms *  cmd,
void *  dummy,
const char *  ns_loc 
)
static

Handler for apache's configuration directive "CorbaNameservice".

Sets the host and optional port where nameservice runs.

Parameters
cmdCommand structure.
dummyNot used parameter.
ns_locThe host [port] of nameservice.
Returns
Error string in case of failure otherwise NULL.

References corba_module, and corba_conf::ns_loc.

static const char* set_object ( cmd_parms *  cmd,
void *  dummy,
const char *  object,
const char *  alias 
)
static

Handler for apache's configuration directive "CorbaObject".

Sets a name of CORBA object which will be managed by this module.

Parameters
cmdCommand structure.
dummyNot used parameter.
objectA name of object.
Returns
Error string in case of failure otherwise NULL.

References corba_module, and corba_conf::objects.

Variable Documentation

const command_rec corba_cmds[]
static
Initial value:
= {
AP_INIT_FLAG("CorbaEnable", set_corba, NULL, RSRC_CONF,
"Whether corba object manager is enabled or not"),
AP_INIT_FLAG("CorbaIORCacheEnable", set_ior_cache, NULL, RSRC_CONF,
"Whether corba IOR string caching is enabled or not"),
AP_INIT_TAKE1("CorbaNameservice", set_nameservice, NULL, RSRC_CONF,
"Location of CORBA nameservice (host[:port]). Default is "
"localhost."),
AP_INIT_TAKE2("CorbaObject", set_object, NULL, RSRC_CONF,
"Context and name of object to provision and its alias. "
"Format for context and name is CONTEXTNAME.OBJECTNAME."),
{ NULL }
}
static const char * set_corba(cmd_parms *cmd, void *dummy, int flag)
Handler for apache&#39;s configuration directive "CorbaEnable".
Definition: mod_corba.c:666
static const char * set_object(cmd_parms *cmd, void *dummy, const char *object, const char *alias)
Handler for apache&#39;s configuration directive "CorbaObject".
Definition: mod_corba.c:750
static const char * set_ior_cache(cmd_parms *cmd, void *dummy, int flag)
Handler for apache&#39;s configuration directive "CorbaEnable".
Definition: mod_corba.c:689
static const char * set_nameservice(cmd_parms *cmd, void *dummy, const char *ns_loc)
Handler for apache&#39;s configuration directive "CorbaNameservice".
Definition: mod_corba.c:713

Structure containing mod_corba's configuration directives and their handler references.

Referenced by register_hooks().

module AP_MODULE_DECLARE_DATA corba_module
Initial value:
= {
STANDARD20_MODULE_STUFF,
NULL,
NULL,
}
static void register_hooks(apr_pool_t *p)
Registration of various hooks which the mod_corba is interested in.
Definition: mod_corba.c:853
static void * merge_corba_config(apr_pool_t *p, void *base_par, void *override_par)
Merge of of mod_corba&#39;s configuration structure.
Definition: mod_corba.c:804
static const command_rec corba_cmds[]
Structure containing mod_corba&#39;s configuration directives and their handler references.
Definition: mod_corba.c:771
static void * create_corba_config(apr_pool_t *p, server_rec *s)
Initialization of of mod_corba&#39;s configuration structure.
Definition: mod_corba.c:788

corba_module declaration.

corba_module definition.

Referenced by corba_postconfig_hook(), corba_process_connection(), ior_cache_fill(), register_hooks(), set_corba(), set_ior_cache(), set_nameservice(), and set_object().