diff --git a/src/agent_map.c b/src/agent_map.c
index 1a00c4d917db9b53d7f30830ce3fa02ef08de7b0..46a1022c304882d9f40149e92577626d88f1aa02 100644
--- a/src/agent_map.c
+++ b/src/agent_map.c
@@ -4529,7 +4529,9 @@ int handle_hld_message(void *agent, struct cmdu_buff *rx_cmdu)
 	struct tlv *t;
 	uint8_t proto;
 	uint8_t *data;
+#ifdef AGENT_SYNC_DYNAMIC_CNTLR_CONFIG
 	bool cntlr_sync = (a->cfg.dyn_cntlr_sync & is_local_cntlr_available());
+#endif
 	int data_len;
 	int tlen = 0;
 	int ret;
@@ -4583,6 +4585,7 @@ int handle_hld_message(void *agent, struct cmdu_buff *rx_cmdu)
 	if (ret == 0)
 		send_1905_acknowledge(a, rx_cmdu->origin, cmdu_get_mid(rx_cmdu), NULL, 0);
 
+#ifdef AGENT_SYNC_DYNAMIC_CNTLR_CONFIG
 	if (proto == 0xab && cntlr_sync) {
 		struct cmdu_buff *cmdu;
 		uint8_t res_proto = 0xac;
@@ -4642,6 +4645,7 @@ int handle_hld_message(void *agent, struct cmdu_buff *rx_cmdu)
 		if (ret)
 			fprintf(stderr, "failed to write file\n");
 	}
+#endif /* AGENT_SYNC_DYNAMIC_CNTLR_CONFIG */
 
 	return ret;
 }