YAZ 5.38.1
statserv.c File Reference

Implements GFS logic. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <yaz/sc.h>
#include <yaz/tpath.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xinclude.h>
#include <fcntl.h>
#include <signal.h>
#include <errno.h>
#include <yaz/comstack.h>
#include <yaz/tcpip.h>
#include <yaz/options.h>
#include <yaz/log.h>
#include "eventl.h"
#include "session.h"
#include <yaz/statserv.h>
#include <yaz/daemon.h>
#include <yaz/yaz-iconv.h>
#include <yaz/snprintf.h>

Go to the source code of this file.

Macros

#define STAT_DEFAULT_LOG_LEVEL   "server,session,request"

Functions

int check_options (int argc, char **argv)
static void log_comstack_error (int level, COMSTACK cs, const char *fmt,...)
static void get_logbits (int force)
static int add_listener (char *where, int listen_id)
static xmlNodePtr xml_config_get_root (void)
static char * nmem_dup_xml_content (NMEM n, xmlNodePtr ptr)
static struct gfs_server * gfs_server_new (const char *id)
static struct gfs_listen * gfs_listen_new (const char *id, const char *address)
static void gfs_server_chdir (struct gfs_server *gfs)
int control_association (association *assoc, const char *host, int force_open)
static void xml_config_read (const char *base_path)
static int xml_config_open (void)
static void xml_config_close (void)
static int xml_config_add_listeners (void)
static void xml_config_bend_start (void)
static void xml_config_bend_stop (void)
static void remove_listeners (void)
void statserv_remove (IOCHAN pIOChannel)
static void statserv_closedown (void)
static void * new_session (void *vp)
static void listener (IOCHAN h, int event)
static void inetd_connection (int what)
static void catchchld (int num)
statserv_options_block * statserv_getcontrol (void)
void statserv_setcontrol (statserv_options_block *block)
static void statserv_reset (void)
static void normal_stop_handler (int num)
static void daemon_handler (void *data)
static void show_version (void)
static int statserv_sc_main (yaz_sc_t s, int argc, char **argv)
static void option_copy (char *dst, const char *src)
void statserv_sc_stop (yaz_sc_t s)
int statserv_main (int argc, char **argv, bend_initresult *(*bend_init)(bend_initrequest *r), void(*bend_close)(void *handle))

Variables

static IOCHAN pListener = NULL
static char gfs_root_dir [FILENAME_MAX+1]
static struct gfs_server * gfs_server_list = 0
static struct gfs_listen * gfs_listen_list = 0
static NMEM gfs_nmem = 0
static char * me = "statserver"
static char * programname ="statserver"
static statserv_options_block * current_control_block = 0
statserv_options_block control_block
static int max_sessions = 0
static int logbits_set = 0
static int log_session = 0
static int log_sessiondetail = 0
static int log_server = 0
static xmlDocPtr xml_config_doc = 0
static int no_sessions = 0
static int sig_received = 0

Detailed Description

Implements GFS logic.

Definition in file statserv.c.

Macro Definition Documentation

◆ STAT_DEFAULT_LOG_LEVEL

#define STAT_DEFAULT_LOG_LEVEL   "server,session,request"

Definition at line 93 of file statserv.c.

Referenced by check_options().

Function Documentation

◆ add_listener()

◆ catchchld()

void catchchld ( int num)
static

Definition at line 1228 of file statserv.c.

References catchchld().

Referenced by catchchld(), and statserv_sc_main().

◆ check_options()

◆ control_association()

◆ daemon_handler()

void daemon_handler ( void * data)
static

Definition at line 1287 of file statserv.c.

References daemon_handler(), iochan_event_loop(), pListener, and sig_received.

Referenced by daemon_handler(), and statserv_sc_main().

◆ get_logbits()

void get_logbits ( int force)
static

get_logbits sets global loglevel bits

Definition at line 156 of file statserv.c.

References get_logbits(), log_server, log_session, log_sessiondetail, logbits_set, and yaz_log_module_level().

◆ gfs_listen_new()

struct gfs_listen * gfs_listen_new ( const char * id,
const char * address )
static

◆ gfs_server_chdir()

void gfs_server_chdir ( struct gfs_server * gfs)
static

◆ gfs_server_new()

◆ inetd_connection()

◆ listener()

◆ log_comstack_error()

void log_comstack_error ( int level,
COMSTACK cs,
const char * fmt,
... )
static

◆ new_session()

◆ nmem_dup_xml_content()

char * nmem_dup_xml_content ( NMEM n,
xmlNodePtr ptr )
static

Definition at line 194 of file statserv.c.

