Skip to content
This repository has been archived by the owner on Dec 26, 2022. It is now read-only.

Commit

Permalink
fix: Fix wrongly define MQTT_ENABLE in accelerator
Browse files Browse the repository at this point in the history
We wrongly define `MQTT_ENABLE` in rule `accelerator`
which causes the whole program crashed.
  • Loading branch information
howjmay committed Dec 31, 2019
1 parent 858e09b commit 6375793
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
18 changes: 13 additions & 5 deletions accelerator/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,30 @@ load("@io_bazel_rules_docker//container:container.bzl", "container_push")

cc_binary(
name = "accelerator",
srcs = [
"config.c",
"config.h",
] + select({
srcs = select({
"//connectivity/mqtt:mqtt_enable": [
"conn_mqtt.c",
],
"//conditions:default": ["main.c"],
}),
copts = [
"-DLOGGER_ENABLE",
"-DMQTT_ENABLE",
] + select({
":DEBUG_MODE": ["-g"],
":PROFILING_MODE": [
"-DNDEBUG",
"-pg",
],
"//conditions:default": ["-DNDEBUG"],
}) + select({
"//connectivity/mqtt:mqtt_enable": [
"-DMQTT_ENABLE",
],
"//conditions:default": [],
}),
deps = [
":ta_errors",
":ta_config",
":http",
"@entangled//utils/handles:signal",
":apis",
Expand Down Expand Up @@ -144,6 +146,12 @@ cc_library(
name = "ta_config",
srcs = ["config.c"],
hdrs = ["config.h"],
copts = select({
"//connectivity/mqtt:mqtt_enable": [
"-DMQTT_ENABLE",
],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
deps = [
":message",
Expand Down
2 changes: 1 addition & 1 deletion accelerator/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ status_t ta_core_default_init(ta_config_t* const ta_conf, iota_config_t* const i
ta_conf->port = TA_PORT;
ta_conf->thread_count = TA_THREAD_COUNT;
ta_conf->proxy_passthrough = false;
#ifdef ENABLE_MQTT
#ifdef MQTT_ENABLE
ta_conf->mqtt_host = MQTT_HOST;
ta_conf->mqtt_topic_root = TOPIC_ROOT;
#endif
Expand Down
4 changes: 2 additions & 2 deletions accelerator/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extern "C" {
#define TA_VERSION "tangle-accelerator/0.5.0"
#define TA_HOST "localhost"

#ifdef MQTT_ENABLE
#ifdef MQTT_ENABLE
#define MQTT_HOST "localhost"
#define TOPIC_ROOT "root/topics"
#endif
Expand Down Expand Up @@ -63,7 +63,7 @@ typedef struct ta_config_s {
char* host; /**< Binding address of tangle-accelerator */
char* port; /**< Binding port of tangle-accelerator */
uint8_t thread_count; /**< Thread count of tangle-accelerator instance */
#ifdef MQTT_ENABLE
#ifdef MQTT_ENABLE
char* mqtt_host; /**< Address of MQTT broker host */
char* mqtt_topic_root; /**< The topic root of MQTT topic */
#endif
Expand Down
2 changes: 1 addition & 1 deletion accelerator/conn_mqtt.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "accelerator/config.h"
#include "config.h"
#include "connectivity/mqtt/mqtt_common.h"
#include "connectivity/mqtt/duplex_callback.h"
#include "connectivity/mqtt/duplex_utils.h"
#include "connectivity/mqtt/mqtt_common.h"
#include "errors.h"

#define CONN_MQTT_LOGGER "conn-mqtt"
Expand Down

0 comments on commit 6375793

Please sign in to comment.