Cross reference for sv/server.c of index.

# File sv/server.c

      $Revision: 1.62 $

      Example code: A server for a client to connect to.

      Status: NOT REVUED, NOT TESTED

      Authors:       Chris Ottrey, Joao Damas,
                     heavy rewrite by Andrei Robachevsky, Marek Bukowy

    Online References:

      Based on DBServer.java

## Included Files

- `#include "/home/shane/code/RIP/include/rip.h"`
  - `#include </home/shane/code/RIP/include/config.h>`
  - `#include <sys/param.h>`
  - `#include </ncc/dbwork/platforms/yucca-debug/glib-indep/include/glib-1.2/glib.h>`
  - `#include "/home/shane/code/RIP/include/AU_util.h"`
    - `#include <stdio.h>`
    - `#include <stdlib.h>`
    - `#include <string.h>`
    - `#include <sys/types.h>`
    - `#include <unistd.h>`
    - `#include <regex.h>`
    - `#include <glib.h>`
  - `#include "/home/shane/code/RIP/include/aa.h"`
    - `#include "/home/shane/code/RIP/include/iproutines.h"`
      - `#include <sys/types.h>`
      - `#include <glib.h>`
      - `#include </home/shane/code/RIP/include/inet6def.h>`
      - `#include </home/shane/code/RIP/include/erroutines.h>`
  - `#include "/home/shane/code/RIP/include/access_control.h"`
    - `#include "/home/shane/code/RIP/include/erroutines.h"`
    - `#include "/home/shane/code/RIP/include/iproutines.h"`
    - `#include "/home/shane/code/RIP/include/rxroutines.h"`
      - `#include <glib.h>`
      - `#include <pthread.h>`
      - `#include <stubs.h>`
      - `#include </home/shane/code/RIP/include/memwrap.h>`
      - `#include <stdio.h>`
      - `#include <iproutines.h>`
      - `#include <erroutines.h>`
      - `#include "/home/shane/code/RIP/include/sk.h"`
        - `#include "/home/shane/code/RIP/include/stubs.h"`
        - `#include <sys/time.h>`
        - `#include <unistd.h>`
        - `#include <sys/types.h>`
        - `#include <sys/socket.h>`
        - `#include <netinet/in.h>`
        - `#include <netdb.h>`
        - `#include <pthread.h>`
        - `#include <stdlib.h>`
        - `#include <errno.h>`
        - `#include <fcntl.h>`
        - `#include <signal.h>`
        - `#include <stdio.h>`
        - `#include "/home/shane/code/RIP/include/iproutines.h"`
      - `#include "/home/shane/code/RIP/include/thread.h"`
    - `#include "/home/shane/code/RIP/include/mysql_driver.h"`
      - `#include "/usr/local/mysql/include/mysql/mysql.h"`
        - `#include <sys/types.h>`
        - `#include "/usr/local/mysql/include/mysql/mysql_com.h"`
        - `#include "/usr/local/mysql/include/mysql/mysql_version.h"`
      - `#include "/usr/local/mysql/include/mysql/mysqld_error.h"`
      - `#include "/home/shane/code/RIP/include/erroutines.h"`
  - `#include "/home/shane/code/RIP/include/bitmask.h"`
  - `#include "/home/shane/code/RIP/include/ca_adminAttribs.h"`
  - `#include "/home/shane/code/RIP/include/ca_configFns.h"`
    - `#include "/home/shane/code/RIP/include/ca_defs.h"`
      - `#include <pthread.h>`
      - `#include <glib.h>`
    - `#include <memwrap.h>`
    - `#include <erroutines.h>`
  - `#include "/home/shane/code/RIP/include/ca_defs.h"`
  - `#include "/home/shane/code/RIP/include/ca_dictionary.h"`
  - `#include "/home/shane/code/RIP/include/ca_macros.h"`
    - `#include "/home/shane/code/RIP/include/ca_adminAttribs.h"`
  - `#include "/home/shane/code/RIP/include/ca_srcAttribs.h"`
  - `#include "/home/shane/code/RIP/include/comparisons.h"`
  - `#include "/home/shane/code/RIP/include/constants.h"`
    - `#include <glib.h>`
  - `#include "/home/shane/code/RIP/include/defs.h"`
    - `#include <glib.h>`
    - `#include "/home/shane/code/RIP/include/bitmask.h"`
    - `#include "/home/shane/code/RIP/include/DF_class_enum.def"`
    - `#include "/home/shane/code/RIP/include/DF_class_mask.def"`
    - `#include "/home/shane/code/RIP/include/DF_attribute_enum.def"`
    - `#include "/home/shane/code/RIP/include/DF_attribute_inv_attr_mask.def"`
    - `#include "/home/shane/code/RIP/include/which_keytypes.h"`
      - `#include "/home/shane/code/RIP/include/bitmask.h"`
    - `#include "/home/shane/code/RIP/include/iproutines.h"`
    - `#include "/home/shane/code/RIP/include/rxroutines.h"`
  - `#include "/home/shane/code/RIP/include/er_arrays.h"`
    - `#include "/home/shane/code/RIP/include/erroutines.h"`
  - `#include "/home/shane/code/RIP/include/er_aspects.h"`
  - `#include "/home/shane/code/RIP/include/er_facilities.h"`
  - `#include "/home/shane/code/RIP/include/er_formats.h"`
  - `#include "/home/shane/code/RIP/include/er_macro.h"`
    - `#include "/home/shane/code/RIP/include/sk.h"`
  - `#include "/home/shane/code/RIP/include/er_paths.h"`
    - `#include <sys/param.h>`
    - `#include <glib.h>`
  - `#include "/home/shane/code/RIP/include/er_yacc_helper.h"`
  - `#include "/home/shane/code/RIP/include/erroutines.h"`
  - `#include "/home/shane/code/RIP/include/fdwrap.h"`
    - `#include <stdio.h>`
  - `#include "/home/shane/code/RIP/include/mg_getopt.h"`
  - `#include "/home/shane/code/RIP/include/globaldefs.h"`
  - `#include "/home/shane/code/RIP/include/gpg.h"`
    - `#include <netdb.h>`
    - `#include <unistd.h>`
    - `#include "/home/shane/code/RIP/include/mail_parser.h"`
      - `#include "/home/shane/code/RIP/include/gpg.h"`
      - `#include "/home/shane/code/RIP/include/memwrap.h"`
  - `#include "/home/shane/code/RIP/include/inet6def.h"`
  - `#include "/home/shane/code/RIP/include/iproutines.h"`
  - `#include "/home/shane/code/RIP/include/mail_parser.h"`
  - `#include "/home/shane/code/RIP/include/memwrap.h"`
  - `#include "/home/shane/code/RIP/include/mm.h"`
    - `#include "/ncc/dbwork/c-client/sparc-sun-solaris2.7/imap-2000a/c-client/mail.h"`
      - `#include "/ncc/dbwork/c-client/sparc-sun-solaris2.7/imap-2000a/c-client/linkage.h"`
    - `#include "/ncc/dbwork/c-client/sparc-sun-solaris2.7/imap-2000a/c-client/osdep.h"`
      - `#include <string.h>`
      - `#include <sys/types.h>`
      - `#include <stdlib.h>`
      - `#include <dirent.h>`
      - `#include <fcntl.h>`
      - `#include <unistd.h>`
      - `#include <time.h>`
      - `#include <utime.h>`
      - `#include <syslog.h>`
      - `#include <sys/file.h>`
      - `#include <ustat.h>`
      - `#include "/ncc/dbwork/c-client/sparc-sun-solaris2.7/imap-2000a/c-client/env_unix.h"`
        - `#include "/ncc/dbwork/c-client/sparc-sun-solaris2.7/imap-2000a/c-client/env.h"`
      - `#include "/ncc/dbwork/c-client/sparc-sun-solaris2.7/imap-2000a/c-client/fs.h"`
      - `#include "/ncc/dbwork/c-client/sparc-sun-solaris2.7/imap-2000a/c-client/ftl.h"`
      - `#include "/ncc/dbwork/c-client/sparc-sun-solaris2.7/imap-2000a/c-client/nl.h"`
      - `#include "/ncc/dbwork/c-client/sparc-sun-solaris2.7/imap-2000a/c-client/tcp.h"`
      - `#include "/ncc/dbwork/c-client/sparc-sun-solaris2.7/imap-2000a/c-client/lockfix.h"`
    - `#include "/home/shane/code/RIP/include/gpg.h"`
    - `#include "/home/shane/code/RIP/include/mail_parser.h"`
    - `#include "/home/shane/code/RIP/include/memwrap.h"`
    - `#include "/ncc/dbwork/platforms/yucca-debug/glib-indep/include/glib-1.2/glib.h"`
  - `#include "/home/shane/code/RIP/include/mysql_driver.h"`
  - `#include "/home/shane/code/RIP/include/nh.h"`
    - `#include <mysql_driver.h>`
  - `#include "/home/shane/code/RIP/include/notification.h"`
    - `#include <stdarg.h>`
    - `#include <stdio.h>`
    - `#include <strings.h>`
    - `#include <unistd.h>`
    - `#include <stdlib.h>`
    - `#include <time.h>`
    - `#include <glib.h>`
    - `#include "/home/shane/code/RIP/include/UP_util.h"`
      - `#include "/home/shane/code/RIP/include/syntax_api.h"`
  - `#include "/home/shane/code/RIP/include/numconv.h"`
  - `#include "/home/shane/code/RIP/include/pc_commands.h"`
  - `#include "/home/shane/code/RIP/include/properties.h"`
  - `#include "/home/shane/code/RIP/include/protocol_config.h"`
  - `#include "/home/shane/code/RIP/include/protocol_mirror.h"`
    - `#include <glib.h>`
    - `#include "/home/shane/code/RIP/include/mysql_driver.h"`
    - `#include "/home/shane/code/RIP/include/iproutines.h"`
    - `#include "/home/shane/code/RIP/include/aa.h"`
      - `#include "/home/shane/code/RIP/include/iproutines.h"`
  - `#include "/home/shane/code/RIP/include/protocol_whois.h"`
    - `#include "/home/shane/code/RIP/include/query_command.h"`
      - `#include <glib.h>`
      - `#include "/home/shane/code/RIP/include/bitmask.h"`
      - `#include "/home/shane/code/RIP/include/sk.h"`
  - `#include "/home/shane/code/RIP/include/query_command.h"`
  - `#include "/home/shane/code/RIP/include/query_instructions.h"`
    - `#include "/home/shane/code/RIP/include/rxroutines.h"`
    - `#include "/home/shane/code/RIP/include/iproutines.h"`
    - `#include "/home/shane/code/RIP/include/mysql_driver.h"`
    - `#include "/home/shane/code/RIP/include/query_command.h"`
    - `#include "/home/shane/code/RIP/include/defs.h"`
    - `#include "/home/shane/code/RIP/include/which_keytypes.h"`
    - `#include "/home/shane/code/RIP/include/access_control.h"`
    - `#include "/home/shane/code/RIP/include/ca_configFns.h"`
    - `#include "/home/shane/code/RIP/include/ca_dictionary.h"`
    - `#include "/home/shane/code/RIP/include/ca_macros.h"`
    - `#include "/home/shane/code/RIP/include/ca_srcAttribs.h"`
  - `#include "/home/shane/code/RIP/include/rp.h"`
    - `#include <stddef.h>`
    - `#include <glib.h>`
    - `#include <pthread.h>`
    - `#include <defs.h>`
    - `#include <iproutines.h>`
    - `#include <erroutines.h>`
    - `#include <rxroutines.h>`
    - `#include <mysql_driver.h>`
    - `#include "/home/shane/code/RIP/include/ca_defs.h"`
    - `#include <thread.h>`
  - `#include "/home/shane/code/RIP/include/rxroutines.h"`
  - `#include "/home/shane/code/RIP/include/server.h"`
  - `#include "/home/shane/code/RIP/include/sk.h"`
  - `#include "/home/shane/code/RIP/include/stubs.h"`
  - `#include "/home/shane/code/RIP/include/syntax_api.h"`
  - `#include "/home/shane/code/RIP/include/ta.h"`
    - `#include <glib.h>`
    - `#include <pthread.h>`
    - `#include <stdio.h>`
    - `#include "/home/shane/code/RIP/include/stubs.h"`
    - `#include "/home/shane/code/RIP/include/memwrap.h"`
    - `#include "/home/shane/code/RIP/include/sk.h"`
    - `#include "/home/shane/code/RIP/include/timediff.h"`
      - `#include <sys/time.h>`
  - `#include "/home/shane/code/RIP/include/thread.h"`
  - `#include "/home/shane/code/RIP/include/timediff.h"`
  - `#include "/home/shane/code/RIP/include/ud.h"`
  - `#include "/home/shane/code/RIP/include/ud_int.h"`
    - `#include <stdio.h>`
    - `#include <strings.h>`
    - `#include <glib.h>`
    - `#include <stdlib.h>`
    - `#include <ctype.h>`
    - `#include <unistd.h>`
    - `#include "/home/shane/code/RIP/include/defs.h"`
    - `#include "/home/shane/code/RIP/include/mysql_driver.h"`
    - `#include "/home/shane/code/RIP/include/iproutines.h"`
    - `#include "/home/shane/code/RIP/include/erroutines.h"`
    - `#include "/home/shane/code/RIP/include/rp.h"`
    - `#include "/home/shane/code/RIP/include/nh.h"`
    - `#include "/home/shane/code/RIP/include/sk.h"`
    - `#include "/home/shane/code/RIP/include/memwrap.h"`
    - `#include "/home/shane/code/RIP/include/ca_configFns.h"`
    - `#include "/home/shane/code/RIP/include/ca_dictionary.h"`
    - `#include "/home/shane/code/RIP/include/ca_macros.h"`
    - `#include "/home/shane/code/RIP/include/ca_srcAttribs.h"`
    - `#include "/home/shane/code/RIP/include/globaldefs.h"`
    - `#include "/home/shane/code/RIP/include/bitmask.h"`
    - `#include "/home/shane/code/RIP/include/which_keytypes.h"`
  - `#include "/home/shane/code/RIP/include/ud_tr.h"`
    - `#include "/home/shane/code/RIP/include/ud_int.h"`
  - `#include "/home/shane/code/RIP/include/ut_string.h"`
  - `#include "/home/shane/code/RIP/include/wh_queries.h"`
    - `#include "/home/shane/code/RIP/include/sk.h"`
  - `#include "/home/shane/code/RIP/include/which_keytypes.h"`

