From f60c522f7dcb78f35beed23bd7af05355a558c5e Mon Sep 17 00:00:00 2001 From: marktwtn Date: Fri, 6 Sep 2019 17:44:05 +0800 Subject: [PATCH] fix: Release remote interface resource correctly Release resource correctly when unexpected things happen such as the RabbitMQ broker is turned off accidentally. --- src/dcurl.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/dcurl.c b/src/dcurl.c index cb54bec..fae5388 100644 --- a/src/dcurl.c +++ b/src/dcurl.c @@ -126,6 +126,14 @@ int8_t *dcurl_entry(int8_t *trytes, int mwm, int threads) remote_pow: if (!doRemoteContext(&Remote_Context, pow_ctx)) { + /* The remote interface can not work without activated RabbitMQ broker + * and remote worker. If it is not working, the PoW would be calculated + * by the local machine. And the remote interface resource should be + * released. + */ + freeRemoteContext(&Remote_Context, pow_ctx); + exitRemoteContext(&Remote_Context); + uv_sem_post(¬ify_remote); goto local_pow; } else { res = getRemoteResult(&Remote_Context, pow_ctx);