/Users/maurits/Documents/studie/afstuderen/biosphere/daemon/service.c File Reference

#include "service.h"
#include "core_services.h"
#include "mutex.h"
#include "node.h"
#include "settings.h"
#include <copy.h>
#include <list.h>
#include <http_common.h>
#include <io.h>
#include <str.h>
#include <type.h>
#include <xml.h>
#include <assert.h>
#include <apr_pools.h>
#include <apr_file_io.h>
#include <apr_strings.h>
#include <stdio.h>

Include dependency graph for service.c:

Go to the source code of this file.

Data Structures

struct  service_info

Functions

bs_status init_service (apr_pool_t *mp)
bs_status add_service (bs_definition *def, service_request_handler handler)
bs_status remove_service (const char *name)
bs_status get_services (bs_definition **def, apr_pool_t *mp)
static bs_status handle_service_request_remotely (const bs_service_request *request, bs_service_response **response, apr_pool_t *mp)
bs_status handle_service_request (const bs_service_request *request, bs_service_response **response, void *mp)

Variables

apr_pool_t * global_mp
static bs_listservices_pool = NULL


Function Documentation

bs_status add_service ( bs_definition def,
service_request_handler  handler 
)

Add a service to the services pool. Since the service is meant to persist, it will be allocated from the global memory pool.

Parameters:
def Service definition structure
handler Function pointer to handler function
Returns:
status code

Definition at line 105 of file service.c.

References BS_OK, BS_SERVICE_DOUBLE, service_info::def, global_mp, service_info::handler, list_append(), list_index(), list_size(), lock_pool_mux(), lock_service_mux(), bs_definition::name, services_pool, streq(), unlock_pool_mux(), and unlock_service_mux().

Referenced by init_service(), and load_module().

Here is the call graph for this function:

bs_status get_services ( bs_definition **  def,
apr_pool_t *  mp 
)

Gather all service definitions of the core services and the various modules into a single definition.

Parameters:
def Result pointer to the definition to populate
mp Memory pool to allocate from
Returns:
Status code.

Definition at line 154 of file service.c.

References BS_ERROR, BS_OK, service_info::def, list_index(), list_size(), lock_service_mux(), merge_def_with_def(), new_bs_definition(), runtestsuite::rv, services_pool, and unlock_service_mux().

Referenced by handle_http_get().

Here is the call graph for this function:

bs_status handle_service_request ( const bs_service_request request,
bs_service_response **  response,
void *  mp 
)

Handle a service request. First, the pool of installed services is searched for a suitable service. Then the handler of this service is called and the response is returned in the result pointer argument.

Parameters:
request The service request to be serviced
response Pointer where the result will be stored
mp Memory pool to allocate from (void pointer for compatibility).
Returns:
Status code

Definition at line 205 of file service.c.

References BS_ERROR, BS_OK, copy_response(), global_mp, handle_service_request_remotely(), list_index(), list_size(), lock_pool_mux(), lock_service_mux(), pool, request_corresponds_with_definition(), runtestsuite::rv, services_pool, unlock_pool_mux(), and unlock_service_mux().

Referenced by handle_http_post(), and load_module().

Here is the call graph for this function:

static bs_status handle_service_request_remotely ( const bs_service_request request,
bs_service_response **  response,
apr_pool_t *  mp 
) [static]

Try to service the request by using a remote service from another node.

Parameters:
request The request to service
response Pointer to a place where the response will be stored
mp Memory pool to allocate from
Returns:
Status code

Definition at line 184 of file service.c.

References node_address::address, node_info::address, BS_NO_SERVICE, BS_OK, connect_and_post(), get_servicing_node(), node_address::port, and runtestsuite::rv.

Referenced by handle_service_request().

Here is the call graph for this function:

bs_status init_service ( apr_pool_t *  mp  ) 

Initialize the services subsystem by setting up the appropriate data structures. After that create the wrapper around several functions that makes up the core service.

Parameters:
mp Memory pool to use.
Returns:
Status code

Definition at line 71 of file service.c.

References add_service(), BIOSPHERED_PREFIX, BS_OK, core_service_request_handler(), CORE_SERVICES_DEFINITION_FILE, len(), new_list(), read_file_into_buf(), runtestsuite::rv, services_pool, and xlate_from_xml().

Referenced by main().

Here is the call graph for this function:

bs_status remove_service ( const char *  name  ) 

Remove the named service.

Parameters:
name Name of the service
Returns:
Status code.

Definition at line 136 of file service.c.

References BS_OK, list_index(), list_remove(), list_size(), lock_service_mux(), services_pool, streq(), and unlock_service_mux().

Referenced by unload_all_modules(), and unload_module().

Here is the call graph for this function:


Variable Documentation

bs_list* services_pool = NULL [static]

A list holding the service_info structures of all installed services.

Definition at line 59 of file service.c.

Referenced by add_service(), get_services(), handle_service_request(), init_service(), and remove_service().


Generated on Tue Jul 17 09:51:10 2007 for Bio-SPHERE by  doxygen 1.5.1