- `#include <ctype.h>`

- `#include <sys/types.h>`

- `#include <sys/stat.h>`

- `#include <sys/wait.h>`

- `#include <sys/socket.h>`

- `#include <netinet/in.h>`

- `#include <errno.h>`

- `#include <unistd.h>`

- `#include <string.h>`

- `#include <sys/poll.h>`

## Preprocessor definitions

`#define MAX_SOURCES 100`

## Typedef svr_counter_t

`typedef struct {...} svr_counter_t`

`struct` |
`{` |
`int count;` |
`pthread_mutex_t lock;` | Mutex lock.Used for synchronizing changes.
`pthread_cond_t cond;` | condition variable
`}` |

## Typedef svr_args

`typedef struct {...} svr_args`

`struct` |
`{` |
`void (*function)(int);` |
`int conn_sock;` |
`int accept_sock;` |
`int limit;` |
`svr_counter_t* counter;` |
`char* name;` |
`}` |

## Global Variable Lock

`pthread_mutex_t Lock`

Included from | /home/shane/code/RIP/include/ca_defs.h
Visible in: |  | aa/aa.c
|  | ac/access_control.c
|  | ca/ca_configFns.c
|  | ca/ca_initFn.c
|  | ca/ca_sanityCheck.c
|  | ca/ca_sourceLoader.c
|  | ca/ca_values.c
|  | co/constants.c
|  | df/defs.c
|  | er/er.c
|  | er/er_arrays.c
|  | er/er_macro.c
|  | er/er_paths.c
|  | er/er_print.c
|  | ip/ip.c
|  | ma/bitmask.c
|  | mm/mm.c
|  | nh/nh.c
|  | pa/gpg.c
|  | pa/spawn.c
|  | pc/pc_commands.c
|  | pc/protocol_config.c
|  | pm/pm_serials.c
|  | pm/protocol_mirror.c
|  | pr/properties.c
|  | pw/protocol_whois.c
|  | qc/mg_getopt.c
|  | qc/query_command.c
|  | qi/query_instructions.c
|  | rp/rp_convert.c
|  | rp/rp_load.c
|  | rp/rp_search.c
|  | rp/rp_tree.c
|  | rp/rp_update.c
|  | rx/rx_node.c
|  | rx/rx_print.c
|  | rx/rx_search.c
|  | rx/rx_tree.c
|  | sk/cd_socket.c
|  | sk/cd_watchdog.c
|  | sk/sk_socket.c
|  | sq/mysql_driver.c
|  | sv/server.c
Used in: | ca_get_adminIntElement() | ca/ca_configFns.c
| ca_get_adminStrElement() | ca/ca_configFns.c
| ca_get_boolean() | ca/ca_configFns.c
| ca_get_dirlist() | ca/ca_configFns.c
| ca_get_int() | ca/ca_configFns.c
| ca_get_string() | ca/ca_configFns.c
| ca_set_boolean() | ca/ca_configFns.c
| ca_srchandle2Intelement() | ca/ca_configFns.c
| ca_srchandle2Strelement() | ca/ca_configFns.c

