diff --git a/src/adapter/adapter.c b/src/adapter/adapter.c index 507d5236..94c6775c 100644 --- a/src/adapter/adapter.c +++ b/src/adapter/adapter.c @@ -469,8 +469,6 @@ static int adapter_command(neu_adapter_t *adapter, neu_reqresp_head_t header, static int adapter_response(neu_adapter_t *adapter, neu_reqresp_head_t *header, void *data) { - int ret = 0; - switch (header->type) { case NEU_REQRESP_TRANS_DATA: strcpy(header->sender, adapter->name); @@ -482,16 +480,7 @@ static int adapter_response(neu_adapter_t *adapter, neu_reqresp_head_t *header, nng_msg *msg = neu_msg_gen(header, data); - ret = nng_sendmsg(adapter->nng.sock, msg, 0); - // ret = nng_sendmsg(adapter->nng.sock, msg, NNG_FLAG_NONBLOCK); - // if (ret == NNG_EAGAIN) { - //} - if (ret != 0) { - nlog_warn("sendmsg error: %d", ret); - nng_msg_free(msg); - } - - return ret; + return nng_sendmsg(adapter->nng.sock, msg, 0); } // clang-format off diff --git a/src/connection/connection.c b/src/connection/connection.c index 6cf8e404..27e1c89b 100644 --- a/src/connection/connection.c +++ b/src/connection/connection.c @@ -367,6 +367,10 @@ void neu_conn_flush(neu_conn_t *conn) void neu_conn_disconnect(neu_conn_t *conn) { conn_disconnect(conn); + if (conn->callback_trigger == true) { + conn->disconnected(conn->data, conn->fd); + conn->callback_trigger = false; + } } static void conn_free_param(neu_conn_t *conn) @@ -610,7 +614,7 @@ static void conn_connect(neu_conn_t *conn) case NEU_CONN_TTY_CLIENT: { struct termios tty_opt = { 0 }; - fd = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY, 0); + fd = open(conn->param.params.tty_client.device, O_RDWR | O_NOCTTY, 0); tty_opt.c_cc[VTIME] = conn->param.params.tty_client.timeout / 100; tty_opt.c_cc[VMIN] = 0; diff --git a/tests/http_test.cc b/tests/http_test.cc index 2c757beb..d8170fd0 100644 --- a/tests/http_test.cc +++ b/tests/http_test.cc @@ -58,7 +58,7 @@ TEST(HTTPTest, http_get_param) nng_url_parse(&url, "http://127.0.0.1"); nng_http_req_alloc(&req, url); - for (int i = 0; i < sizeof(data) / sizeof(query_param_data_t); ++i) { + for (uint64_t i = 0; i < sizeof(data) / sizeof(query_param_data_t); ++i) { nng_http_req_set_uri(req, (char *) data[i].uri); nng_aio_set_input(aio, 0, req); len = 0; @@ -135,7 +135,7 @@ TEST(HTTPTest, http_get_param_node_id) nng_url_parse(&url, "http://127.0.0.1"); nng_http_req_alloc(&req, url); - for (int i = 0; i < sizeof(data) / sizeof(query_node_id_data_t); ++i) { + for (uint64_t i = 0; i < sizeof(data) / sizeof(query_node_id_data_t); ++i) { neu_node_id_t prev_node_id = node_id; nng_http_req_set_uri(req, (char *) data[i].uri); nng_aio_set_input(aio, 0, req); diff --git a/tests/jwt_test.cc b/tests/jwt_test.cc index d451e84f..da4e1c13 100644 --- a/tests/jwt_test.cc +++ b/tests/jwt_test.cc @@ -10,9 +10,7 @@ zlog_category_t *neuron = NULL; TEST(JwtTest, SetJwt) { - char * token = NULL; - unsigned char public_key[4096] = { 0 }; - size_t pub_key_len = 0; + char *token = NULL; EXPECT_EQ(0, neu_jwt_init((char *) "./config")); @@ -24,11 +22,8 @@ TEST(JwtTest, SetJwt) TEST(JwtTest, JwtValidate) { - char * token = NULL; - char b_token[1024] = { 0 }; - unsigned char public_key[4096] = { 0 }; - size_t pub_key_len = 0; - struct timeval expire_tv = { 0 }; + char *token = NULL; + char b_token[1024] = { 0 }; EXPECT_EQ(0, neu_jwt_init((char *) "./config")); EXPECT_EQ(0, neu_jwt_new(&token));