add shutdown points at strategic points in the code

remotes/svn/trunk
Richard Fuchs 13 years ago
parent d97d2430bf
commit 924af07388

10
cdr.c

@ -3,6 +3,7 @@
#include "medmysql.h"
#include "config.h"
#include "cdr.h"
#include "mediator.h"
static char* cdr_map_status(const char *sip_status)
{
@ -75,6 +76,9 @@ int cdr_process_records(med_entry_t *records, u_int64_t count, u_int64_t *ext_co
++msg_unknowns;
e->method = MED_UNRECOGNIZED;
}
if (check_shutdown())
return -1;
}
/*syslog(LOG_DEBUG, "%d INVITEs, %d BYEs, %d unrecognized", msg_invites, msg_byes, msg_unknowns);*/
@ -422,6 +426,9 @@ int cdr_create_cdrs(med_entry_t *records, u_int64_t count,
endtime = e->timestamp;
unix_endtime = e->unix_timestamp;
}
if (check_shutdown())
return -1;
}
if(invites == 0)
@ -496,6 +503,9 @@ int cdr_create_cdrs(med_entry_t *records, u_int64_t count,
// TODO: error handling
}
}
if (check_shutdown())
return -1;
}
*cdr_count = cdr_index;

@ -17,7 +17,7 @@
#include "medmysql.h"
#include "cdr.h"
static sig_atomic_t mediator_shutdown = 0;
sig_atomic_t mediator_shutdown = 0;
int mediator_lockfd = -1;
u_int64_t mediator_count = 0;

@ -47,6 +47,7 @@
#define MED_SEP '|'
extern int mediator_lockfd;
extern sig_atomic_t mediator_shutdown;
typedef enum {
MED_INVITE = 1,
@ -80,5 +81,13 @@ extern GHashTable *med_uuid_table;
void critical(const char *);
static inline int check_shutdown(void) {
if (mediator_shutdown) {
syslog(LOG_INFO, "Shutdown detected, aborting work in progress");
return 1;
}
return 0;
}
#endif /* _MEDIATOR_H */

@ -174,6 +174,9 @@ int medmysql_fetch_callids(med_callid_t **callids, u_int64_t *count)
}
/*syslog(LOG_DEBUG, "callid[%"PRIu64"]='%s'", i, c->value);*/
if (check_shutdown())
return -1;
}
out:
@ -241,6 +244,9 @@ int medmysql_fetch_records(med_callid_t *callid,
g_strlcpy(e->dst_leg, row[7], sizeof(e->dst_leg));
e->med_id = atoll(row[8]);
e->valid = 1;
if (check_shutdown())
return -1;
}
out:
@ -420,6 +426,9 @@ int medmysql_insert_cdrs(cdr_entry_t *entries, u_int64_t count, struct medmysql_
CDRPRINT(",");
CDRESCAPE(str_split);
CDRPRINT("),");
if (check_shutdown())
return -1;
}
/*syslog(LOG_DEBUG, "q='%s'", query);*/
@ -603,13 +612,13 @@ static int medmysql_flush_medlist(struct medmysql_str *str) {
}
int medmysql_batch_end(struct medmysql_batches *batches) {
if (medmysql_flush_cdr(batches))
if (medmysql_flush_cdr(batches) || check_shutdown())
return -1;
if (medmysql_flush_medlist(&batches->acc_trash))
if (medmysql_flush_medlist(&batches->acc_trash) || check_shutdown())
return -1;
if (medmysql_flush_medlist(&batches->acc_backup))
if (medmysql_flush_medlist(&batches->acc_backup) || check_shutdown())
return -1;
if (medmysql_flush_medlist(&batches->to_delete))
if (medmysql_flush_medlist(&batches->to_delete) || check_shutdown())
return -1;
if (mysql_query_wrapper(cdr_handler, "commit", 6))

Loading…
Cancel
Save