proto fetch storage ids add field allow_empty
parent
ba41d958b2
commit
67af9585d8
|
|
@ -406,18 +406,17 @@ int fdfs_load_storage_ids(char *content, const char *pStorageIdsFilename)
|
|||
}
|
||||
|
||||
pHost = group_name;
|
||||
while (!(*pHost == ' ' || *pHost == '\t' \
|
||||
|| *pHost == '\0'))
|
||||
while (!(*pHost == ' ' || *pHost == '\t' || *pHost == '\0'))
|
||||
{
|
||||
pHost++;
|
||||
}
|
||||
|
||||
if (*pHost == '\0')
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"config file: %s, line no: %d, " \
|
||||
"content: %s, invalid format, " \
|
||||
"expect ip address!", __LINE__, \
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"config file: %s, line no: %d, "
|
||||
"content: %s, invalid format, "
|
||||
"expect ip address!", __LINE__,
|
||||
pStorageIdsFilename, i + 1, line);
|
||||
result = EINVAL;
|
||||
break;
|
||||
|
|
@ -567,7 +566,7 @@ int fdfs_get_storage_ids_from_tracker_server(TrackerServerInfo *pTrackerServer)
|
|||
#define MAX_REQUEST_LOOP 32
|
||||
TrackerHeader *pHeader;
|
||||
ConnectionInfo *conn;
|
||||
char out_buff[sizeof(TrackerHeader) + sizeof(int)];
|
||||
char out_buff[sizeof(TrackerHeader) + sizeof(FDFSFetchStorageIdsBody)];
|
||||
char *p;
|
||||
char *response;
|
||||
struct data_info {
|
||||
|
|
@ -593,7 +592,7 @@ int fdfs_get_storage_ids_from_tracker_server(TrackerServerInfo *pTrackerServer)
|
|||
pHeader = (TrackerHeader *)out_buff;
|
||||
p = out_buff + sizeof(TrackerHeader);
|
||||
pHeader->cmd = TRACKER_PROTO_CMD_STORAGE_FETCH_STORAGE_IDS;
|
||||
long2buff(sizeof(int), pHeader->pkg_len);
|
||||
long2buff(sizeof(FDFSFetchStorageIdsBody), pHeader->pkg_len);
|
||||
|
||||
start_index = 0;
|
||||
list_count = 0;
|
||||
|
|
|
|||
|
|
@ -213,6 +213,13 @@ typedef struct
|
|||
char size[4];
|
||||
} FDFSTrunkInfoBuff;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char start_index[4];
|
||||
char allow_empty;
|
||||
} FDFSFetchStorageIdsBody;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1054,6 +1054,7 @@ static int tracker_deal_get_storage_group_name(struct fast_task_info *pTask)
|
|||
|
||||
static int tracker_deal_fetch_storage_ids(struct fast_task_info *pTask)
|
||||
{
|
||||
FDFSFetchStorageIdsBody *req_body;
|
||||
FDFSStorageIdInfo *pIdsStart;
|
||||
FDFSStorageIdInfo *pIdsEnd;
|
||||
FDFSStorageIdInfo *pIdInfo;
|
||||
|
|
@ -1063,33 +1064,41 @@ static int tracker_deal_fetch_storage_ids(struct fast_task_info *pTask)
|
|||
int start_index;
|
||||
char ip_str[256];
|
||||
|
||||
nPkgLen = pTask->recv.ptr->length - sizeof(TrackerHeader);
|
||||
if (nPkgLen != sizeof(*req_body))
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"cmd=%d, client ip addr: %s, package size %d "
|
||||
"is not correct, expect %d bytes", __LINE__,
|
||||
TRACKER_PROTO_CMD_STORAGE_FETCH_STORAGE_IDS,
|
||||
pTask->client_ip, nPkgLen, (int)sizeof(*req_body));
|
||||
pTask->send.ptr->length = sizeof(TrackerHeader);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
req_body = (FDFSFetchStorageIdsBody *)(pTask->recv.ptr->data +
|
||||
sizeof(TrackerHeader));
|
||||
if (!g_use_storage_id)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"client ip addr: %s, operation not supported", \
|
||||
if (req_body->allow_empty)
|
||||
{
|
||||
pTask->send.ptr->length = sizeof(TrackerHeader) + 8;
|
||||
memset(pTask->send.ptr->data + sizeof(TrackerHeader), 0, 8);
|
||||
return 0;
|
||||
}
|
||||
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"client ip addr: %s, operation not supported",
|
||||
__LINE__, pTask->client_ip);
|
||||
pTask->send.ptr->length = sizeof(TrackerHeader);
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
nPkgLen = pTask->recv.ptr->length - sizeof(TrackerHeader);
|
||||
if (nPkgLen != sizeof(int))
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"cmd=%d, client ip addr: %s, " \
|
||||
"package size %d is not correct, " \
|
||||
"expect %d bytes", __LINE__, \
|
||||
TRACKER_PROTO_CMD_STORAGE_FETCH_STORAGE_IDS, \
|
||||
pTask->client_ip, nPkgLen, (int)sizeof(int));
|
||||
pTask->send.ptr->length = sizeof(TrackerHeader);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
start_index = buff2int(pTask->recv.ptr->data + sizeof(TrackerHeader));
|
||||
start_index = buff2int(req_body->start_index);
|
||||
if (start_index < 0 || start_index >= g_storage_ids_by_id.count)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"client ip addr: %s, invalid offset: %d", \
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"client ip addr: %s, invalid offset: %d",
|
||||
__LINE__, pTask->client_ip, start_index);
|
||||
pTask->send.ptr->length = sizeof(TrackerHeader);
|
||||
return EINVAL;
|
||||
|
|
|
|||
Loading…
Reference in New Issue