mirror of
https://github.com/emqx/neuron.git
synced 2026-10-27 12:28:44 +08:00
@@ -44,6 +44,7 @@ cp build/libneuron-base.so ${package_name}/lib
|
||||
cp zlog/src/libzlog.so.1.2 ${package_name}/lib
|
||||
|
||||
cp zlog.conf ${package_name}/config/
|
||||
cp dev.conf ${package_name}/config/
|
||||
cp neuron.key ${package_name}/config/
|
||||
cp neuron.pem ${package_name}/config/
|
||||
|
||||
|
||||
@@ -356,7 +356,7 @@ int modbus_write(neu_plugin_t *plugin, void *req, neu_datatag_t *tag,
|
||||
process_protocol_buf(plugin, response_size);
|
||||
} else {
|
||||
plugin->common.adapter_callbacks->driver.write_response(
|
||||
plugin->common.adapter, req, NEU_ERR_PLUGIN_WRITE_FAILURE);
|
||||
plugin->common.adapter, req, NEU_ERR_PLUGIN_DISCONNECTED);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
size_t req_data_size = 0; \
|
||||
req_type *req = NULL; \
|
||||
\
|
||||
nng_aio_set_timeout(aio, 3000); \
|
||||
nng_aio_defer(aio, http_timeout, NULL); \
|
||||
if (http_get_body((aio), (void **) &req_data, &req_data_size) == 0 && \
|
||||
decode_fun(req_data, &req) == 0) { \
|
||||
{ func }; \
|
||||
|
||||
@@ -395,3 +395,20 @@ int http_internal_error(nng_aio *aio, char *content)
|
||||
{
|
||||
return response(aio, content, NNG_HTTP_STATUS_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
void http_timeout(nng_aio *aio, void *arg, int err)
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
switch (err) {
|
||||
case NNG_ETIMEDOUT:
|
||||
http_internal_error(aio, "{\"error\": \"timeout\"}");
|
||||
break;
|
||||
case NNG_ECANCELED:
|
||||
http_internal_error(aio, "{\"error\": \"canceled\"}");
|
||||
break;
|
||||
default:
|
||||
http_internal_error(aio, "{\"error\": \"unknown\"}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -80,6 +80,7 @@ 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
|
||||
}
|
||||
|
||||
@@ -85,6 +85,8 @@ neu_adapter_t *neu_adapter_create(neu_adapter_info_t *info, bool start)
|
||||
|
||||
rv = nng_pair1_open(&adapter->sock);
|
||||
assert(rv == 0);
|
||||
nng_socket_set_int(adapter->sock, NNG_OPT_RECVBUF, 128);
|
||||
nng_socket_set_int(adapter->sock, NNG_OPT_SENDBUF, 128);
|
||||
nng_socket_set_ms(adapter->sock, NNG_OPT_SENDTIMEO, 1000);
|
||||
nng_socket_get_int(adapter->sock, NNG_OPT_RECVFD, &adapter->recv_fd);
|
||||
|
||||
|
||||
@@ -75,6 +75,8 @@ neu_manager_t *neu_manager_create()
|
||||
rv = nng_listen(manager->socket, url, NULL, 0);
|
||||
assert(rv == 0);
|
||||
|
||||
nng_socket_set_int(manager->socket, NNG_OPT_RECVBUF, 2048);
|
||||
nng_socket_set_int(manager->socket, NNG_OPT_SENDBUF, 2048);
|
||||
nng_socket_get_int(manager->socket, NNG_OPT_RECVFD, ¶m.fd);
|
||||
manager->loop = neu_event_add_io(manager->events, param);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user