YAZ 5.37.0
statserv.c File Reference

Implements GFS logic. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.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 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_servergfs_server_new (const char *id)
static struct gfs_listengfs_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_blockstatserv_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_servergfs_server_list = 0
static struct gfs_listengfs_listen_list = 0
static NMEM gfs_nmem = 0
static char * me = "statserver"
static char * programname ="statserver"
static statserv_options_blockcurrent_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 92 of file statserv.c.

Referenced by check_options().

Function Documentation

◆ add_listener()

◆ catchchld()

void catchchld ( int num)
static

Definition at line 1206 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 1265 of file statserv.c.

References iochan_event_loop(), pListener, and sig_received.

Referenced by statserv_sc_main().

◆ get_logbits()

void get_logbits ( int force)
static

get_logbits sets global loglevel bits

Definition at line 136 of file statserv.c.

References 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()

◆ new_session()

◆ nmem_dup_xml_content()

char * nmem_dup_xml_content ( NMEM n,
xmlNodePtr ptr )
static

Definition at line 174 of file statserv.c.

References nmem_malloc(), and yaz_isspace.

Referenced by xml_config_read().

◆ normal_stop_handler()

void normal_stop_handler ( int num)
static

Definition at line 1259 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 1352 of file statserv.c.

References BEND_NAME_MAX.

Referenced by check_options().

◆ remove_listeners()

void remove_listeners ( void )
static

Definition at line 1197 of file statserv.c.

References iochan_destroy, iochan::next, and pListener.

Referenced by listener().

◆ show_version()

void show_version ( void )
static

Definition at line 1271 of file statserv.c.

References YAZ_VERSION, yaz_version(), and YAZ_VERSION_SHA1.

Referenced by check_options().

◆ statserv_closedown()

void statserv_closedown ( void )
static

Definition at line 931 of file statserv.c.

References iochan_destroy, iochan::next, pListener, xml_config_bend_stop(), and xml_config_close().

Referenced by statserv_sc_stop().

◆ statserv_getcontrol()

statserv_options_block * statserv_getcontrol ( void )

Definition at line 1214 of file statserv.c.

References control_block, and current_control_block.

Referenced by destroy_association(), process_initRequest(), and srw_bend_init().

◆ 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 927 of file statserv.c.

Referenced by iochan_event_loop().

◆ statserv_reset()

void statserv_reset ( void )
static

Definition at line 1252 of file statserv.c.

Referenced by statserv_sc_stop().

◆ statserv_sc_main()

◆ statserv_sc_stop()

void statserv_sc_stop ( yaz_sc_t s)

Definition at line 1497 of file statserv.c.

References statserv_closedown(), and statserv_reset().

Referenced by statserv_main().

◆ statserv_setcontrol()

void statserv_setcontrol ( statserv_options_block * block)

◆ xml_config_add_listeners()

int xml_config_add_listeners ( void )
static

Definition at line 610 of file statserv.c.

References add_listener(), gfs_listen::address, gfs_listen_list, and gfs_listen::next.

Referenced by statserv_sc_main().

◆ xml_config_bend_start()

void xml_config_bend_start ( void )
static

◆ xml_config_bend_stop()

void xml_config_bend_stop ( void )
static

◆ xml_config_close()

void xml_config_close ( void )
static

Definition at line 590 of file statserv.c.

References gfs_nmem, gfs_server_list, nmem_destroy(), and xml_config_doc.

Referenced by statserv_closedown().

◆ xml_config_get_root()

xmlNodePtr xml_config_get_root ( void )
static

Definition at line 155 of file statserv.c.

References control_block, xml_config_doc, yaz_log(), and YLOG_WARN.

Referenced by xml_config_read().

◆ xml_config_open()

◆ xml_config_read()

Variable Documentation

◆ control_block

◆ current_control_block

statserv_options_block* current_control_block = 0
static

Definition at line 86 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 74 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 72 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 133 of file statserv.c.

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

◆ log_session

int log_session = 0
static

Definition at line 131 of file statserv.c.

◆ log_sessiondetail

int log_sessiondetail = 0
static

Definition at line 132 of file statserv.c.

◆ logbits_set

int logbits_set = 0
static

Definition at line 130 of file statserv.c.

◆ max_sessions

int max_sessions = 0
static

Definition at line 128 of file statserv.c.

Referenced by check_options(), and new_session().

◆ me

char* me = "statserver"
static

Definition at line 77 of file statserv.c.

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

◆ no_sessions

int no_sessions = 0
static

Definition at line 944 of file statserv.c.

Referenced by listener(), and new_session().

◆ pListener

◆ programname

char* programname ="statserver"
static

Definition at line 78 of file statserv.c.

Referenced by statserv_sc_main().

◆ sig_received

int sig_received = 0
static

Definition at line 1256 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 151 of file statserv.c.

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