use fdfs_get_ipaddr_by_peer_ip

pull/484/head
YuQing 2019-12-04 15:59:31 +08:00
parent 33b539eac6
commit 867dc29111
2 changed files with 15 additions and 8 deletions

View File

@ -23,10 +23,11 @@
#include <sys/param.h> #include <sys/param.h>
#include "fdfs_define.h" #include "fdfs_define.h"
#include "fastcommon/logger.h" #include "fastcommon/logger.h"
#include "fdfs_global.h" #include "fastcommon/fc_list.h"
#include "fastcommon/sockopt.h" #include "fastcommon/sockopt.h"
#include "fastcommon/avl_tree.h" #include "fastcommon/avl_tree.h"
#include "fastcommon/shared_func.h" #include "fastcommon/shared_func.h"
#include "fdfs_global.h"
#include "tracker_types.h" #include "tracker_types.h"
#include "tracker_proto.h" #include "tracker_proto.h"
#include "storage_global.h" #include "storage_global.h"
@ -43,11 +44,13 @@ typedef struct {
int id; //trunk file id int id; //trunk file id
} FDFSTrunkFileIdInfo; } FDFSTrunkFileIdInfo;
typedef struct { typedef struct recovery_thread_data {
struct fc_list_head link;
int thread_index; //-1 for global int thread_index; //-1 for global
int result; int result;
bool done; bool done;
const char *base_path; const char *base_path;
pthread_t tid;
} RecoveryThreadData; } RecoveryThreadData;
#define RECOVERY_BINLOG_FILENAME ".binlog.recovery" #define RECOVERY_BINLOG_FILENAME ".binlog.recovery"
@ -1321,7 +1324,7 @@ static int storage_disk_recovery_do_restore(const char *pBasePath)
if (__sync_fetch_and_add(&current_recovery_thread_count, 0) > 0) if (__sync_fetch_and_add(&current_recovery_thread_count, 0) > 0)
{ {
for (i=0; i<60; i++) for (i=0; i<10; i++)
{ {
if ((thread_count=__sync_fetch_and_add( if ((thread_count=__sync_fetch_and_add(
&current_recovery_thread_count, 0)) == 0) &current_recovery_thread_count, 0)) == 0)

View File

@ -413,8 +413,10 @@ static int tracker_check_and_sync(struct fast_task_info *pTask, \
pDestServer->status = pServer->status; pDestServer->status = pServer->status;
memcpy(pDestServer->id, pServer->id, memcpy(pDestServer->id, pServer->id,
FDFS_STORAGE_ID_MAX_SIZE); FDFS_STORAGE_ID_MAX_SIZE);
memcpy(pDestServer->ip_addr, FDFS_CURRENT_IP_ADDR(pServer), memcpy(pDestServer->ip_addr,
IP_ADDRESS_SIZE); fdfs_get_ipaddr_by_peer_ip(&pServer->ip_addrs,
pTask->client_ip), IP_ADDRESS_SIZE);
int2buff(pClientInfo->pGroup->storage_port, int2buff(pClientInfo->pGroup->storage_port,
pDestServer->port); pDestServer->port);
} }
@ -438,8 +440,9 @@ static int tracker_check_and_sync(struct fast_task_info *pTask, \
pDestServer->status = (*ppServer)->status; pDestServer->status = (*ppServer)->status;
memcpy(pDestServer->id, (*ppServer)->id, memcpy(pDestServer->id, (*ppServer)->id,
FDFS_STORAGE_ID_MAX_SIZE); FDFS_STORAGE_ID_MAX_SIZE);
memcpy(pDestServer->ip_addr, FDFS_CURRENT_IP_ADDR(*ppServer), memcpy(pDestServer->ip_addr,
IP_ADDRESS_SIZE); fdfs_get_ipaddr_by_peer_ip(&(*ppServer)->ip_addrs,
pTask->client_ip), IP_ADDRESS_SIZE);
int2buff(pClientInfo->pGroup->storage_port, int2buff(pClientInfo->pGroup->storage_port,
pDestServer->port); pDestServer->port);
pDestServer++; pDestServer++;
@ -2400,7 +2403,8 @@ static int tracker_deal_server_list_group_storages(struct fast_task_info *pTask)
pStorageStat = &((*ppServer)->stat); pStorageStat = &((*ppServer)->stat);
pDest->status = (*ppServer)->status; pDest->status = (*ppServer)->status;
strcpy(pDest->id, (*ppServer)->id); strcpy(pDest->id, (*ppServer)->id);
strcpy(pDest->ip_addr, FDFS_CURRENT_IP_ADDR(*ppServer)); strcpy(pDest->ip_addr, fdfs_get_ipaddr_by_peer_ip(
&(*ppServer)->ip_addrs, pTask->client_ip));
if ((*ppServer)->psync_src_server != NULL) if ((*ppServer)->psync_src_server != NULL)
{ {
strcpy(pDest->src_id, \ strcpy(pDest->src_id, \