## Global Variable SV_whois_sock

`int SV_whois_sock`

Visible in: |  | sv/server.c
Used in: | SV_start() | sv/server.c

## Global Variable SV_config_sock

`int SV_config_sock`

Visible in: |  | sv/server.c
Used in: | SV_start() | sv/server.c

## Global Variable SV_mirror_sock

`int SV_mirror_sock`

Visible in: |  | sv/server.c
Used in: | SV_start() | sv/server.c

## Global Variable SV_update_sock

`int SV_update_sock[100]`

Visible in: |  | sv/server.c
Used in: | SV_start() | sv/server.c

## Global Variable SV_shutdown_send_fd

`int SV_shutdown_send_fd`

Visible in: |  | sv/server.c
Used in: | SV_shutdown() | sv/server.c
| SV_start() | sv/server.c

## Global Variable SV_shutdown_recv_fd

`int SV_shutdown_recv_fd`

Visible in: |  | sv/server.c
Used in: | SV_start() | sv/server.c
| main_loop() | sv/server.c

## Global Variable SV_starttime

Server starting time

`time_t SV_starttime`

Visible in: |  | sv/server.c
| show_uptime() | pc/pc_commands.c
Used in: | SV_start() | sv/server.c
| show_uptime() | pc/pc_commands.c

