dump local host ip

multi_ipaddr
YuQing 2019-10-16 08:56:18 +08:00
parent 0d940c07ac
commit 1143859c86
3 changed files with 32 additions and 12 deletions

View File

@ -32,6 +32,7 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize)
char reserved_space_str[32]; char reserved_space_str[32];
char tracker_client_ip_str[256]; char tracker_client_ip_str[256];
char last_storage_ip_str[256]; char last_storage_ip_str[256];
char *p;
int total_len; int total_len;
int i; int i;
@ -250,14 +251,18 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize)
g_path_space_list[i].free_mb); g_path_space_list[i].free_mb);
} }
total_len += snprintf(buff + total_len, buffSize - total_len, if (total_len < buffSize - 1)
"\ng_local_host_ip_count=%d\n", g_local_host_ip_count); {
for (i=0; i<g_local_host_ip_count; i++) *(buff + total_len++) = '\n';
{ }
total_len += snprintf(buff + total_len, buffSize - total_len, p = buff + total_len;
"\tg_local_host_ip_addrs[%d]=%s\n", i, local_host_ip_addrs_to_string(p, buffSize - total_len);
g_local_host_ip_addrs + i * IP_ADDRESS_SIZE); total_len += strlen(p);
} if (total_len < buffSize - 1)
{
*(buff + total_len++) = '\n';
}
*(buff + total_len) = '\0';
return total_len; return total_len;
} }

View File

@ -693,7 +693,7 @@ int fdfs_get_storage_ids_from_tracker_server(TrackerServerInfo *pTrackerServer)
} }
*p = '\0'; *p = '\0';
logInfo("list_count: %d, storage ids:\n%s", list_count, content); //logInfo("list_count: %d, storage ids:\n%s", list_count, content);
result = fdfs_load_storage_ids(content, \ result = fdfs_load_storage_ids(content, \
"storage-ids-from-tracker"); "storage-ids-from-tracker");

View File

@ -288,6 +288,7 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize)
{ {
int total_len; int total_len;
char reserved_space_str[32]; char reserved_space_str[32];
char *p;
total_len = snprintf(buff, buffSize, total_len = snprintf(buff, buffSize,
"g_fdfs_connect_timeout=%ds\n" "g_fdfs_connect_timeout=%ds\n"
@ -403,6 +404,19 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize)
#endif #endif
); );
if (total_len < buffSize - 1)
{
*(buff + total_len++) = '\n';
}
p = buff + total_len;
local_host_ip_addrs_to_string(p, buffSize - total_len);
total_len += strlen(p);
if (total_len < buffSize - 1)
{
*(buff + total_len++) = '\n';
}
*(buff + total_len) = '\0';
return total_len; return total_len;
} }
@ -411,7 +425,7 @@ static int fdfs_dump_tracker_servers(char *buff, const int buffSize)
int total_len; int total_len;
TrackerServerInfo *pTrackerServer; TrackerServerInfo *pTrackerServer;
TrackerServerInfo *pTrackerEnd; TrackerServerInfo *pTrackerEnd;
ConnectionInfo *conn; char ip_str[256];
total_len = snprintf(buff, buffSize, \ total_len = snprintf(buff, buffSize, \
"g_tracker_servers.server_count=%d, " \ "g_tracker_servers.server_count=%d, " \
@ -427,11 +441,12 @@ static int fdfs_dump_tracker_servers(char *buff, const int buffSize)
for (pTrackerServer=g_tracker_servers.servers; \ for (pTrackerServer=g_tracker_servers.servers; \
pTrackerServer<pTrackerEnd; pTrackerServer++) pTrackerServer<pTrackerEnd; pTrackerServer++)
{ {
conn = pTrackerServer->connections; fdfs_server_info_to_string(pTrackerServer, ip_str, sizeof(ip_str));
total_len += snprintf(buff + total_len, buffSize - total_len, total_len += snprintf(buff + total_len, buffSize - total_len,
"\t%d. tracker server=%s:%d\n", \ "\t%d. tracker server=%s:%d\n", \
(int)(pTrackerServer - g_tracker_servers.servers) + 1, \ (int)(pTrackerServer - g_tracker_servers.servers) + 1, \
conn->ip_addr, conn->port); ip_str, pTrackerServer->connections[0].port);
} }
return total_len; return total_len;