Fixed warning for not using return values for write when writing lock file.

Removed host table from peer hosts, just use ip.
0.2
Andreas Granig 15 years ago
parent 102875a41e
commit dcb38257a5

@ -434,10 +434,6 @@ void cdr_set_provider(cdr_entry_t *cdr)
{
g_strlcpy(cdr->source_provider_id, val, sizeof(cdr->source_provider_id));
}
else if((val = g_hash_table_lookup(med_peer_host_table, cdr->source_domain)) != NULL)
{
g_strlcpy(cdr->source_provider_id, val, sizeof(cdr->source_provider_id));
}
else
{
g_strlcpy(cdr->source_provider_id, "0", sizeof(cdr->source_provider_id));
@ -458,10 +454,6 @@ void cdr_set_provider(cdr_entry_t *cdr)
{
g_strlcpy(cdr->destination_provider_id, val, sizeof(cdr->destination_provider_id));
}
else if((val = g_hash_table_lookup(med_peer_host_table, cdr->destination_domain)) != NULL)
{
g_strlcpy(cdr->destination_provider_id, val, sizeof(cdr->destination_provider_id));
}
else
{
g_strlcpy(cdr->destination_provider_id, "0", sizeof(cdr->destination_provider_id));

@ -21,7 +21,6 @@ static sig_atomic_t mediator_shutdown = 0;
int mediator_lockfd = -1;
u_int64_t mediator_count = 0;
GHashTable *med_peer_host_table = NULL;
GHashTable *med_peer_ip_table = NULL;
GHashTable *med_uuid_table = NULL;
@ -29,11 +28,10 @@ GHashTable *med_uuid_table = NULL;
/**********************************************************************/
static int mediator_load_maps()
{
med_peer_host_table = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
med_peer_ip_table = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
med_uuid_table = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
if(medmysql_load_maps(med_peer_host_table, med_peer_ip_table))
if(medmysql_load_maps(med_peer_ip_table))
return -1;
if(medmysql_load_uuids(med_uuid_table))
return -1;
@ -50,8 +48,6 @@ static void mediator_print_mapentry(gpointer key, gpointer value, gpointer d)
/**********************************************************************/
static void mediator_destroy_maps()
{
if(med_peer_host_table)
g_hash_table_destroy(med_peer_host_table);
if(med_peer_ip_table)
g_hash_table_destroy(med_peer_ip_table);
if(med_uuid_table)
@ -61,8 +57,6 @@ static void mediator_destroy_maps()
/**********************************************************************/
static void mediator_print_maps()
{
syslog(LOG_DEBUG, "Peer host map:");
g_hash_table_foreach(med_peer_host_table, mediator_print_mapentry, NULL);
syslog(LOG_DEBUG, "Peer IP map:");
g_hash_table_foreach(med_peer_ip_table, mediator_print_mapentry, NULL);
syslog(LOG_DEBUG, "UUID map:");
@ -280,6 +274,7 @@ out:
void critical(const char *msg) {
write(mediator_lockfd, msg, strlen(msg));
write(mediator_lockfd, "\n", 1);
int ret;
ret = write(mediator_lockfd, msg, strlen(msg));
ret = write(mediator_lockfd, "\n", 1);
}

@ -13,7 +13,7 @@
"src_leg, dst_leg, id " \
"from acc where callid = '%s' order by time asc"
#define MED_LOAD_PEER_QUERY "select h.domain, h.ip, g.peering_contract_id " \
#define MED_LOAD_PEER_QUERY "select h.ip, g.peering_contract_id " \
"from provisioning.voip_peer_hosts h, provisioning.voip_peer_groups g " \
"where g.id = h.group_id"
#define MED_LOAD_UUID_QUERY "select vs.uuid, r.contract_id from billing.voip_subscribers vs, " \
@ -391,14 +391,13 @@ int medmysql_insert_cdrs(cdr_entry_t *entries, u_int64_t count, struct medmysql_
}
/**********************************************************************/
int medmysql_load_maps(GHashTable *host_table, GHashTable *ip_table)
int medmysql_load_maps(GHashTable *ip_table)
{
MYSQL_RES *res;
MYSQL_ROW row;
int ret = 0;
char query[1024] = "";
gpointer key;
char* host_id;
char* ip_id;
snprintf(query, sizeof(query), MED_LOAD_PEER_QUERY);
@ -415,52 +414,32 @@ int medmysql_load_maps(GHashTable *host_table, GHashTable *ip_table)
while((row = mysql_fetch_row(res)) != NULL)
{
host_id = NULL;
ip_id = NULL;
if(row[0] == NULL || row[1] == NULL || row[2] == NULL)
if(row[0] == NULL || row[1] == NULL)
{
syslog(LOG_CRIT, "Error loading peer hosts, a column is NULL");
ret = -1;
goto out;
}
host_id = strdup(row[2]);
if(host_id == NULL)
{
syslog(LOG_CRIT, "Error allocating host id memory: %s", strerror(errno));
ret = -1;
goto out;
}
ip_id = strdup(row[2]);
ip_id = strdup(row[1]);
if(ip_id == NULL)
{
syslog(LOG_CRIT, "Error allocating ip id memory: %s", strerror(errno));
free(host_id);
ret = -1;
goto out;
}
if(g_hash_table_lookup(host_table, row[0]) != NULL)
{
syslog(LOG_WARNING, "Skipping duplicate hostname '%s'", row[0]);
}
else
{
key = (gpointer)g_strdup(row[0]);
g_hash_table_insert(host_table, key, host_id);
}
if(ip_table != NULL)
{
if(g_hash_table_lookup(ip_table, row[1]) != NULL)
if(g_hash_table_lookup(ip_table, row[0]) != NULL)
{
syslog(LOG_WARNING, "Skipping duplicate IP '%s'", row[1]);
}
else
{
key = (gpointer)g_strdup(row[1]);
key = (gpointer)g_strdup(row[0]);
g_hash_table_insert(ip_table, key, ip_id);
}
}

@ -28,7 +28,7 @@ int medmysql_trash_entries(const char *callid, struct medmysql_batches *);
int medmysql_backup_entries(const char *callid, struct medmysql_batches *);
int medmysql_delete_entries(const char *callid, struct medmysql_batches *);
int medmysql_insert_cdrs(cdr_entry_t *records, u_int64_t count, struct medmysql_batches *);
int medmysql_load_maps(GHashTable *host_table, GHashTable *ip_table);
int medmysql_load_maps(GHashTable *ip_table);
int medmysql_load_uuids(GHashTable *uuid_table);
int medmysql_batch_start(struct medmysql_batches *);
int medmysql_batch_end(struct medmysql_batches *);

Loading…
Cancel
Save