## Global Variable SV_pidfile

`char* SV_pidfile`

Visible in: |  | sv/server.c
Used in: | SV_shutdown() | sv/server.c
| SV_start() | sv/server.c

## Global Function SV_do_child()

      Handle whois/config/mirror connections. Takes a pointer to the
      service description structure, containing a connected socket, limit
      of active threads, pointer to the counter of them. Does not stop to
      obey the limits, assumes this to be checked and assumes that it is
      already counted.  Decrements the counter on exit.

      Precondition: the counter must be incremented before this function is called.

      Author:
        marek

`void* SV_do_child ( void* varg )`

`void* SV_do_child`
  Actually, does not return anything useful. Just NULL.
`void* varg`
  service description structure.

Calls: | ER_dbg_va() | er/er.c
| counter_add() | sv/server.c
| counter_state() | sv/server.c
| TA_add(), TA_delete(), UT_free_real(), fdwrap_close(), pthread_self()
Used in: | main_loop() | sv/server.c

## Global Function SV_shutdown()

      Shutdown the server.

      More:

      Authors:
            andrei

    Stops the server.

       Close listening sockets (whois, config, mirror and updates)
       Stop all threads by triggering do_server variable.

    .properties

`void SV_shutdown ( void )`

Prototyped in: | /home/shane/code/RIP/include/server.h
Calls: | CO_set_const() | co/constants.c
| ER_inf_va() | er/er.c
| ER_perror() | er/er.c
| ctime_r() | aa/aa.c
| ___errno(), fprintf(), gettimeofday(), sleep(), sprintf(), strcpy(), strerror(), unlink(), write()
Called by: | SV_signal_thread() | sv/server.c
References Variables: | SV_pidfile | sv/server.c
| SV_shutdown_send_fd | sv/server.c

