• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

FFFTPのソースコードです。


Commit MetaInfo

Revisionfad6e7c3240d47608cb07f6f2304e1e5091f995a (tree)
Zeit2011-11-01 21:53:00
Autors_kawamoto <s_kawamoto@user...>
Commiters_kawamoto

Log Message

Fix bugs of receiving data on Windows 2000.
Enhance routines for canceling or aborting.

Ändern Zusammenfassung

Diff

Binary files a/FFFTP_Eng_Release/FFFTP.exe and b/FFFTP_Eng_Release/FFFTP.exe differ
Binary files a/Release/FFFTP.exe and b/Release/FFFTP.exe differ
--- a/common.h
+++ b/common.h
@@ -1719,6 +1719,8 @@ int do_listen(SOCKET s, int backlog);
17191719 SOCKET do_accept(SOCKET s, struct sockaddr *addr, int *addrlen);
17201720 int do_recv(SOCKET s, char *buf, int len, int flags, int *TimeOut, int *CancelCheckWork);
17211721 int do_send(SOCKET s, const char *buf, int len, int flags, int *TimeOutErr, int *CancelCheckWork);
1722+// 同時接続対応
1723+void RemoveReceivedData(SOCKET s);
17221724 int CheckClosedAndReconnect(void);
17231725 void CheckAllEventClosed(void);
17241726
--- a/main.c
+++ b/main.c
@@ -832,6 +832,10 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
832832 switch (message)
833833 {
834834 case WM_COMMAND :
835+ // 同時接続対応
836+ // 中断後に受信バッファに応答が残っていると次のコマンドの応答が正しく処理できない
837+ if(CancelFlg == YES)
838+ RemoveReceivedData(AskCmdCtrlSkt());
835839 switch(LOWORD(wParam))
836840 {
837841 case MENU_CONNECT :
--- a/socket.c
+++ b/socket.c
@@ -1046,36 +1046,40 @@ int do_send(SOCKET s, const char *buf, int len, int flags, int *TimeOutErr, int
10461046 #if DBG_MSG
10471047 DoPrintf("## Async set: FD_CONNECT|FD_CLOSE|FD_ACCEPT|FD_READ|FD_WRITE");
10481048 #endif
1049- WSAAsyncSelect(s, hWndSocket, WM_ASYNC_SOCKET, FD_CONNECT | FD_CLOSE | FD_ACCEPT | FD_READ | FD_WRITE);
1049+ // Windows 2000でFD_WRITEが通知されないことがあるバグ修正
1050+ // 毎回通知されたのはNT 4.0までのバグであり仕様ではない
1051+ // XP以降は互換性のためか毎回通知される
1052+// WSAAsyncSelect(s, hWndSocket, WM_ASYNC_SOCKET, FD_CONNECT | FD_CLOSE | FD_ACCEPT | FD_READ | FD_WRITE);
10501053 if(BackgrndMessageProc() == YES)
10511054 *CancelCheckWork = YES;
10521055
10531056 // FTPS対応
10541057 // 送信バッファの空き確認には影響しないが念のため
10551058 // while((*CancelCheckWork == NO) && (AskAsyncDone(s, &Error, FD_WRITE_BIT) != YES))
1056- while(!IsSSLAttached(s) && (*CancelCheckWork == NO) && (AskAsyncDone(s, &Error, FD_WRITE_BIT) != YES))
1057- {
1058- if(AskAsyncDone(s, &Error, FD_CLOSE_BIT) == YES)
1059- {
1060- Error = 1;
1061- break;
1062- }
1063-
1064- Sleep(1);
1065- if(BackgrndMessageProc() == YES)
1066- *CancelCheckWork = YES;
1067- else if(TimeOut != 0)
1068- {
1069- time(&ElapseTime);
1070- ElapseTime -= StartTime;
1071- if(ElapseTime >= TimeOut)
1072- {
1073- DoPrintf("do_write timed out");
1074- *TimeOutErr = YES;
1075- *CancelCheckWork = YES;
1076- }
1077- }
1078- }
1059+ // Windows 2000でFD_WRITEが通知されないことがあるバグ修正
1060+// while(!IsSSLAttached(s) && (*CancelCheckWork == NO) && (AskAsyncDone(s, &Error, FD_WRITE_BIT) != YES))
1061+// {
1062+// if(AskAsyncDone(s, &Error, FD_CLOSE_BIT) == YES)
1063+// {
1064+// Error = 1;
1065+// break;
1066+// }
1067+//
1068+// Sleep(1);
1069+// if(BackgrndMessageProc() == YES)
1070+// *CancelCheckWork = YES;
1071+// else if(TimeOut != 0)
1072+// {
1073+// time(&ElapseTime);
1074+// ElapseTime -= StartTime;
1075+// if(ElapseTime >= TimeOut)
1076+// {
1077+// DoPrintf("do_write timed out");
1078+// *TimeOutErr = YES;
1079+// *CancelCheckWork = YES;
1080+// }
1081+// }
1082+// }
10791083
10801084 if((Error == 0) && (*CancelCheckWork == NO) && (*TimeOutErr == NO))
10811085 {
@@ -1133,6 +1137,20 @@ int do_send(SOCKET s, const char *buf, int len, int flags, int *TimeOutErr, int
11331137 }
11341138
11351139
1140+// 同時接続対応
1141+void RemoveReceivedData(SOCKET s)
1142+{
1143+ char buf[1024];
1144+ int len;
1145+ int Error;
1146+ while((len = recvS(s, buf, sizeof(buf), MSG_PEEK)) >= 0)
1147+ {
1148+ AskAsyncDone(s, &Error, FD_READ_BIT);
1149+ recvS(s, buf, len, 0);
1150+ }
1151+}
1152+
1153+
11361154 /*-----
11371155 *
11381156 * Parameter