Skip to content

Commit

Permalink
Never iterate starting at -1.
Browse files Browse the repository at this point in the history
If the XML and hash didn't agree, we could never set n = 0 and then
start filling in the array at -1.  This is simplified and we now
treat surgery on the XML separate from in-memory pruning.
  • Loading branch information
postwait committed Oct 21, 2017
1 parent a9153ee commit a44a2a8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/stratcon_jlog_streamer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1258,13 +1258,14 @@ static int
stratcon_remove_noit(const char *target, unsigned short port, const char *cn) {
mtev_hash_iter iter = MTEV_HASH_ITER_ZERO;
const char *key_id;
int klen, n = -1, i, cnt = 0;
int klen, i, cnt = 0;
void *vconn;
mtev_connection_ctx_t **ctx;
mtev_conf_section_t *noit_configs;
char path[256];
char remote_str[256];

if(cn && *cn == '\0') cn = NULL;

snprintf(remote_str, sizeof(remote_str), "%s:%d", target, port);

/* A sweep through the config of all noits with this address,
Expand All @@ -1287,7 +1288,6 @@ stratcon_remove_noit(const char *target, unsigned short port, const char *cn) {
CONF_REMOVE(noit_configs[i]);
xmlUnlinkNode(mtev_conf_section_to_xmlnodeptr(noit_configs[i]));
xmlFreeNode(mtev_conf_section_to_xmlnodeptr(noit_configs[i]));
n = 0;
}
mtev_conf_release_sections(noit_configs, cnt);

Expand All @@ -1303,13 +1303,13 @@ stratcon_remove_noit(const char *target, unsigned short port, const char *cn) {
CONF_REMOVE(noit_configs[i]);
xmlUnlinkNode(mtev_conf_section_to_xmlnodeptr(noit_configs[i]));
xmlFreeNode(mtev_conf_section_to_xmlnodeptr(noit_configs[i]));
n = 0;
}
mtev_conf_release_sections(noit_configs, cnt);
}

int n = 0;
mtev_connection_ctx_t **ctx = malloc(sizeof(*ctx) * mtev_hash_size(&noits));
pthread_mutex_lock(&noits_lock);
ctx = malloc(sizeof(*ctx) * mtev_hash_size(&noits));
while(mtev_hash_next(&noits, &iter, &key_id, &klen,
&vconn)) {
const char *expected_cn;
Expand Down

0 comments on commit a44a2a8

Please sign in to comment.