From abe7193e7d8b27f7149663595d68ed775e043b3e Mon Sep 17 00:00:00 2001 From: Roman Khlopkov <roman.khlopkov@demlabs.net> Date: Tue, 1 Sep 2020 18:32:19 +0300 Subject: [PATCH] [*] Pipe buffer resize --- dap-sdk/net/core/dap_events_socket.c | 13 ++++++++++++- dap-sdk/net/core/dap_server.c | 1 + modules/channel/chain/dap_stream_ch_chain.c | 5 ++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/dap-sdk/net/core/dap_events_socket.c b/dap-sdk/net/core/dap_events_socket.c index db55e06daa..44d1965580 100644 --- a/dap-sdk/net/core/dap_events_socket.c +++ b/dap-sdk/net/core/dap_events_socket.c @@ -103,7 +103,6 @@ dap_events_socket_t *dap_events_socket_wrap_no_add( dap_events_t *a_events, #if defined(DAP_EVENTS_CAPS_EPOLL) ret->ev_base_flags = EPOLLERR | EPOLLRDHUP | EPOLLHUP; - ret->is_dont_reset_write_flag = true; #endif if ( a_sock!= 0 && a_sock != -1){ @@ -251,6 +250,18 @@ dap_events_socket_t * s_create_type_queue_ptr(dap_worker_t * a_w, dap_events_soc // log_it(L_DEBUG, "Created one-way unnamed packet pipe %d->%d", l_pipe[0], l_pipe[1]); l_es->fd = l_pipe[0]; l_es->fd2 = l_pipe[1]; + const int l_file_buf_size = 64; + FILE* l_sys_max_pipe_size_fd = fopen("/proc/sys/fs/pipe-max-size", "r"); + if (l_sys_max_pipe_size_fd == NULL) { + log_it(L_WARNING, "Сan't resize pipe buffer"); + } + char l_file_buf[l_file_buf_size]; + memset(l_file_buf, 0, l_file_buf_size); + fread(l_file_buf, l_file_buf_size, 1, l_sys_max_pipe_size_fd); + uint64_t l_sys_max_pipe_size = strtoull(l_file_buf, 0, 10); + if (l_sys_max_pipe_size && fcntl(l_pipe[0], F_SETPIPE_SZ, l_sys_max_pipe_size) == l_sys_max_pipe_size) { + log_it(L_DEBUG, "Successfully resized pipe buffer to %lld", l_sys_max_pipe_size); + } #elif defined (DAP_EVENTS_CAPS_QUEUE_POSIX) char l_mq_name[64]; struct mq_attr l_mq_attr ={0}; diff --git a/dap-sdk/net/core/dap_server.c b/dap-sdk/net/core/dap_server.c index 307ca58852..24fe29c0bd 100644 --- a/dap-sdk/net/core/dap_server.c +++ b/dap-sdk/net/core/dap_server.c @@ -257,6 +257,7 @@ dap_events_socket_t * dap_server_events_socket_new(dap_events_t * a_events, int //fcntl(a_sock, F_SETFL, O_NONBLOCK); ret = dap_events_socket_wrap_no_add(a_events, a_sock, a_callbacks); + ret->is_dont_reset_write_flag = true; ret->type = DESCRIPTOR_TYPE_SOCKET; ret->server = a_server; diff --git a/modules/channel/chain/dap_stream_ch_chain.c b/modules/channel/chain/dap_stream_ch_chain.c index 5975958164..afe6ba08d9 100644 --- a/modules/channel/chain/dap_stream_ch_chain.c +++ b/modules/channel/chain/dap_stream_ch_chain.c @@ -494,7 +494,7 @@ void s_stream_ch_packet_in(dap_stream_ch_t* a_ch, void* a_arg) } break; case DAP_STREAM_CH_CHAIN_PKT_TYPE_CHAIN: { - log_it(L_INFO, "In: CHAIN pkt"); + //log_it(L_INFO, "In: CHAIN pkt"); dap_chain_t * l_chain = dap_chain_find_by_id(l_chain_pkt->hdr.net_id, l_chain_pkt->hdr.chain_id); if(l_chain) { // Expect atom element in @@ -572,8 +572,7 @@ void s_stream_ch_packet_in(dap_stream_ch_t* a_ch, void* a_arg) } if(l_ch_chain->callback_notify_packet_in) l_ch_chain->callback_notify_packet_in(l_ch_chain, l_ch_pkt->hdr.type, l_chain_pkt, - l_chain_pkt_data_size, //l_ch_pkt->hdr.size, - l_ch_chain->callback_notify_arg); + l_chain_pkt_data_size, l_ch_chain->callback_notify_arg); } } } -- GitLab