References nmem_dup_xml_content(), nmem_malloc(), and yaz_isspace.

Referenced by nmem_dup_xml_content(), and xml_config_read().

◆ normal_stop_handler()

void normal_stop_handler ( int num)
static

Definition at line 1281 of file statserv.c.

References sig_received.

Referenced by statserv_sc_main().

◆ option_copy()

void option_copy ( char * dst,
const char * src )
static

Definition at line 1374 of file statserv.c.

References BEND_NAME_MAX, and option_copy().

Referenced by check_options(), and option_copy().

◆ remove_listeners()

void remove_listeners ( void )
static

Definition at line 1219 of file statserv.c.

References iochan_destroy, iochan::next, pListener, and remove_listeners().

Referenced by listener(), and remove_listeners().

◆ show_version()

void show_version ( void )
static

Definition at line 1293 of file statserv.c.

References show_version(), YAZ_VERSION, yaz_version(), and YAZ_VERSION_SHA1.

Referenced by check_options(), and show_version().

◆ statserv_closedown()

void statserv_closedown ( void )
static

◆ statserv_getcontrol()

◆ statserv_main()

int statserv_main ( int argc,
char ** argv,
bend_initresult * bend_init (*)(bend_initrequest *r),
void(* bend_close )(void *handle) )

◆ statserv_remove()

void statserv_remove ( IOCHAN pIOChannel)

Definition at line 948 of file statserv.c.

References statserv_remove().

Referenced by iochan_event_loop(), and statserv_remove().

◆ statserv_reset()

void statserv_reset ( void )
static

Definition at line 1274 of file statserv.c.

References statserv_reset().

Referenced by statserv_reset(), and statserv_sc_stop().

◆ statserv_sc_main()

◆ statserv_sc_stop()

void statserv_sc_stop ( yaz_sc_t s)

Definition at line 1519 of file statserv.c.

References statserv_closedown(), statserv_reset(), and statserv_sc_stop().

Referenced by statserv_main(), and statserv_sc_stop().

◆ statserv_setcontrol()

◆ xml_config_add_listeners()

int xml_config_add_listeners ( void )
static

◆ xml_config_bend_start()

◆ xml_config_bend_stop()

◆ xml_config_close()

void xml_config_close ( void )
static

◆ xml_config_get_root()

xmlNodePtr xml_config_get_root ( void )
static

◆ xml_config_open()

◆ xml_config_read()

Variable Documentation

◆ control_block

◆ current_control_block

statserv_options_block* current_control_block = 0
static

Definition at line 87 of file statserv.c.

Referenced by statserv_getcontrol(), and statserv_setcontrol().

◆ gfs_listen_list

struct gfs_listen* gfs_listen_list = 0
static

Definition at line 75 of file statserv.c.

Referenced by xml_config_add_listeners(), and xml_config_read().

◆ gfs_nmem

NMEM gfs_nmem = 0
static

◆ gfs_root_dir

char gfs_root_dir[FILENAME_MAX+1]
static

Definition at line 73 of file statserv.c.

Referenced by gfs_server_chdir(), statserv_setcontrol(), and xml_config_open().

◆ gfs_server_list

struct gfs_server* gfs_server_list = 0
static

◆ log_server

int log_server = 0
static

Definition at line 134 of file statserv.c.

Referenced by add_listener(), get_logbits(), and listener().

◆ log_session

int log_session = 0
static

Definition at line 132 of file statserv.c.

◆ log_sessiondetail

int log_sessiondetail = 0
static

Definition at line 133 of file statserv.c.

◆ logbits_set

int logbits_set = 0
static

Definition at line 131 of file statserv.c.

◆ max_sessions

int max_sessions = 0
static

Definition at line 129 of file statserv.c.

Referenced by check_options(), and new_session().

◆ me

char* me = "statserver"
static

Definition at line 78 of file statserv.c.

Referenced by check_options(), listener(), and statserv_sc_main().

◆ no_sessions

int no_sessions = 0
static

Definition at line 965 of file statserv.c.

Referenced by listener(), and new_session().

◆ pListener

◆ programname

char* programname ="statserver"
static

Definition at line 79 of file statserv.c.

Referenced by statserv_sc_main().

◆ sig_received

int sig_received = 0
static

Definition at line 1278 of file statserv.c.

Referenced by daemon_handler(), normal_stop_handler(), and statserv_sc_main().

◆ xml_config_doc

xmlDocPtr xml_config_doc = 0
static

Definition at line 171 of file statserv.c.

Referenced by xml_config_close(), xml_config_get_root(), and xml_config_open().