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