## Global Function SV_signal_thread()

      Handle signals.

      Changes the flags:
      	do_nrtm
      	do_update
      	do_whoisd

      More:

      Author:
            andrei

`void* SV_signal_thread ( void )`

Prototyped in: | /home/shane/code/RIP/include/server.h
Calls: | CO_get_do_update() | co/constants.c
| CO_set_const() | co/constants.c
| SV_shutdown() | sv/server.c
| log_print() | sv/server.c
| sigwait() | aa/aa.c
| pthread_exit(), pthread_sigmask(), sigaddset(), sigemptyset(), sprintf(), strcpy()

## Global Function SV_sleep()

`int SV_sleep ( int delay )`

Prototyped in: | /home/shane/code/RIP/include/server.h
Calls: | CO_get_do_server() | co/constants.c
| sleep()
Called by: | AC_decay() | ac/access_control.c

## Global Function SV_start()

      Start the server.

      More:

      Authors:
            ottrey
            joao

    Starts up the server.

       Create sockets on the necessary ports (whois, config and mirror)
       Start new threads for each service.

    .properties

`int SV_start ( char* pidfile )`

Prototyped in: | /home/shane/code/RIP/include/server.h
Calls: | AC_acc_load() | ac/access_control.c
| AC_build() | ac/access_control.c
| ER_inf_va() | er/er.c
| ER_perror() | er/er.c
| PW_init() | pw/protocol_whois.c
| SK_getsock() | sk/sk_socket.c
| SK_init() | sk/cd_watchdog.c
| SQ_close_connection() | sq/mysql_driver.c
| SQ_get_connection() | sq/mysql_driver.c
| SV_concurrent_server() | sv/server.c
| ca_get_SourceHandleByPosition() | ca/ca_configFns.c
| ca_get_int() | ca/ca_configFns.c
| ca_srchandle2Intelement() | ca/ca_configFns.c
| ca_srchandle2Strelement() | ca/ca_configFns.c
| ctime_r() | aa/aa.c
| radix_init() | sv/server.c
| radix_load() | sv/server.c
| TH_create(), TR_recover(), UT_free_real(), ___errno(), fdwrap_close(), fprintf(), getpid(), gettimeofday(), open(), pipe(), printf(), pthread_exit(), sprintf(), strerror(), strlen(), write()
References Functions: | AC_decay() | ac/access_control.c
| PC_interact() | pc/protocol_config.c
| PM_interact() | pm/protocol_mirror.c
| PW_interact() | pw/protocol_whois.c
| UD_do_nrtm(), UD_do_updates()
References Variables: | SV_config_sock | sv/server.c
| SV_mirror_sock | sv/server.c
| SV_pidfile | sv/server.c
| SV_shutdown_recv_fd | sv/server.c
| SV_shutdown_send_fd | sv/server.c
| SV_starttime | sv/server.c
| SV_update_sock | sv/server.c
| SV_whois_sock | sv/server.c

