FS-3277 --resolve There are actually really only 2 places where it needs the real hostname, the hostname command and the header on the events. I changed everything to the switchname because there were some more sql stmts etc in the core.

This commit is contained in:
Anthony Minessale committed 2011-04-29 10:24:50 -05:00
1 parent 5510618660
commit 00b53a91ea
18 files changed
+102 -93

No files matched your search

@@ -366,7 +366,6 @@ static long do_lookup_url(switch_memory_pool_t *pool, switch_event_t *event, cha
switch_time_t time_diff = 0;
CURL *curl_handle = NULL;
long httpRes = 0;
char hostname[256] = "";
struct http_data http_data;
@@ -375,8 +374,6 @@ static long do_lookup_url(switch_memory_pool_t *pool, switch_event_t *event, cha
http_data.max_bytes = 10240;
SWITCH_STANDARD_STREAM(http_data.stream);
gethostname(hostname, sizeof(hostname));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "url: %s\n", query);
curl_handle = curl_easy_init();
@@ -249,9 +249,13 @@ SWITCH_STANDARD_API(banner_function)
SWITCH_STANDARD_API(hostname_api_function)
{
char hostname[256] = "";
gethostname(hostname, sizeof(hostname));
stream->write_function(stream, "%s", hostname);
stream->write_function(stream, "%s", switch_core_get_hostname());
return SWITCH_STATUS_SUCCESS;
}
SWITCH_STANDARD_API(switchname_api_function)
{
stream->write_function(stream, "%s", switch_core_get_switchname());
return SWITCH_STATUS_SUCCESS;
}
@@ -3862,9 +3866,7 @@ SWITCH_STANDARD_API(show_function)
char *command = NULL, *as = NULL;
switch_core_flag_t cflags = switch_core_flags();
switch_status_t status = SWITCH_STATUS_SUCCESS;
char hostname[256] = "";
gethostname(hostname, sizeof(hostname));
const char *hostname = switch_core_get_switchname();
if (!(cflags & SCF_USE_SQL)) {
stream->write_function(stream, "-ERR SQL DISABLED NO DATA AVAILABLE!\n");
@@ -5150,6 +5152,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
SWITCH_ADD_API(commands_api_interface, "help", "Show help for all the api commands", help_function, "");
SWITCH_ADD_API(commands_api_interface, "host_lookup", "host_lookup", host_lookup_function, "<hostname>");
SWITCH_ADD_API(commands_api_interface, "hostname", "Returns the system hostname", hostname_api_function, "");
SWITCH_ADD_API(commands_api_interface, "switchname", "Returns the switch name", switchname_api_function, "");
SWITCH_ADD_API(commands_api_interface, "hupall", "hupall", hupall_api_function, "<cause> [<var> <value>]");
SWITCH_ADD_API(commands_api_interface, "in_group", "determine if a user is in a group", in_group_function, "<user>[@<domain>] <group_name>");
SWITCH_ADD_API(commands_api_interface, "is_lan_addr", "see if an ip is a lan addr", lan_addr_function, "<ip>");
-3
View File
@@ -104,7 +104,6 @@ static http_data_t *do_lookup_url(switch_memory_pool_t *pool, const char *url, c
CURL *curl_handle = NULL;
long httpRes = 0;
char hostname[256] = "";
http_data_t *http_data = NULL;
@@ -115,8 +114,6 @@ static http_data_t *do_lookup_url(switch_memory_pool_t *pool, const char *url, c
http_data->max_bytes = 64000;
SWITCH_STANDARD_STREAM(http_data->stream);
gethostname(hostname, sizeof(hostname));
if (!method) {
method = "get";
}
+1 -1
View File
@@ -598,7 +598,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_db_load)
switch_limit_interface_t *limit_interface;
memset(&globals, 0, sizeof(&globals));
gethostname(globals.hostname, sizeof(globals.hostname));
strncpy(globals.hostname, switch_core_get_switchname(), sizeof(globals.hostname));
globals.pool = pool;
@@ -67,7 +67,7 @@ static switch_xml_config_int_options_t config_int_ht_0 = { SWITCH_TRUE, 0 };
static struct {
switch_hash_t *profile_hash;
char hostname[256];
const char *hostname;
int integer;
int debug;
char *dbname;
@@ -949,7 +949,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_directory_load)
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
gethostname(globals.hostname, sizeof(globals.hostname));
globals.hostname = switch_core_get_switchname();
globals.dbname = switch_core_sprintf(pool, "directory");
+1 -1
View File
@@ -3885,7 +3885,7 @@ static switch_status_t load_config(int reload, int del_all)
switch_cache_db_handle_t *dbh = NULL;
fifo_node_t *node;
gethostname(globals.hostname, sizeof(globals.hostname));
strncpy(globals.hostname, switch_core_get_switchname(), sizeof(globals.hostname));
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf);
+5 -5
View File
@@ -89,7 +89,7 @@ SWITCH_LIMIT_INCR(limit_incr_redis)
}
/* Get the keys for redis server */
uuid_rediskey = switch_core_session_sprintf(session,"%s_%s_%s", switch_core_get_hostname(), realm, resource);
uuid_rediskey = switch_core_session_sprintf(session,"%s_%s_%s", switch_core_get_switchname(), realm, resource);
rediskey = switch_core_session_sprintf(session, "%s_%s", realm, resource);
if ((pvt = switch_channel_get_private(channel, "limit_redis"))) {
@@ -179,7 +179,7 @@ SWITCH_LIMIT_RELEASE(limit_release_redis)
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Couldn't decrement value corresponding to %s\n", (char *)p_key);
switch_goto_status(SWITCH_STATUS_FALSE, end);
}
p_uuid_key = switch_core_session_sprintf(session, "%s_%s", switch_core_get_hostname(), (char *)p_key);
p_uuid_key = switch_core_session_sprintf(session, "%s_%s", switch_core_get_switchname(), (char *)p_key);
if (credis_decr(redis,p_uuid_key,&uuid_val) != 0) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Couldn't decrement value corresponding to %s\n", p_uuid_key);
switch_goto_status(SWITCH_STATUS_FALSE, end);
@@ -193,7 +193,7 @@ SWITCH_LIMIT_RELEASE(limit_release_redis)
} else {
rediskey = switch_core_session_sprintf(session, "%s_%s", realm, resource);
uuid_rediskey = switch_core_session_sprintf(session, "%s_%s_%s", switch_core_get_hostname(), realm, resource);
uuid_rediskey = switch_core_session_sprintf(session, "%s_%s_%s", switch_core_get_switchname(), realm, resource);
switch_core_hash_delete(pvt->hash, (const char *) rediskey);
if (credis_decr(redis, rediskey, &val) != 0) {
@@ -249,13 +249,13 @@ SWITCH_LIMIT_RESET(limit_reset_redis)
{
REDIS redis;
if (redis_factory(&redis) == SWITCH_STATUS_SUCCESS) {
char *rediskey = switch_mprintf("%s_*", switch_core_get_hostname());
char *rediskey = switch_mprintf("%s_*", switch_core_get_switchname());
int dec = 0, val = 0, keyc;
char *uuids[2000];
if ((keyc = credis_keys(redis, rediskey, uuids, switch_arraylen(uuids))) > 0) {
int i = 0;
int hostnamelen = strlen(switch_core_get_hostname())+1;
int hostnamelen = strlen(switch_core_get_switchname())+1;
for (i = 0; i < keyc && uuids[i]; i++){
const char *key = uuids[i] + hostnamelen;
+2 -1
View File
@@ -4956,7 +4956,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load)
switch_find_local_ip(mod_sofia_globals.guess_ip, sizeof(mod_sofia_globals.guess_ip), &mod_sofia_globals.guess_mask, AF_INET);
in.s_addr = mod_sofia_globals.guess_mask;
switch_set_string(mod_sofia_globals.guess_mask_str, inet_ntoa(in));
gethostname(mod_sofia_globals.hostname, sizeof(mod_sofia_globals.hostname));
strcpy(mod_sofia_globals.hostname, switch_core_get_switchname());
switch_core_hash_init(&mod_sofia_globals.profile_hash, mod_sofia_globals.pool);
@@ -51,7 +51,6 @@ static struct {
char *address;
char *bindings;
uint32_t key_count;
char hostname[80];
switch_port_t port;
switch_sockaddr_t *addr;
switch_socket_t *udp_socket;
@@ -282,7 +281,7 @@ static void event_handler(switch_event_t *event)
case SWITCH_EVENT_LOG:
return;
default:
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Multicast-Sender", globals.hostname);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Multicast-Sender", switch_core_get_switchname());
if (switch_event_serialize(event, &packet, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
size_t len;
char *buf;
@@ -377,7 +376,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_event_multicast_load)
switch_core_hash_init(&globals.event_hash, module_pool);
switch_core_hash_init(&globals.peer_hash, module_pool);
gethostname(globals.hostname, sizeof(globals.hostname));
globals.key_count = 0;
if (load_config() != SWITCH_STATUS_SUCCESS) {
+3 -4
View File
@@ -140,7 +140,7 @@ int channelList_load(netsnmp_cache *cache, void *vmagic)
idx = 1;
sprintf(sql, "SELECT * FROM channels WHERE hostname='%s' ORDER BY created_epoch", switch_core_get_hostname());
sprintf(sql, "SELECT * FROM channels WHERE hostname='%s' ORDER BY created_epoch", switch_core_get_switchname());
switch_cache_db_execute_sql_callback(dbh, sql, channelList_callback, NULL, NULL);
switch_cache_db_release_db_handle(&dbh);
@@ -237,14 +237,13 @@ int handle_systemStats(netsnmp_mib_handler *handler, netsnmp_handler_registratio
case SS_CURRENT_CALLS:
{
switch_cache_db_handle_t *dbh;
char sql[1024] = "", hostname[256] = "";
char sql[1024] = "";
if (switch_core_db_handle(&dbh) != SWITCH_STATUS_SUCCESS) {
return SNMP_ERR_GENERR;
}
gethostname(hostname, sizeof(hostname));
sprintf(sql, "SELECT COUNT(*) FROM calls WHERE hostname='%s'", hostname);
sprintf(sql, "SELECT COUNT(*) FROM calls WHERE hostname='%s'", switch_core_get_switchname());
switch_cache_db_execute_sql_callback(dbh, sql, sql_count_callback, &int_val, NULL);
snmp_set_var_typed_integer(requests->requestvb, ASN_GAUGE, int_val);
switch_cache_db_release_db_handle(&dbh);
+1 -1
View File
@@ -155,7 +155,7 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con
char *uri = NULL;
char *dynamic_url = NULL;
gethostname(hostname, sizeof(hostname));
strncpy(hostname, switch_core_get_switchname(), sizeof(hostname));
if (!binding) {
return NULL;