Permalink
Browse files

Upped max segments handled by protocol to 65536.

Max segments is 256 by default, but could feasibly be upped.
  • Loading branch information...
1 parent 58baa4e commit a696bfdc17412030107c1ab28afc10363960f1f3 @davechallis committed Nov 3, 2011
Showing with 47 additions and 25 deletions.
  1. +16 −0 src/admin/admin.c
  2. +6 −5 src/admin/admin_backend.c
  3. +4 −4 src/admin/admin_common.h
  4. +21 −16 src/admin/admin_protocol.c
View
16 src/admin/admin.c
@@ -662,7 +662,15 @@ static int start_or_stop_stores(int action)
case ADM_ERR_KB_STATUS_STOPPED:
print_colour("stopped", ANSI_COLOUR_GREEN);
break;
+ case ADM_ERR_KB_STATUS_UNKNOWN:
+ print_colour("unknown", ANSI_COLOUR_RED);
+ break;
default:
+ fsa_error(
+ LOG_CRIT,
+ "Unknown server response: %d",
+ kbr->return_val
+ );
print_colour("unknown", ANSI_COLOUR_RED);
break;
}
@@ -678,7 +686,15 @@ static int start_or_stop_stores(int action)
case ADM_ERR_KB_STATUS_STOPPED:
print_colour("stopped", ANSI_COLOUR_YELLOW);
break;
+ case ADM_ERR_KB_STATUS_UNKNOWN:
+ print_colour("unknown", ANSI_COLOUR_RED);
+ break;
default:
+ fsa_error(
+ LOG_CRIT,
+ "Unknown server response: %d",
+ kbr->return_val
+ );
print_colour("unknown", ANSI_COLOUR_RED);
break;
}
View
11 src/admin/admin_backend.c
@@ -176,18 +176,19 @@ int fsab_kb_info_init(fsa_kb_info *ki, const unsigned char *kb_name, int *err)
md = fs_metadata_open((char *)kb_name);
if (md != NULL) {
ki->num_segments =
- atoi(fs_metadata_get_string(md, FS_MD_SEGMENTS, "0"));
+ (uint16_t)atoi(fs_metadata_get_string(md, FS_MD_SEGMENTS, "0"));
fs_rid_vector *vec = fs_metadata_get_int_vector(md, FS_MD_SEGMENT_P);
fs_rid_vector_sort(vec);
- /* segment ID and max segments should be 256 */
- ki->p_segments_len = (uint8_t)vec->length;
+ /* segment ID and max segments should be 256, but allow 65536
+ to allow for value to be upped in #define */
+ ki->p_segments_len = (uint16_t)vec->length;
ki->p_segments_data =
- (uint8_t *)malloc(ki->p_segments_len * sizeof(uint8_t));
+ (uint16_t *)malloc(ki->p_segments_len * sizeof(uint16_t));
for (int i = 0; i < vec->length; i++) {
- ki->p_segments_data[i] = (uint8_t)vec->data[i];
+ ki->p_segments_data[i] = (uint16_t)vec->data[i];
}
fs_rid_vector_free(vec);
View
8 src/admin/admin_common.h
@@ -10,7 +10,7 @@
*/
/* Protocol headers */
-#define ADM_PROTO_VERS 0x1
+#define ADM_PROTO_VERS 0x2
#define ADM_H_LEN 2
#define ADM_H_VERS_LEN 1
#define ADM_H_CMD_LEN 1
@@ -97,9 +97,9 @@ typedef struct _fsa_kb_info {
uint32_t pid;
uint16_t port;
uint8_t status;
- uint8_t num_segments;
- uint8_t p_segments_len;
- uint8_t *p_segments_data;
+ uint16_t num_segments;
+ uint16_t p_segments_len;
+ uint16_t *p_segments_data;
struct _fsa_kb_info *next;
} fsa_kb_info;
View
37 src/admin/admin_protocol.c
@@ -390,15 +390,16 @@ fsa_kb_info *fsap_decode_rsp_get_kb_info_all(const unsigned char *buf)
memcpy(&(ki->status), p, 1);
p += 1;
- memcpy(&(ki->num_segments), p, 1);
- p += 1;
+ memcpy(&(ki->num_segments), p, sizeof(uint16_t));
+ p += sizeof(uint16_t);
- memcpy(&(ki->p_segments_len), p, 1);
- p += 1;
+ memcpy(&(ki->p_segments_len), p, sizeof(uint16_t));
+ p += sizeof(uint16_t);
- ki->p_segments_data = (uint8_t *)malloc(ki->p_segments_len);
- memcpy(ki->p_segments_data, p, ki->p_segments_len);
- p += ki->p_segments_len;
+ ki->p_segments_data =
+ (uint16_t *)malloc(ki->p_segments_len * sizeof(uint16_t));
+ memcpy(ki->p_segments_data, p, ki->p_segments_len * sizeof(uint16_t));
+ p += (ki->p_segments_len * sizeof(uint16_t));
ki->next = first_ki;
first_ki = ki;
@@ -455,15 +456,15 @@ unsigned char *fsap_encode_rsp_get_kb_info_all(const fsa_kb_info *ki, int *len)
uint8_t name_len;
/* name_len name pid port status num_segments p_segments_len segments
- * 1 * 4 2 1 1 1 * */
- int base_entry_size = 10;
+ * 1 * 4 2 1 2 2 * */
+ int base_entry_size = 12;
/* loop through once to find size and number of entries */
for (cur_ki = ki; cur_ki != NULL; cur_ki = cur_ki->next) {
n_entries += 1;
data_len += base_entry_size;
data_len += strlen((char *)cur_ki->name);
- data_len += cur_ki->p_segments_len * sizeof(uint8_t);
+ data_len += cur_ki->p_segments_len * sizeof(uint16_t);
}
/* create and fill buffer */
@@ -492,14 +493,18 @@ unsigned char *fsap_encode_rsp_get_kb_info_all(const fsa_kb_info *ki, int *len)
memcpy(p, &(cur_ki->status), 1);
p += 1;
- memcpy(p, &(cur_ki->num_segments), 1);
- p += 1;
+ memcpy(p, &(cur_ki->num_segments), sizeof(uint16_t));
+ p += sizeof(uint16_t);
- memcpy(p, &(cur_ki->p_segments_len), 1);
- p += 1;
+ memcpy(p, &(cur_ki->p_segments_len), sizeof(uint16_t));
+ p += sizeof(uint16_t);
- memcpy(p, cur_ki->p_segments_data, cur_ki->p_segments_len);
- p += cur_ki->p_segments_len;
+ memcpy(
+ p,
+ cur_ki->p_segments_data,
+ cur_ki->p_segments_len * sizeof(uint16_t)
+ );
+ p += (cur_ki->p_segments_len * sizeof(uint16_t));
}
*len = data_len + ADM_HEADER_LEN;

0 comments on commit a696bfd

Please sign in to comment.