From 08f7f39836d00ecdbae18c51ddc3739015a4e9c1 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 22 Sep 2014 21:56:42 +1000 Subject: [PATCH] Do not accept proxy notify update until subscription complete --- src/stratifier.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/stratifier.c b/src/stratifier.c index d68bbdac..0a2c2d34 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -155,6 +155,8 @@ static struct { int nonce2len; int enonce2varlen; + + bool subscribed; } proxy_base; static int64_t workbase_id; @@ -760,6 +762,7 @@ static bool update_subscribe(ckpool_t *ckp) free(buf); ck_wlock(&workbase_lock); + proxy_base.subscribed = true; proxy_base.diff = ckp->startdiff; /* Length is checked by generator */ strcpy(proxy_base.enonce1, json_string_value(json_object_get(val, "enonce1"))); @@ -794,6 +797,11 @@ static void update_notify(ckpool_t *ckp) return; } + if (unlikely(!proxy_base.subscribed)) { + LOGINFO("No valid proxy subscription to update notify yet"); + return; + } + LOGDEBUG("Update notify: %s", buf); wb = ckzalloc(sizeof(workbase_t)); val = json_loads(buf, 0, NULL);