## Local Function SV_concurrent_server()

      This is the routine that creates the main threads.

      void *  do_function The function to call for each type of service

      More:

      Author:
            ottrey
    	joao
    	marek

`static void SV_concurrent_server ( int sock, int limit, char* name, void do_function(int) )`

`int sock`
  The socket to connect to.
`int limit`
  Limit of active clients (0 == no limit)
`char* name`
  &nbs;
`void do_function(int)`
  &nbs;

Calls: | TH_create(), UT_calloc_real(), pthread_cond_init(), pthread_mutex_init()
Called by: | SV_start() | sv/server.c
References Functions: | main_loop() | sv/server.c

## Local Function asctime_r()

`static char* asctime_r ( const struct tm* __tm, char* __buf )`

Included from: | /usr/include/time.h
Calls: | __posix_asctime_r()

## Local Function counter_add()

      function to operate on the counter structures -
      takes the increment (can be negative), changes the value
      using the locks and everything,

      int
      counter_add            returns the new value.

      Author:
        marek

`static int counter_add ( svr_counter_t* cst, int incval )`

`svr_counter_t* cst`
  counter structure
`int incval`
  increment value (can be negative)

Calls: | pthread_cond_signal(), pthread_mutex_lock(), pthread_mutex_unlock()
Called by: | SV_do_child() | sv/server.c
| counter_state() | sv/server.c
| main_loop() | sv/server.c

