Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dap-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
4
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dap
dap-sdk
Commits
9b5420ed
Commit
9b5420ed
authored
1 year ago
by
Roman Khlopkov
🔜
Browse files
Options
Downloads
Patches
Plain Diff
[*] Proc threads involved on CLI command execution
parent
5410384d
No related branches found
No related tags found
No related merge requests found
Pipeline
#32955
passed with stage
Stage: build
in 17 minutes and 28 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
net/server/cli_server/dap_cli_server.c
+7
-38
7 additions, 38 deletions
net/server/cli_server/dap_cli_server.c
with
7 additions
and
38 deletions
net/server/cli_server/dap_cli_server.c
+
7
−
38
View file @
9b5420ed
...
...
@@ -23,46 +23,20 @@
along with any Cellframe SDK based project. If not, see <http://www.gnu.org/licenses/>.
*/
#include
<sys/stat.h>
#include
<stdio.h>
#include
<string.h>
#include
<errno.h>
#include
<assert.h>
//#include <glib.h>
#include
<unistd.h>
#ifndef _WIN32
#include
<poll.h>
#include
<sys/socket.h>
#include
<sys/types.h>
#include
<arpa/inet.h>
//#include <unistd.h> // for close
#include
<fcntl.h>
//#include <sys/poll.h>
//#include <sys/select.h>
#include
<netinet/in.h>
#include
<sys/un.h>
#include
<sys/stat.h>
//#define closesocket close
//typedef int SOCKET;
//#define SOCKET_ERROR -1 // for win32 = (-1)
//#define INVALID_SOCKET -1 // for win32 = (SOCKET)(~0)
// for Windows
#else
#include
<winsock2.h>
#include
<windows.h>
#include
<mswsock.h>
#include
<ws2tcpip.h>
#include
<io.h>
#endif
#include
<pthread.h>
#include
"dap_common.h"
#include
"dap_strfuncs.h"
#include
"dap_file_utils.h"
#include
"dap_list.h"
#include
"dap_net.h"
#include
"dap_cli_server.h"
#include
"dap_proc_thread.h"
#define LOG_TAG "dap_cli_server"
...
...
@@ -79,8 +53,6 @@ static bool s_debug_cli = false;
static
dap_cli_cmd_t
*
s_commands
=
NULL
;
static
dap_cli_cmd_aliases_t
*
s_command_alias
=
NULL
;
static
void
*
s_thread_one_client_func
(
void
*
args
);
static
void
*
s_thread_main_func
(
void
*
args
);
static
inline
void
s_cmd_add_ex
(
const
char
*
a_name
,
dap_cli_server_cmd_callback_ex_t
a_func
,
void
*
a_arg_func
,
const
char
*
a_doc
,
const
char
*
a_doc_ex
);
...
...
@@ -726,9 +698,9 @@ char* s_get_next_str( SOCKET nSocket, int *dwLen, const char *stop_str, bool del
/**
* threading function for processing a request from a client
*/
static
void
*
s_thread_one_client_func
(
void
*
arg
s
)
static
bool
s_thread_one_client_func
(
dap_proc_thread_t
UNUSED_ARG
*
a_thread
,
void
*
arg
)
{
SOCKET
newsockfd
=
(
SOCKET
)
(
intptr_t
)
arg
s
;
SOCKET
newsockfd
=
(
SOCKET
)
(
intptr_t
)
arg
;
int
str_len
,
marker
=
0
,
timeout
=
5000
,
argc
=
0
,
is_data
;
dap_list_t
*
cmd_param_list
=
NULL
;
char
*
str_header
;
...
...
@@ -857,7 +829,7 @@ char *str_header;
if
(
s_debug_cli
)
log_it
(
L_DEBUG
,
"close connection=%d sockfd=%"
DAP_FORMAT_SOCKET
,
cs
,
newsockfd
);
return
NULL
;
return
false
;
}
/**
...
...
@@ -875,7 +847,6 @@ static void* s_thread_main_func(void *args)
// wait of clients
while
(
1
)
{
pthread_t
threadId
;
struct
sockaddr_in
peer
;
socklen_t
size
=
sizeof
(
peer
);
// received a new connection request
...
...
@@ -883,10 +854,8 @@ static void* s_thread_main_func(void *args)
log_it
(
L_ERROR
,
"new connection break newsockfd=%"
DAP_FORMAT_SOCKET
,
newsockfd
);
break
;
}
// create child thread for a client connection
pthread_create
(
&
threadId
,
NULL
,
s_thread_one_client_func
,
(
void
*
)
(
intptr_t
)
newsockfd
);
// in order to thread not remain in state "dead" after completion
pthread_detach
(
threadId
);
// Serve client connection on automatically chosen processing thread
dap_proc_thread_callback_add
(
NULL
,
s_thread_one_client_func
,
DAP_INT_TO_POINTER
(
newsockfd
));
};
// close connection
int
cs
=
closesocket
(
sockfd
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment