fix(http): remove aio timeout

This commit is contained in:
fengzero
2022-08-12 05:44:11 +00:00
parent 2bef69d0ee
commit 79665e140b
4 changed files with 20 additions and 10 deletions
+13 -3
View File
@@ -79,16 +79,16 @@ int modbus_group_timer(neu_plugin_t *plugin, neu_plugin_group_t *group,
} else {
struct modbus_group_data *gd =
(struct modbus_group_data *) group->user_data;
plugin->plugin_group_data = gd;
for (uint16_t i = 0; i < gd->cmd_sort->n_cmd; i++) {
uint16_t response_size = 0;
int ret = modbus_stack_read(
plugin->cmd_idx = i;
int ret = modbus_stack_read(
plugin->stack, gd->cmd_sort->cmd[i].slave_id,
gd->cmd_sort->cmd[i].area, gd->cmd_sort->cmd[i].start_address,
gd->cmd_sort->cmd[i].n_register, &response_size);
if (ret > 0) {
plugin->plugin_group_data = gd;
plugin->cmd_idx = i;
process_protocol_buf(plugin, response_size);
}
}
@@ -106,6 +106,16 @@ int modbus_value_handle(void *ctx, uint8_t slave_id, uint16_t n_byte,
uint16_t start_address = gd->cmd_sort->cmd[plugin->cmd_idx].start_address;
uint16_t n_register = gd->cmd_sort->cmd[plugin->cmd_idx].n_register;
if (bytes == NULL) {
neu_dvalue_t dvalue = { 0 };
dvalue.type = NEU_TYPE_ERROR;
dvalue.value.i32 = NEU_ERR_PLUGIN_DISCONNECTED;
plugin->common.adapter_callbacks->driver.update(
plugin->common.adapter, gd->group, NULL, dvalue);
return 0;
}
utarray_foreach(gd->cmd_sort->cmd[plugin->cmd_idx].tags, modbus_point_t **,
p_tag)
{
+7 -2
View File
@@ -113,6 +113,7 @@ int modbus_stack_read(modbus_stack_t *stack, uint8_t slave_id,
{
static __thread uint8_t buf[32] = { 0 };
static __thread neu_protocol_pack_buf_t pbuf = { 0 };
int ret = 0;
neu_protocol_pack_buf_init(&pbuf, buf, sizeof(buf));
@@ -143,8 +144,12 @@ int modbus_stack_read(modbus_stack_t *stack, uint8_t slave_id,
modbus_header_wrap(&pbuf, stack->seq++);
*response_size += sizeof(struct modbus_header);
return stack->send_fn(stack->ctx, neu_protocol_pack_buf_used_size(&pbuf),
neu_protocol_pack_buf_get(&pbuf));
ret = stack->send_fn(stack->ctx, neu_protocol_pack_buf_used_size(&pbuf),
neu_protocol_pack_buf_get(&pbuf));
if (ret <= 0) {
stack->value_fn(stack->ctx, 0, 0, NULL);
}
return ret;
}
int modbus_stack_write(modbus_stack_t *stack, void *req, uint8_t slave_id,
-4
View File
@@ -45,8 +45,6 @@
#define REST_PROCESS_HTTP_REQUEST_VALIDATE_JWT(aio, req_type, decode_fun, \
func) \
{ \
nng_aio_set_timeout(aio, 3000); \
nng_aio_defer(aio, http_timeout, NULL); \
char *jwt = (char *) http_get_header(aio, (char *) "Authorization"); \
\
NEU_JSON_RESPONSE_ERROR(neu_jwt_validate(jwt), { \
@@ -61,8 +59,6 @@
#define VALIDATE_JWT(aio) \
{ \
nng_aio_set_timeout(aio, 3000); \
nng_aio_defer(aio, http_timeout, NULL); \
char *jwt = (char *) http_get_header(aio, (char *) "Authorization"); \
\
NEU_JSON_RESPONSE_ERROR(neu_jwt_validate(jwt), { \
-1
View File
@@ -80,7 +80,6 @@ int http_unauthorized(nng_aio *aio, char *content);
int http_not_found(nng_aio *aio, char *content);
int http_conflict(nng_aio *aio, char *content);
int http_internal_error(nng_aio *aio, char *content);
void http_timeout(nng_aio *aio, void *arg, int err);
#ifdef __cplusplus
}