## Local Function counter_state()

      int
      counter_state         returns the current value of a counter

      Author:
        marek

`static int counter_state ( svr_counter_t* cst )`

`svr_counter_t* cst`
  counter

Calls: | counter_add() | sv/server.c
Called by: | SV_do_child() | sv/server.c

## Local Function counter_wait()

      waits until the counter is in the range [0-limit].
      unless the limit is 0, in which case the check is disabled.

      Author:
        marek

`static int counter_wait ( svr_counter_t* cst, int limit )`

`int counter_wait`
  returns the new value of the counter after wait
`svr_counter_t* cst`
  counter
`int limit`
  limit / range, or 0 to disable the check

Calls: | pthread_cond_wait(), pthread_mutex_lock(), pthread_mutex_unlock()
Called by: | main_loop() | sv/server.c

## Local Function ctime_r()

`static char* ctime_r ( const time_t* __time, char* __buf )`

Included from: | /usr/include/time.h
Calls: | __posix_ctime_r()
Called by: | SV_shutdown() | sv/server.c
| SV_start() | sv/server.c

## Local Function getlogin_r()

`static int getlogin_r ( char* __name, int __len )`

Included from: | /usr/include/unistd.h
Calls: | __posix_getlogin_r()

## Local Function log_print()

`static void log_print ( const char* arg )`

Calls: | printf()
Called by: | SV_signal_thread() | sv/server.c

## Local Function main_loop()

      Waits for an incoming connection on the and spawns a new thread to
      handle it.  Takes a pointer to the service description structure
      containing the number of the listening socket, limit of active
      threads, pointer to the counter of them, and the function to call
      with a connected socket.  Increments the counter before starting
      a client thread to run SV_do_child().

      More:

      Author:
            ottrey
    	joao
    	andrei (do_server)
    	marek (rewritten/simplified/added limits)

`static void* main_loop ( void* arg )`

`void* arg`
  pointer to the service description structure.

Calls: | CO_get_do_server() | co/constants.c
| ER_dbg_va() | er/er.c
| ER_perror() | er/er.c
| SK_accept_connection() | sk/sk_socket.c
| counter_add() | sv/server.c
| counter_wait() | sv/server.c
| TA_add(), TA_delete(), TA_increment(), TA_setactivity(), TH_create(), UT_malloc_real(), ___errno(), memcpy(), poll(), snprintf(), strerror()
Used in: | SV_concurrent_server() | sv/server.c
References Functions: | SV_do_child() | sv/server.c
References Variables: | SV_shutdown_recv_fd | sv/server.c

## Local Function radix_init()

      Initialize the radix tree - all trees are added to the forest in
      a locked state.  As each tree finishes loading (from radix_load()),
      it is unlocked.

`static void radix_init ( void )`

Calls: | RP_init_trees() | rp/rp_tree.c
| ca_get_SourceHandleByPosition() | ca/ca_configFns.c
| TH_init_read_write_lockw(), fprintf()
Called by: | SV_start() | sv/server.c
References Variables: | rx_forest_rwlock | rp/rp_tree.c

## Local Function radix_load()

      Load the radix tree - all trees are initialized from the appropriate
      SQL tables.  As each tree finishes loading (from radix_load()), it is
      unlocked.  They must be created by the radix_init() function.

`static void radix_load ( void )`

Calls: | RP_sql_load_reg() | rp/rp_load.c
| ca_get_SourceHandleByPosition() | ca/ca_configFns.c
| fprintf()
Called by: | SV_start() | sv/server.c

## Local Function readdir_r()

`static int readdir_r ( DIR* __dp, struct dirent* __ent, struct dirent** __res )`

Included from: | /usr/include/dirent.h
Calls: | __posix_readdir_r()

## Local Function sigwait()

`static int sigwait ( const sigset_t* __setp, int* __signo )`

Included from: | /usr/include/signal.h
Calls: | __posix_sigwait()
Called by: | SV_signal_thread() | sv/server.c

## Local Function ttyname_r()

`static int ttyname_r ( int __fildes, char* __buf, size_t __size )`

Included from: | /usr/include/unistd.h
Calls: | __posix_ttyname_r()