- feature: auto-save registration table during operation
This commit is contained in:
parent
2fd9cde299
commit
2757a6bad6
@ -1,5 +1,6 @@
|
||||
0.5.11
|
||||
======
|
||||
15-Apr-2005: - feature: auto-save registration table during operation
|
||||
10-Apr-2005: - started DocBook documentation
|
||||
3-Apr-2005: - fix: changing public IP address
|
||||
27-Mar-2005: - feature: siproxd "in front of" a NAT router should work
|
||||
|
||||
@ -90,6 +90,11 @@ user = nobody
|
||||
# the specified directory path does exist!
|
||||
registration_file = /var/lib/siproxd/siproxd_registrations
|
||||
|
||||
######################################################################
|
||||
# Automatically save current registrations every 'n' seconds
|
||||
#
|
||||
autosave_registrations = 300
|
||||
|
||||
######################################################################
|
||||
# PID file:
|
||||
# Where to create the PID file.
|
||||
|
||||
@ -175,6 +175,7 @@ static int parse_config (FILE *configfile) {
|
||||
{ "log_calls", TYP_INT4, &configuration.log_calls },
|
||||
{ "pid_file", TYP_STRING, &configuration.pid_file },
|
||||
{ "default_expires", TYP_INT4, &configuration.default_expires },
|
||||
{ "autosave_registrations",TYP_INT4, &configuration.autosave_registrations },
|
||||
{0, 0, 0}
|
||||
};
|
||||
|
||||
|
||||
@ -40,9 +40,15 @@ static char const ident[]="$Id$";
|
||||
/* configuration storage */
|
||||
extern struct siproxd_config configuration;
|
||||
|
||||
struct urlmap_s urlmap[URLMAP_SIZE]; /* URL mapping table */
|
||||
/* URL mapping table */
|
||||
struct urlmap_s urlmap[URLMAP_SIZE];
|
||||
|
||||
/* time of last save */
|
||||
static time_t last_save=0;
|
||||
|
||||
extern int errno;
|
||||
|
||||
|
||||
/*
|
||||
* initialize the URL mapping table
|
||||
*/
|
||||
@ -104,6 +110,8 @@ void register_init(void) {
|
||||
fclose(stream);
|
||||
}
|
||||
}
|
||||
/* initialize save-timer */
|
||||
time(&last_save);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -111,7 +119,7 @@ void register_init(void) {
|
||||
/*
|
||||
* shut down the URL mapping table
|
||||
*/
|
||||
void register_shut(void) {
|
||||
void register_save(void) {
|
||||
int i;
|
||||
FILE *stream;
|
||||
|
||||
@ -455,11 +463,13 @@ int register_client(sip_ticket_t *ticket, int force_lcl_masq) {
|
||||
/*
|
||||
* cyclically called to do the aging of the URL mapping table entries
|
||||
* and throw out expired entries.
|
||||
* Also we do the cyclic saving here - if required.
|
||||
*/
|
||||
void register_agemap(void) {
|
||||
int i;
|
||||
time_t t;
|
||||
|
||||
/* expire old entries */
|
||||
time(&t);
|
||||
DEBUGC(DBCLASS_BABBLE,"sip_agemap, t=%i",(int)t);
|
||||
for (i=0; i<URLMAP_SIZE; i++) {
|
||||
@ -470,9 +480,16 @@ void register_agemap(void) {
|
||||
osip_uri_free(urlmap[i].true_url);
|
||||
osip_uri_free(urlmap[i].masq_url);
|
||||
osip_uri_free(urlmap[i].reg_url);
|
||||
// osip_via_free(urlmap[i].via);
|
||||
}
|
||||
}
|
||||
|
||||
/* auto-save of registration table */
|
||||
if ((configuration.autosave_registrations > 0) &&
|
||||
((last_save + configuration.autosave_registrations) < t)) {
|
||||
DEBUGC(DBCLASS_REG,"auto-saving registration table");
|
||||
register_save();
|
||||
last_save = t;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -507,8 +507,8 @@ int main (int argc, char *argv[])
|
||||
} /* while TRUE */
|
||||
exit_prg:
|
||||
|
||||
/* dump current known SIP registrations */
|
||||
register_shut();
|
||||
/* save current known SIP registrations */
|
||||
register_save();
|
||||
INFO("properly terminating siproxd");
|
||||
|
||||
/* remove PID file */
|
||||
|
||||
@ -87,6 +87,7 @@ struct siproxd_config {
|
||||
int log_calls;
|
||||
char *pid_file;
|
||||
int default_expires;
|
||||
int autosave_registrations;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -125,7 +126,7 @@ int sockbind(struct in_addr ipaddr, int localport, int errflg);
|
||||
|
||||
/* register.c */
|
||||
void register_init(void);
|
||||
void register_shut(void);
|
||||
void register_save(void);
|
||||
int register_client(sip_ticket_t *ticket, int force_lcl_masq); /*X*/
|
||||
void register_agemap(void);
|
||||
int register_response(sip_ticket_t *ticket, int flag); /*X*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user