diff --git a/CMakeLists.txt b/CMakeLists.txt index 4bf1b9b3ee20b3c7e00cd82918a66b5789daba47..19e2c130306ae548d032f46b1328548649a9c8b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ project(cellframe-sdk C) cmake_minimum_required(VERSION 2.8) set(CMAKE_C_STANDARD 11) -set(CELLFRAME_SDK_NATIVE_VERSION "2.5-8") +set(CELLFRAME_SDK_NATIVE_VERSION "2.5-9") add_definitions ("-DCELLFRAME_SDK_VERSION=\"${CELLFRAME_SDK_NATIVE_VERSION}\"") set(DAPSDK_MODULES "") diff --git a/dap-sdk/net/core/dap_server.c b/dap-sdk/net/core/dap_server.c index 24fe29c0bdddaf5c90dad19c2710cc02225b9c29..41fe2385da5885f18bcb4d67dfc727e84b1bfe5d 100644 --- a/dap-sdk/net/core/dap_server.c +++ b/dap-sdk/net/core/dap_server.c @@ -58,10 +58,12 @@ #define LOG_TAG "dap_server" +static dap_events_socket_t * s_es_server_create(dap_events_t * a_events, int a_sock, + dap_events_socket_callbacks_t * a_callbacks, dap_server_t * a_server); + static void s_es_server_accept(dap_events_socket_t *a_es, int a_remote_socket, struct sockaddr* a_remote_addr); static void s_es_server_error(dap_events_socket_t *a_es, int a_arg); static void s_es_server_new(dap_events_socket_t *a_es, void * a_arg); - static void s_server_delete(dap_server_t * a_server); /** * @brief dap_server_init @@ -148,7 +150,7 @@ dap_server_t* dap_server_new(dap_events_t *a_events, const char * a_addr, uint16 listen(l_server->socket_listener, SOMAXCONN); } - fcntl( l_server->socket_listener, F_SETFL, O_NONBLOCK); + //fcntl( l_server->socket_listener, F_SETFL, O_NONBLOCK); pthread_mutex_init(&l_server->started_mutex,NULL); pthread_cond_init(&l_server->started_cond,NULL); @@ -229,7 +231,7 @@ static void s_es_server_accept(dap_events_socket_t *a_es, int a_remote_socket, s dap_events_socket_t * l_es_new = NULL; log_it(L_DEBUG, "Listening socket (binded on %s:%u) got new incomming connection",l_server->address,l_server->port); log_it(L_DEBUG, "Accepted new connection (sock %d from %d)", a_remote_socket, a_es->socket); - l_es_new = dap_server_events_socket_new(a_es->events,a_remote_socket,&l_server->client_callbacks,l_server); + l_es_new = s_es_server_create(a_es->events,a_remote_socket,&l_server->client_callbacks,l_server); //l_es_new->is_dont_reset_write_flag = true; // By default all income connection has this flag getnameinfo(a_remote_addr,a_remote_addr_size, l_es_new->hostaddr , sizeof(l_es_new->hostaddr),l_es_new->service,sizeof(l_es_new->service), @@ -241,14 +243,14 @@ static void s_es_server_accept(dap_events_socket_t *a_es, int a_remote_socket, s /** - * @brief dap_server_events_socket_new + * @brief s_esocket_new * @param a_events * @param a_sock * @param a_callbacks * @param a_server * @return */ -dap_events_socket_t * dap_server_events_socket_new(dap_events_t * a_events, int a_sock, +static dap_events_socket_t * s_es_server_create(dap_events_t * a_events, int a_sock, dap_events_socket_callbacks_t * a_callbacks, dap_server_t * a_server) { dap_events_socket_t * ret = NULL; diff --git a/dap-sdk/net/core/include/dap_events_socket.h b/dap-sdk/net/core/include/dap_events_socket.h index cf9a008d8ddb22e9120b3d5ffbd8c58790647423..81bf6a0098557b55c6d8db40b8fda629ea7aadb4 100644 --- a/dap-sdk/net/core/include/dap_events_socket.h +++ b/dap-sdk/net/core/include/dap_events_socket.h @@ -91,12 +91,9 @@ typedef struct dap_events_socket_callbacks { union{ dap_events_socket_callback_accept_t accept_callback; // Accept callback for listening socket dap_events_socket_callback_timer_t timer_callback; // Timer callback for listening socket - dap_events_socket_callback_event_t event_callback; // Timer callback for listening socket - dap_events_socket_callback_queue_t queue_callback; // Timer callback for listening socket - dap_events_socket_callback_queue_ptr_t queue_ptr_callback; // Timer callback for listening socket - dap_events_socket_callback_t action_callback; // Callback for action with socket - // for events and timers thats pointer - // to processing callback + dap_events_socket_callback_event_t event_callback; // Event callback for listening socket + dap_events_socket_callback_queue_t queue_callback; // Queue callback for listening socket + dap_events_socket_callback_queue_ptr_t queue_ptr_callback; // queue_ptr callback for listening socket }; dap_events_socket_callback_t new_callback; // Create new client callback dap_events_socket_callback_t delete_callback; // Delete client callback diff --git a/dap-sdk/net/core/include/dap_server.h b/dap-sdk/net/core/include/dap_server.h index f22ea6469649aee0a9c87b6bcdae95f046dbd986..44bf62135e5756e0d1c05fb1f62937e4d0b1ccc8 100644 --- a/dap-sdk/net/core/include/dap_server.h +++ b/dap-sdk/net/core/include/dap_server.h @@ -86,5 +86,3 @@ int dap_server_init( ); // Init server module void dap_server_deinit( void ); // Deinit server module dap_server_t* dap_server_new(dap_events_t *a_events, const char * a_addr, uint16_t a_port, dap_server_type_t a_type); -dap_events_socket_t * dap_server_events_socket_new(dap_events_t * a_events, int a_sock, - dap_events_socket_callbacks_t * a_callbacks, dap_server_t * a_server); diff --git a/dap-sdk/net/core/include/dap_worker.h b/dap-sdk/net/core/include/dap_worker.h index cb08c3dbeb7809682db4f1c6f7487054b2b466b2..eb02022f633a4162e63536a2349091a553857e28 100644 --- a/dap-sdk/net/core/include/dap_worker.h +++ b/dap-sdk/net/core/include/dap_worker.h @@ -31,8 +31,8 @@ typedef struct dap_worker { uint32_t id; - dap_events_t *events; - dap_proc_queue_t * proc_queue; + dap_events_t* events; + dap_proc_queue_t* proc_queue; atomic_uint event_sockets_count; dap_events_socket_t *esockets; // Hashmap of event sockets @@ -45,8 +45,9 @@ typedef struct dap_worker dap_events_socket_t * queue_callback; // Queue for pure callback on worker dap_timerfd_t * timer_check_activity; +#ifdef DAP_EVENTS_CAPS_EPOLL EPOLL_HANDLE epoll_fd; - +#endif pthread_cond_t started_cond; pthread_mutex_t started_mutex; void * _inheritor; diff --git a/modules/service/vpn/dap_chain_net_srv_vpn.c b/modules/service/vpn/dap_chain_net_srv_vpn.c index 9aa788be20a73a1becd07766ae8abb8a961a42f0..92b9e016820f90a50216dbd7c66f9271d1797bd0 100644 --- a/modules/service/vpn/dap_chain_net_srv_vpn.c +++ b/modules/service/vpn/dap_chain_net_srv_vpn.c @@ -572,7 +572,7 @@ int s_vpn_tun_create(dap_config_t * g_config) dap_worker_t * l_worker = dap_events_worker_get(i); assert( l_worker ); int l_tun_fd; - if( (l_tun_fd = open("/dev/net/tun", O_RDWR| O_NONBLOCK)) < 0 ) { + if( (l_tun_fd = open("/dev/net/tun", O_RDWR)) < 0 ) { log_it(L_ERROR,"Opening /dev/net/tun error: '%s'", strerror(errno)); err = -100; break;