Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
k-sdk
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈伟灿
k-sdk
Commits
12530ad9
Commit
12530ad9
authored
Sep 15, 2020
by
chen.weican
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】修改nanomsg数据缓存没有清空导致数据叠加的BUG
【提交人】陈伟灿
parent
9210363f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
common/api/tcp_channel.c
common/api/tcp_channel.c
+4
-2
No files found.
common/api/tcp_channel.c
View file @
12530ad9
...
@@ -320,7 +320,7 @@ static void read_cb(struct ev_loop *loop, struct ev_io *watcher, int revents)
...
@@ -320,7 +320,7 @@ static void read_cb(struct ev_loop *loop, struct ev_io *watcher, int revents)
}
}
int
res
=
0
;
int
res
=
0
;
kk_tcp_ctrl_t
*
tcp_ctrl
=
(
kk_tcp_ctrl_t
*
)
watcher
->
data
;
kk_tcp_ctrl_t
*
tcp_ctrl
=
(
kk_tcp_ctrl_t
*
)
watcher
->
data
;
int32_t
bytes
=
re
ad
(
watcher
->
fd
,
buffer
,
sizeof
(
buffer
)
);
int32_t
bytes
=
re
cv
(
watcher
->
fd
,
buffer
,
sizeof
(
buffer
),
0
);
if
(
-
1
==
bytes
)
{
if
(
-
1
==
bytes
)
{
//tcp Error
//tcp Error
if
(
EINTR
!=
errno
&&
EAGAIN
!=
errno
)
{
if
(
EINTR
!=
errno
&&
EAGAIN
!=
errno
)
{
...
@@ -659,6 +659,7 @@ static void loop_tcp_client_thread(void *arg){
...
@@ -659,6 +659,7 @@ static void loop_tcp_client_thread(void *arg){
{
{
//接受网络数据
//接受网络数据
_MutexLock
(
g_client_ctrl
.
mutex
);
_MutexLock
(
g_client_ctrl
.
mutex
);
memset
(
buf
,
0x0
,
sizeof
(
buf
));
ret
=
read
(
g_client_ctrl
.
sd
,
buf
,
sizeof
(
buf
));
ret
=
read
(
g_client_ctrl
.
sd
,
buf
,
sizeof
(
buf
));
_MutexUnlock
(
g_client_ctrl
.
mutex
);
_MutexUnlock
(
g_client_ctrl
.
mutex
);
...
@@ -670,7 +671,7 @@ static void loop_tcp_client_thread(void *arg){
...
@@ -670,7 +671,7 @@ static void loop_tcp_client_thread(void *arg){
break
;
break
;
}
}
}
else
if
(
ret
>
0
){
}
else
if
(
ret
>
0
){
printf
(
"
buf = %s
\n
"
,
buf
);
//printf("11
buf = %s\n",buf);
if
(
g_client_ctrl
.
cb
!=
NULL
){
if
(
g_client_ctrl
.
cb
!=
NULL
){
g_client_ctrl
.
cb
(
buf
,
ret
,
""
);
g_client_ctrl
.
cb
(
buf
,
ret
,
""
);
}
}
...
@@ -701,6 +702,7 @@ int kk_reset_retry_num(){
...
@@ -701,6 +702,7 @@ int kk_reset_retry_num(){
int
kk_tcp_client_send
(
char
*
data
,
int
len
){
int
kk_tcp_client_send
(
char
*
data
,
int
len
){
int
ret
=
0
;
int
ret
=
0
;
int
cnt
=
0
;
int
cnt
=
0
;
if
(
data
!=
NULL
){
if
(
data
!=
NULL
){
while
(
g_client_ctrl
.
sd
==
-
1
&&
cnt
<
5
){
while
(
g_client_ctrl
.
sd
==
-
1
&&
cnt
<
5
){
printf
(
"[%s] tcp don't connect, sleep 1s !!!!
\n
"
,
__FUNCTION__
);
printf
(
"[%s] tcp don't connect, sleep 1s !!!!
\n
"
,
__FUNCTION__
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment