Merge pull request #534 from fengzeroz/main

fix connection: serial device & compile warning
This commit is contained in:
fengzeroz
2022-06-14 13:48:41 +08:00
committed by GitHub
4 changed files with 11 additions and 23 deletions
+1 -12
View File
@@ -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
+5 -1
View File
@@ -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;
+2 -2
View File
@@ -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);
+3 -8
View File
@@ -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));