Skip to content

Commit

Permalink
Merge branch 'dev' into aes_key_processing_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
shailesh33 authored Mar 14, 2018
2 parents 232e28c + 2e2688f commit 08c10f4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
15 changes: 11 additions & 4 deletions src/proto/dyn_redis.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ static bool
redis_arg0(struct msg *r)
{
switch (r->type) {
case MSG_REQ_REDIS_EXISTS:
case MSG_REQ_REDIS_PERSIST:
case MSG_REQ_REDIS_PTTL:
case MSG_REQ_REDIS_TTL:
Expand Down Expand Up @@ -284,6 +283,7 @@ redis_argx(struct msg *r)
switch (r->type) {
case MSG_REQ_REDIS_MGET:
case MSG_REQ_REDIS_DEL:
case MSG_REQ_REDIS_EXISTS:
return true;

default:
Expand Down Expand Up @@ -2576,7 +2576,8 @@ redis_pre_coalesce(struct msg *rsp)
switch (rsp->type) {
case MSG_RSP_REDIS_INTEGER:
/* only redis 'del' fragmented request sends back integer reply */
ASSERT(req->type == MSG_REQ_REDIS_DEL);
ASSERT((req->type == MSG_REQ_REDIS_DEL) ||
(req->type == MSG_REQ_REDIS_EXISTS));

mbuf = STAILQ_FIRST(&rsp->mhdr);
/*
Expand Down Expand Up @@ -2664,7 +2665,7 @@ redis_post_coalesce_mset(struct msg *request)
}

void
redis_post_coalesce_del(struct msg *request)
redis_post_coalesce_num(struct msg *request)
{
struct msg *response = request->selected_rsp;
rstatus_t status;
Expand Down Expand Up @@ -2738,7 +2739,8 @@ redis_post_coalesce(struct msg *req)
return redis_post_coalesce_mget(req);

case MSG_REQ_REDIS_DEL:
return redis_post_coalesce_del(req);
case MSG_REQ_REDIS_EXISTS:
return redis_post_coalesce_num(req);

case MSG_REQ_REDIS_MSET:
return redis_post_coalesce_mset(req);
Expand Down Expand Up @@ -2950,6 +2952,9 @@ redis_fragment_argx(struct msg *r, struct server_pool *pool, struct rack *rack,
} else if (r->type == MSG_REQ_REDIS_DEL) {
status = msg_prepend_format(sub_msg, "*%d\r\n$3\r\ndel\r\n",
sub_msg->narg + 1);
} else if (r->type == MSG_REQ_REDIS_EXISTS) {
status = msg_prepend_format(sub_msg, "*%d\r\n$6\r\nexists\r\n",
sub_msg->narg + 1);
} else if (r->type == MSG_REQ_REDIS_MSET) {
status = msg_prepend_format(sub_msg, "*%d\r\n$4\r\nmset\r\n",
sub_msg->narg + 1);
Expand Down Expand Up @@ -2984,6 +2989,7 @@ redis_fragment(struct msg *r, struct server_pool *pool, struct rack *rack, struc
switch (r->type) {
case MSG_REQ_REDIS_MGET:
case MSG_REQ_REDIS_DEL:
case MSG_REQ_REDIS_EXISTS:
return redis_fragment_argx(r, pool, rack, frag_msgq, 1);

case MSG_REQ_REDIS_MSET:
Expand Down Expand Up @@ -3026,6 +3032,7 @@ redis_is_multikey_request(struct msg *req)
switch (req->type) {
case MSG_REQ_REDIS_MGET:
case MSG_REQ_REDIS_DEL:
case MSG_REQ_REDIS_EXISTS:
case MSG_REQ_REDIS_MSET:
return true;
default:
Expand Down
29 changes: 17 additions & 12 deletions src/seedsprovider/dyn_dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
#define DNS_TXT_NAME "_dynomite.ec2-internal"
#endif

static char * txtName = NULL;
static char * dnsName = NULL;
static char * dnsType = NULL;
static int queryType = T_TXT;
static int64_t last = 0; //storing last time for seeds check
static uint32_t last_seeds_hash = 0;

Expand Down Expand Up @@ -74,52 +76,55 @@ dns_get_seeds(struct context * ctx, struct mbuf *seeds_buf)

if (!_env_checked) {
_env_checked = 1;
txtName = getenv("DYNOMITE_DNS_TXT_NAME");
if (txtName == NULL) txtName = DNS_TXT_NAME;
dnsName = getenv("DYNOMITE_DNS_NAME");
if (dnsName == NULL) dnsName = DNS_TXT_NAME;
dnsType = getenv("DYNOMITE_DNS_TYPE");
if (dnsType != NULL) { if (strcmp(dnsType, "A") == 0) queryType = T_A; }
}

log_debug(LOG_VVERB, "checking for %s", txtName);
log_debug(LOG_VVERB, "checking for %s", dnsName);

if (!seeds_check()) {
return DN_NOOPS;
}

unsigned char buf[BUFSIZ];
int r = res_query(txtName, C_IN, T_TXT, buf, sizeof(buf));

int r = res_query(dnsName, C_IN, queryType, buf, sizeof(buf));
if (r == -1) {
log_debug(LOG_DEBUG, "DNS response for %s: %s", txtName, hstrerror(h_errno));
log_debug(LOG_DEBUG, "DNS response for %s: %s", dnsName, hstrerror(h_errno));
return DN_NOOPS;
}
if (r >= sizeof(buf)) {
log_debug(LOG_DEBUG, "DNS reply is too large for %s: %d, bufsize: %d", txtName, r, sizeof(buf));
log_debug(LOG_DEBUG, "DNS reply is too large for %s: %d, bufsize: %d", dnsName, r, sizeof(buf));
return DN_NOOPS;
}
HEADER *hdr = (HEADER*)buf;
if (hdr->rcode != NOERROR) {
log_debug(LOG_DEBUG, "DNS reply code for %s: %d", txtName, hdr->rcode);
log_debug(LOG_DEBUG, "DNS reply code for %s: %d", dnsName, hdr->rcode);
return DN_NOOPS;
}
int na = ntohs(hdr->ancount);

ns_msg m;
if (ns_initparse(buf, r, &m) == -1) {
log_debug(LOG_DEBUG, "ns_initparse error for %s: %s", txtName, strerror(errno));
log_debug(LOG_DEBUG, "ns_initparse error for %s: %s", dnsName, strerror(errno));
return DN_NOOPS;
}
int i;
ns_rr rr;
for (i = 0; i < na; ++i) {
if (ns_parserr(&m, ns_s_an, i, &rr) == -1) {
log_debug(LOG_DEBUG, "ns_parserr for %s: %s", txtName, strerror (errno));
log_debug(LOG_DEBUG, "ns_parserr for %s: %s", dnsName, strerror (errno));
return DN_NOOPS;
}
mbuf_rewind(seeds_buf);
unsigned char *s = ns_rr_rdata(rr);
if (s[0] >= ns_rr_rdlen(rr)) {
log_debug(LOG_DEBUG, "invalid TXT length for %s: %d < %d", txtName, s[0], ns_rr_rdlen(rr));
log_debug(LOG_DEBUG, "invalid length for %s: %d < %d", dnsName, s[0], ns_rr_rdlen(rr));
return DN_NOOPS;
}
log_debug(LOG_VERB, "seeds for %s: %.*s", txtName, s[0], s +1);
log_debug(LOG_VERB, "seeds for %s: %.*s", dnsName, s[0], s +1);
mbuf_copy(seeds_buf, s + 1, s[0]);
}

Expand Down

0 comments on commit 08c10f4

Please sign in to comment.