Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
FMVip_Today
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhenfei.zhang
FMVip_Today
Commits
68a7e05d
Commit
68a7e05d
authored
Sep 17, 2016
by
Carwyn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes: 1. 大数据包接收失败问题
parent
11222179
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
21 deletions
+36
-21
FMVipDC/fmsockserver.cpp
+35
-21
FMVipDC/fmsockserver.h
+1
-0
No files found.
FMVipDC/fmsockserver.cpp
View file @
68a7e05d
...
@@ -111,12 +111,13 @@ BOOL FMSockServer::_Listen()
...
@@ -111,12 +111,13 @@ BOOL FMSockServer::_Listen()
io_data
->
buffer
.
buf
=
(
char
*
)
&
io_data
->
header
;
io_data
->
buffer
.
buf
=
(
char
*
)
&
io_data
->
header
;
io_data
->
relay
=
_relay
;
io_data
->
relay
=
_relay
;
io_data
->
socket
=
sclient
;
io_data
->
socket
=
sclient
;
io_data
->
offset
=
0
;
WSARecv
(
sclient
,
&
io_data
->
buffer
,
1
,
NULL
,
&
io_data
->
flags
,
&
io_data
->
overlap
,
FMSockServer
::
RecvRoutine
);
WSARecv
(
sclient
,
&
io_data
->
buffer
,
1
,
NULL
,
&
io_data
->
flags
,
&
io_data
->
overlap
,
FMSockServer
::
RecvRoutine
);
DWORD
res
=
SleepEx
(
1000
,
TRUE
);
DWORD
res
=
SleepEx
(
1000
,
TRUE
);
while
(
res
!=
WAIT_IO_COMPLETION
)
{
while
(
res
!=
WAIT_IO_COMPLETION
)
{
FMLOG
(
_T
(
"
_Listen Rewaiting fo
r I/O completion..."
));
FMLOG
(
_T
(
"
Rewaiting for msg heade
r I/O completion..."
));
res
=
SleepEx
(
1000
,
TRUE
);
res
=
SleepEx
(
1000
,
TRUE
);
}
}
}
}
...
@@ -149,41 +150,54 @@ void FMSockServer::RecvRoutine(DWORD err, DWORD bytes, LPWSAOVERLAPPED overlappe
...
@@ -149,41 +150,54 @@ void FMSockServer::RecvRoutine(DWORD err, DWORD bytes, LPWSAOVERLAPPED overlappe
HeapFree
(
GetProcessHeap
(),
0
,
io_data
);
HeapFree
(
GetProcessHeap
(),
0
,
io_data
);
return
;
return
;
}
}
FMLOG
(
_T
(
"Received bytes: %ld."
),
bytes
);
FMLOG
(
_T
(
"Received bytes: %ld."
),
io_data
->
offset
+
bytes
);
UINT
data_len
=
strlen
(
io_data
->
msg
);
if
(
io_data
->
header
.
flag
==
FMSOCKFLAG
)
{
if
(
io_data
->
header
.
flag
==
FMSOCKFLAG
)
{
if
(
err
!=
0
||
bytes
==
0
)
{
if
(
err
!=
0
||
bytes
==
0
)
{
//! Connection was closed by client
//! Connection was closed by client
closesocket
(
io_data
->
socket
);
closesocket
(
io_data
->
socket
);
FMLOG
(
_T
(
"Error receiving data."
));
FMLOG
(
_T
(
"Error receiving data."
));
}
}
else
if
(
strlen
(
io_data
->
msg
)
<
io_data
->
header
.
len
)
{
else
if
(
data_len
<
io_data
->
header
.
len
)
{
//! Receive data
//! Receive data
LPFMSOCKDATA
io_new_data
=
NULL
;
if
(
data_len
==
0
)
{
UINT
len
=
sizeof
(
FMSOCKDATA
)
+
io_data
->
header
.
len
;
LPFMSOCKDATA
io_new_data
=
NULL
;
io_new_data
=
(
LPFMSOCKDATA
)
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
len
);
UINT
len
=
sizeof
(
FMSOCKDATA
)
+
io_data
->
header
.
len
;
io_new_data
=
(
LPFMSOCKDATA
)
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
len
);
io_new_data
->
buffer
=
io_data
->
buffer
;
io_new_data
->
buffer
.
len
=
io_data
->
header
.
len
;
io_new_data
->
buffer
.
buf
=
io_new_data
->
msg
;
io_new_data
->
socket
=
io_data
->
socket
;
io_new_data
->
relay
=
io_data
->
relay
;
io_new_data
->
flags
=
io_data
->
flags
;
io_new_data
->
header
=
io_data
->
header
;
io_new_data
->
buffer
=
io_data
->
buffer
;
io_new_data
->
buffer
.
len
=
io_data
->
header
.
len
;
io_new_data
->
buffer
.
buf
=
io_new_data
->
msg
+
io_new_data
->
offset
;
WSARecv
(
io_new_data
->
socket
,
&
io_new_data
->
buffer
,
1
,
NULL
,
&
io_new_data
->
flags
,
&
io_new_data
->
overlap
,
FMSockServer
::
RecvRoutine
);
io_new_data
->
socket
=
io_data
->
socket
;
io_new_data
->
relay
=
io_data
->
relay
;
io_new_data
->
flags
=
io_data
->
flags
;
io_new_data
->
header
=
io_data
->
header
;
DWORD
res
=
SleepEx
(
1000
,
TRUE
);
WSARecv
(
io_new_data
->
socket
,
&
io_new_data
->
buffer
,
1
,
NULL
,
&
io_new_data
->
flags
,
&
io_new_data
->
overlap
,
FMSockServer
::
RecvRoutine
);
while
(
res
!=
WAIT_IO_COMPLETION
)
{
DWORD
res
=
SleepEx
(
1000
,
TRUE
);
FMLOG
(
_T
(
"RecvRoutine 1 Rewaiting for I/O completion..."
));
while
(
res
!=
WAIT_IO_COMPLETION
)
{
res
=
SleepEx
(
1000
,
TRUE
);
FMLOG
(
_T
(
"Rewaiting for new data(offset: %ld)I/O completion..."
),
io_new_data
->
offset
);
res
=
SleepEx
(
1000
,
TRUE
);
}
}
else
{
io_data
->
buffer
.
len
=
io_data
->
header
.
len
-
io_data
->
offset
;
io_data
->
buffer
.
buf
=
io_data
->
msg
+
io_data
->
offset
;
io_data
->
offset
+=
bytes
;
WSARecv
(
io_data
->
socket
,
&
io_data
->
buffer
,
1
,
NULL
,
&
io_data
->
flags
,
&
io_data
->
overlap
,
FMSockServer
::
RecvRoutine
);
DWORD
res
=
SleepEx
(
1000
,
TRUE
);
while
(
res
!=
WAIT_IO_COMPLETION
)
{
FMLOG
(
_T
(
"Rewaiting for old data(offset: %ld)I/O completion..."
),
io_data
->
offset
);
res
=
SleepEx
(
1000
,
TRUE
);
}
}
}
}
}
else
{
else
{
//! Legal freemud api data
//! Legal freemud api data
FMLOG
(
"All data received: %s"
,
io_data
->
msg
);
io_data
->
msg
[
bytes
]
=
'\0'
;
io_data
->
msg
[
bytes
]
=
'\0'
;
char
*
response
=
NULL
;
UINT
len
=
0
;
char
*
response
=
NULL
;
UINT
len
=
0
;
...
@@ -203,7 +217,7 @@ void FMSockServer::RecvRoutine(DWORD err, DWORD bytes, LPWSAOVERLAPPED overlappe
...
@@ -203,7 +217,7 @@ void FMSockServer::RecvRoutine(DWORD err, DWORD bytes, LPWSAOVERLAPPED overlappe
WSARecv
(
io_new_data
->
socket
,
&
io_new_data
->
buffer
,
1
,
NULL
,
&
io_new_data
->
flags
,
&
io_new_data
->
overlap
,
FMSockServer
::
RecvRoutine
);
WSARecv
(
io_new_data
->
socket
,
&
io_new_data
->
buffer
,
1
,
NULL
,
&
io_new_data
->
flags
,
&
io_new_data
->
overlap
,
FMSockServer
::
RecvRoutine
);
DWORD
res
=
SleepEx
(
1000
,
TRUE
);
DWORD
res
=
SleepEx
(
1000
,
TRUE
);
while
(
res
!=
WAIT_IO_COMPLETION
)
{
while
(
res
!=
WAIT_IO_COMPLETION
)
{
FMLOG
(
_T
(
"Re
cvRoutine Rewaiting
for I/O completion..."
));
FMLOG
(
_T
(
"Re
waiting send
for I/O completion..."
));
res
=
SleepEx
(
1000
,
TRUE
);
res
=
SleepEx
(
1000
,
TRUE
);
}
}
}
}
...
...
FMVipDC/fmsockserver.h
View file @
68a7e05d
...
@@ -35,6 +35,7 @@ typedef struct
...
@@ -35,6 +35,7 @@ typedef struct
DWORD
flags
;
DWORD
flags
;
SOCKET
socket
;
SOCKET
socket
;
FMApiRelay
*
relay
;
FMApiRelay
*
relay
;
UINT
offset
;
FMSOCKHEADER
header
;
FMSOCKHEADER
header
;
char
msg
[
1
];
char
msg
[
1
];
...
...
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