Skip to content

Commit

Permalink
Merge pull request #19 from sayurin/fix-17
Browse files Browse the repository at this point in the history
fix #17.
  • Loading branch information
sayurin committed Apr 10, 2018
2 parents 65abf29 + 93c544c commit 874ec9d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,18 @@ static int FTPS_recv(SOCKET s, char* buf, int len, int flags) {
}

if (empty(context->readPlain))
// TODO: recv()の読み出し量が少ないとSEC_E_INCOMPLETE_MESSAGEが発生してしまう。
return context->readStatus == SEC_I_CONTEXT_EXPIRED ? 0 : SOCKET_ERROR;
switch (context->readStatus) {
case SEC_I_CONTEXT_EXPIRED:
return 0;
case SEC_E_INCOMPLETE_MESSAGE:
// recvできたデータが少なすぎてフレームの解析・デコードができず、復号データが得られないというエラー。
// ブロッキングが発生するというエラーに書き換える。
WSASetLastError(WSAEWOULDBLOCK);
return SOCKET_ERROR;
default:
_RPTWN(_CRT_WARN, L"FTPS_recv readStatus: %08X.\n", context->readStatus);
return SOCKET_ERROR;
}
len = std::min(len, size_as<int>(context->readPlain));
std::copy_n(begin(context->readPlain), len, buf);
if ((flags & MSG_PEEK) == 0)
Expand Down

0 comments on commit 874ec9d

Please sign in to comment.