Loweynet
Revisão | c3c5ce768282208e5678f485c889484f9343cb48 (tree) |
---|---|
Hora | 2012-02-07 00:36:12 |
Autor | s_kawamoto <s_kawamoto@user...> |
Commiter | s_kawamoto |
Fix bugs of simultaneous connection.
Fix bugs of exclusive locks for UI.
@@ -786,6 +786,9 @@ static LRESULT FileListCommonWndProc(HWND hWnd, UINT message, WPARAM wParam, LPA | ||
786 | 786 | return(CallWindowProc(ProcPtr, hWnd, message, wParam, lParam)); |
787 | 787 | |
788 | 788 | case WM_DROPFILES : |
789 | + // 同時接続対応 | |
790 | + if(AskUserOpeDisabled() == YES) | |
791 | + break; | |
789 | 792 | // ドラッグ中は処理しない。ドラッグ後にWM_LBUTTONDOWNが飛んでくるため、そこで処理する。 |
790 | 793 | if (Dragging == YES) |
791 | 794 | return (FALSE); |
@@ -818,6 +821,9 @@ static LRESULT FileListCommonWndProc(HWND hWnd, UINT message, WPARAM wParam, LPA | ||
818 | 821 | hCsrDrg = LoadCursor(NULL, IDC_ARROW); |
819 | 822 | SetCursor(hCsrDrg); |
820 | 823 | |
824 | + // 同時接続対応 | |
825 | + if(AskUserOpeDisabled() == YES) | |
826 | + break; | |
821 | 827 | Point.x = (long)(short)LOWORD(lParam); |
822 | 828 | Point.y = (long)(short)HIWORD(lParam); |
823 | 829 | ClientToScreen(hWnd, &Point); |
@@ -261,8 +261,9 @@ void DownLoadProc(int ChName, int ForceFile, int All) | ||
261 | 261 | } |
262 | 262 | DeleteFileList(&FileListBase); |
263 | 263 | |
264 | - strcpy(Pkt.Cmd, "GOQUIT"); | |
265 | - AddTransFileList(&Pkt); | |
264 | + // 同時接続対応 | |
265 | +// strcpy(Pkt.Cmd, "GOQUIT"); | |
266 | +// AddTransFileList(&Pkt); | |
266 | 267 | |
267 | 268 | GoForwardTransWindow(); |
268 | 269 | // KeepTransferDialog(NO); |
@@ -363,8 +364,9 @@ void DirectDownLoadProc(char *Fname) | ||
363 | 364 | AddTransFileList(&Pkt); |
364 | 365 | } |
365 | 366 | |
366 | - strcpy(Pkt.Cmd, "GOQUIT"); | |
367 | - AddTransFileList(&Pkt); | |
367 | + // 同時接続対応 | |
368 | +// strcpy(Pkt.Cmd, "GOQUIT"); | |
369 | +// AddTransFileList(&Pkt); | |
368 | 370 | |
369 | 371 | GoForwardTransWindow(); |
370 | 372 | // KeepTransferDialog(NO); |
@@ -629,8 +631,9 @@ void MirrorDownloadProc(int Notify) | ||
629 | 631 | AddTransFileList(&Pkt); |
630 | 632 | } |
631 | 633 | |
632 | - strcpy(Pkt.Cmd, "GOQUIT"); | |
633 | - AddTransFileList(&Pkt); | |
634 | + // 同時接続対応 | |
635 | +// strcpy(Pkt.Cmd, "GOQUIT"); | |
636 | +// AddTransFileList(&Pkt); | |
634 | 637 | } |
635 | 638 | else |
636 | 639 | EraseTmpTransFileList(&Base); |
@@ -1056,8 +1059,9 @@ void UpLoadListProc(int ChName, int All) | ||
1056 | 1059 | |
1057 | 1060 | DeleteFileList(&FileListBase); |
1058 | 1061 | |
1059 | - strcpy(Pkt.Cmd, "GOQUIT"); | |
1060 | - AddTransFileList(&Pkt); | |
1062 | + // 同時接続対応 | |
1063 | +// strcpy(Pkt.Cmd, "GOQUIT"); | |
1064 | +// AddTransFileList(&Pkt); | |
1061 | 1065 | |
1062 | 1066 | GoForwardTransWindow(); |
1063 | 1067 |
@@ -1223,8 +1227,9 @@ void UpLoadDragProc(WPARAM wParam) | ||
1223 | 1227 | |
1224 | 1228 | DeleteFileList(&FileListBase); |
1225 | 1229 | |
1226 | - strcpy(Pkt.Cmd, "GOQUIT"); | |
1227 | - AddTransFileList(&Pkt); | |
1230 | + // 同時接続対応 | |
1231 | +// strcpy(Pkt.Cmd, "GOQUIT"); | |
1232 | +// AddTransFileList(&Pkt); | |
1228 | 1233 | |
1229 | 1234 | GoForwardTransWindow(); |
1230 | 1235 |
@@ -1494,8 +1499,9 @@ void MirrorUploadProc(int Notify) | ||
1494 | 1499 | AddTransFileList(&Pkt); |
1495 | 1500 | } |
1496 | 1501 | |
1497 | - strcpy(Pkt.Cmd, "GOQUIT"); | |
1498 | - AddTransFileList(&Pkt); | |
1502 | + // 同時接続対応 | |
1503 | +// strcpy(Pkt.Cmd, "GOQUIT"); | |
1504 | +// AddTransFileList(&Pkt); | |
1499 | 1505 | } |
1500 | 1506 | else |
1501 | 1507 | EraseTmpTransFileList(&Base); |
@@ -537,7 +537,7 @@ static void EraseTransFileList(void) | ||
537 | 537 | TRANSPACKET *New; |
538 | 538 | TRANSPACKET *Next; |
539 | 539 | TRANSPACKET *NotDel; |
540 | - TRANSPACKET Pkt; | |
540 | +// TRANSPACKET Pkt; | |
541 | 541 | |
542 | 542 | NotDel = NULL; |
543 | 543 |
@@ -582,8 +582,9 @@ static void EraseTransFileList(void) | ||
582 | 582 | // 同時接続対応 |
583 | 583 | WaitForMainThread = NO; |
584 | 584 | |
585 | - strcpy(Pkt.Cmd, "GOQUIT"); | |
586 | - AddTransFileList(&Pkt); | |
585 | + // 同時接続対応 | |
586 | +// strcpy(Pkt.Cmd, "GOQUIT"); | |
587 | +// AddTransFileList(&Pkt); | |
587 | 588 | return; |
588 | 589 | } |
589 | 590 |
@@ -742,6 +743,8 @@ static ULONG WINAPI TransferThread(void *Dummy) | ||
742 | 743 | Pos = TransPacketBase; |
743 | 744 | TransPacketBase = TransPacketBase->Next; |
744 | 745 | free(Pos); |
746 | + if(TransPacketBase == NULL) | |
747 | + GoExit = YES; | |
745 | 748 | } |
746 | 749 | NewCmdSkt = AskCmdCtrlSkt(); |
747 | 750 | if(AskReuseCmdSkt() == YES && ThreadCount == 0) |
@@ -759,9 +762,7 @@ static ULONG WINAPI TransferThread(void *Dummy) | ||
759 | 762 | else |
760 | 763 | CheckClosedAndReconnectTrnSkt(&TrnSkt, &Canceled[ThreadCount]); |
761 | 764 | // 同時ログイン数制限対策 |
762 | - if(TrnSkt != INVALID_SOCKET) | |
763 | - LastUsed = timeGetTime(); | |
764 | - else | |
765 | + if(TrnSkt == INVALID_SOCKET) | |
765 | 766 | { |
766 | 767 | // 同時ログイン数制限に引っかかった可能性あり |
767 | 768 | // 負荷を下げるために約10秒間待機 |
@@ -773,6 +774,7 @@ static ULONG WINAPI TransferThread(void *Dummy) | ||
773 | 774 | i--; |
774 | 775 | } |
775 | 776 | } |
777 | + LastUsed = timeGetTime(); | |
776 | 778 | // WaitForSingleObject(hListAccMutex, INFINITE); |
777 | 779 | while(WaitForSingleObject(hListAccMutex, 0) == WAIT_TIMEOUT) |
778 | 780 | { |
@@ -786,7 +788,7 @@ static ULONG WINAPI TransferThread(void *Dummy) | ||
786 | 788 | { |
787 | 789 | // 同時ログイン数制限対策 |
788 | 790 | // 60秒間使用されなければログアウト |
789 | - if(timeGetTime() - LastUsed > 60000) | |
791 | + if(timeGetTime() - LastUsed > 60000 || NewCmdSkt == INVALID_SOCKET) | |
790 | 792 | { |
791 | 793 | ReleaseMutex(hListAccMutex); |
792 | 794 | SendData(TrnSkt, "QUIT\r\n", 6, 0, &Canceled[ThreadCount]); |
@@ -806,13 +808,6 @@ static ULONG WINAPI TransferThread(void *Dummy) | ||
806 | 808 | // if(TransPacketBase != NULL) |
807 | 809 | if(TrnSkt != INVALID_SOCKET && NextTransPacketBase != NULL) |
808 | 810 | { |
809 | - if(strcmp(NextTransPacketBase->Cmd, "GOQUIT") == 0 && NextTransPacketBase != TransPacketBase) | |
810 | - { | |
811 | - ReleaseMutex(hListAccMutex); | |
812 | - BackgrndMessageProc(); | |
813 | - Sleep(1); | |
814 | - continue; | |
815 | - } | |
816 | 811 | Pos = NextTransPacketBase; |
817 | 812 | NextTransPacketBase = NextTransPacketBase->Next; |
818 | 813 | // ディレクトリ操作は非同期で行わない |
@@ -841,6 +836,7 @@ static ULONG WINAPI TransferThread(void *Dummy) | ||
841 | 836 | // TransPacketBase->hWndTrans = hWndTrans; |
842 | 837 | Pos->hWndTrans = hWndTrans; |
843 | 838 | Pos->ctrl_skt = TrnSkt; |
839 | + Pos->Abort = ABORT_NONE; | |
844 | 840 | Pos->ThreadCount = ThreadCount; |
845 | 841 | |
846 | 842 | if(hWndTrans != NULL) |
@@ -856,6 +852,9 @@ static ULONG WINAPI TransferThread(void *Dummy) | ||
856 | 852 | // SendMessage(hWndTrans, WM_SET_PACKET, 0, (LPARAM)TransPacketBase); |
857 | 853 | SendMessage(hWndTrans, WM_SET_PACKET, 0, (LPARAM)Pos); |
858 | 854 | |
855 | + // 中断後に受信バッファに応答が残っていると次のコマンドの応答が正しく処理できない | |
856 | + RemoveReceivedData(TrnSkt); | |
857 | + | |
859 | 858 | /* ダウンロード */ |
860 | 859 | // if(strncmp(TransPacketBase->Cmd, "RETR", 4) == 0) |
861 | 860 | if(strncmp(Pos->Cmd, "RETR", 4) == 0) |
@@ -1110,11 +1109,11 @@ static ULONG WINAPI TransferThread(void *Dummy) | ||
1110 | 1109 | } |
1111 | 1110 | /* 自動終了のための通知 */ |
1112 | 1111 | // else if(strcmp(TransPacketBase->Cmd, "GOQUIT") == 0) |
1113 | - else if(strcmp(Pos->Cmd, "GOQUIT") == 0) | |
1114 | - { | |
1115 | - ReleaseMutex(hListAccMutex); | |
1116 | - GoExit = YES; | |
1117 | - } | |
1112 | +// else if(strcmp(Pos->Cmd, "GOQUIT") == 0) | |
1113 | +// { | |
1114 | +// ReleaseMutex(hListAccMutex); | |
1115 | +// GoExit = YES; | |
1116 | +// } | |
1118 | 1117 | else |
1119 | 1118 | ReleaseMutex(hListAccMutex); |
1120 | 1119 |
@@ -1134,6 +1133,7 @@ static ULONG WINAPI TransferThread(void *Dummy) | ||
1134 | 1133 | for(i = 0; i < MAX_DATA_CONNECTION; i++) |
1135 | 1134 | Canceled[i] = YES; |
1136 | 1135 | EraseTransFileList(); |
1136 | + GoExit = YES; | |
1137 | 1137 | Pos = NULL; |
1138 | 1138 | } |
1139 | 1139 | else |
@@ -1152,7 +1152,7 @@ static ULONG WINAPI TransferThread(void *Dummy) | ||
1152 | 1152 | // TransPacketBase = TransPacketBase->Next; |
1153 | 1153 | // free(Pos); |
1154 | 1154 | } |
1155 | - ClearAll = NO; | |
1155 | +// ClearAll = NO; | |
1156 | 1156 | ReleaseMutex(hListAccMutex); |
1157 | 1157 | |
1158 | 1158 | if(BackgrndMessageProc() == YES) |
@@ -1171,8 +1171,25 @@ static ULONG WINAPI TransferThread(void *Dummy) | ||
1171 | 1171 | // else |
1172 | 1172 | else if(TransPacketBase == NULL) |
1173 | 1173 | { |
1174 | + ClearAll = NO; | |
1174 | 1175 | DelNotify = NO; |
1175 | 1176 | |
1177 | + if(GoExit == YES) | |
1178 | + { | |
1179 | + SoundPlay(SND_TRANS); | |
1180 | + if(AskAutoExit() == NO) | |
1181 | + { | |
1182 | + if(Down == YES) | |
1183 | + PostMessage(GetMainHwnd(), WM_REFRESH_LOCAL_FLG, 0, 0); | |
1184 | + if(Up == YES) | |
1185 | + PostMessage(GetMainHwnd(), WM_REFRESH_REMOTE_FLG, 0, 0); | |
1186 | + } | |
1187 | + Down = NO; | |
1188 | + Up = NO; | |
1189 | + PostMessage(GetMainHwnd(), WM_COMMAND, MAKEWPARAM(MENU_AUTO_EXIT, 0), 0); | |
1190 | + GoExit = NO; | |
1191 | + } | |
1192 | + | |
1176 | 1193 | ReleaseMutex(hListAccMutex); |
1177 | 1194 | if(KeepDlg == NO) |
1178 | 1195 | { |
@@ -1201,22 +1218,6 @@ static ULONG WINAPI TransferThread(void *Dummy) | ||
1201 | 1218 | // Sleep(1); |
1202 | 1219 | Sleep(100); |
1203 | 1220 | |
1204 | - if(GoExit == YES) | |
1205 | - { | |
1206 | - SoundPlay(SND_TRANS); | |
1207 | - if(AskAutoExit() == NO) | |
1208 | - { | |
1209 | - if(Down == YES) | |
1210 | - PostMessage(GetMainHwnd(), WM_REFRESH_LOCAL_FLG, 0, 0); | |
1211 | - if(Up == YES) | |
1212 | - PostMessage(GetMainHwnd(), WM_REFRESH_REMOTE_FLG, 0, 0); | |
1213 | - } | |
1214 | - Down = NO; | |
1215 | - Up = NO; | |
1216 | - PostMessage(GetMainHwnd(), WM_COMMAND, MAKEWPARAM(MENU_AUTO_EXIT, 0), 0); | |
1217 | - GoExit = NO; | |
1218 | - } | |
1219 | - | |
1220 | 1221 | // 再転送対応 |
1221 | 1222 | TransferErrorMode = AskTransferErrorMode(); |
1222 | 1223 | TransferErrorNotify = AskTransferErrorNotify(); |
@@ -1346,6 +1347,8 @@ int DoDownLoad(SOCKET cSkt, TRANSPACKET *Pkt, int DirList, int *CancelCheckWork) | ||
1346 | 1347 | } |
1347 | 1348 | else |
1348 | 1349 | SetErrorMsg(Reply); |
1350 | + // エラーによってはダイアログが表示されない場合があるバグ対策 | |
1351 | + DispDownloadFinishMsg(Pkt, iRetCode); | |
1349 | 1352 | } |
1350 | 1353 | else |
1351 | 1354 | { |
@@ -1353,8 +1356,6 @@ int DoDownLoad(SOCKET cSkt, TRANSPACKET *Pkt, int DirList, int *CancelCheckWork) | ||
1353 | 1356 | SetTaskMsg(MSGJPN089, Pkt->RemoteFile); |
1354 | 1357 | iRetCode = 200; |
1355 | 1358 | } |
1356 | - // エラーによってはダイアログが表示されない場合があるバグ対策 | |
1357 | - DispDownloadFinishMsg(Pkt, iRetCode); | |
1358 | 1359 | return(iRetCode); |
1359 | 1360 | } |
1360 | 1361 |
@@ -2281,6 +2282,8 @@ static void DispDownloadFinishMsg(TRANSPACKET *Pkt, int iRetCode) | ||
2281 | 2282 | { |
2282 | 2283 | char Fname[FMAX_PATH+1]; |
2283 | 2284 | |
2285 | + // 同時接続対応 | |
2286 | + ReleaseMutex(hListAccMutex); | |
2284 | 2287 | if(ForceAbort == NO) |
2285 | 2288 | { |
2286 | 2289 | if((iRetCode/100) >= FTP_CONTINUE) |
@@ -2300,7 +2303,9 @@ static void DispDownloadFinishMsg(TRANSPACKET *Pkt, int iRetCode) | ||
2300 | 2303 | return; |
2301 | 2304 | #endif |
2302 | 2305 | |
2303 | - if((strncmp(Pkt->Cmd, "NLST", 4) == 0) || (strncmp(Pkt->Cmd, "LIST", 4) == 0)) | |
2306 | + // MLSD対応 | |
2307 | +// if((strncmp(Pkt->Cmd, "NLST", 4) == 0) || (strncmp(Pkt->Cmd, "LIST", 4) == 0)) | |
2308 | + if((strncmp(Pkt->Cmd, "NLST", 4) == 0) || (strncmp(Pkt->Cmd, "LIST", 4) == 0) || (strncmp(Pkt->Cmd, "MLSD", 4) == 0)) | |
2304 | 2309 | { |
2305 | 2310 | SetTaskMsg(MSGJPN097); |
2306 | 2311 | strcpy(Fname, MSGJPN098); |
@@ -2337,7 +2342,9 @@ static void DispDownloadFinishMsg(TRANSPACKET *Pkt, int iRetCode) | ||
2337 | 2342 | } |
2338 | 2343 | else |
2339 | 2344 | { |
2340 | - if((strncmp(Pkt->Cmd, "NLST", 4) == 0) || (strncmp(Pkt->Cmd, "LIST", 4) == 0)) | |
2345 | + // MLSD対応 | |
2346 | +// if((strncmp(Pkt->Cmd, "NLST", 4) == 0) || (strncmp(Pkt->Cmd, "LIST", 4) == 0)) | |
2347 | + if((strncmp(Pkt->Cmd, "NLST", 4) == 0) || (strncmp(Pkt->Cmd, "LIST", 4) == 0) || (strncmp(Pkt->Cmd, "MLSD", 4) == 0)) | |
2341 | 2348 | SetTaskMsg(MSGJPN101, Pkt->ExistSize); |
2342 | 2349 | // 同時接続対応 |
2343 | 2350 | // else if((Pkt->hWndTrans != NULL) && (TimeStart != 0)) |
@@ -2610,6 +2617,8 @@ static int DoUpLoad(SOCKET cSkt, TRANSPACKET *Pkt) | ||
2610 | 2617 | // エラーによってはダイアログが表示されない場合があるバグ対策 |
2611 | 2618 | // DispUploadFinishMsg(Pkt, iRetCode); |
2612 | 2619 | } |
2620 | + // エラーによってはダイアログが表示されない場合があるバグ対策 | |
2621 | + DispUploadFinishMsg(Pkt, iRetCode); | |
2613 | 2622 | } |
2614 | 2623 | else |
2615 | 2624 | { |
@@ -2617,8 +2626,6 @@ static int DoUpLoad(SOCKET cSkt, TRANSPACKET *Pkt) | ||
2617 | 2626 | SetTaskMsg(MSGJPN107, Pkt->LocalFile); |
2618 | 2627 | iRetCode = 200; |
2619 | 2628 | } |
2620 | - // エラーによってはダイアログが表示されない場合があるバグ対策 | |
2621 | - DispUploadFinishMsg(Pkt, iRetCode); | |
2622 | 2629 | return(iRetCode); |
2623 | 2630 | } |
2624 | 2631 |
@@ -3579,6 +3586,8 @@ static int TermCodeConvAndSend(TERMCODECONVINFO *tInfo, SOCKET Skt, char *Data, | ||
3579 | 3586 | |
3580 | 3587 | static void DispUploadFinishMsg(TRANSPACKET *Pkt, int iRetCode) |
3581 | 3588 | { |
3589 | + // 同時接続対応 | |
3590 | + ReleaseMutex(hListAccMutex); | |
3582 | 3591 | if(ForceAbort == NO) |
3583 | 3592 | { |
3584 | 3593 | if((iRetCode/100) >= FTP_CONTINUE) |
@@ -3738,8 +3747,6 @@ static LRESULT CALLBACK TransDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM | ||
3738 | 3747 | // if(!(Pkt = (TRANSPACKET*)GetWindowLong(hDlg, GWL_USERDATA))) |
3739 | 3748 | if(!(Pkt = (TRANSPACKET*)GetWindowLongPtr(hDlg, GWLP_USERDATA))) |
3740 | 3749 | break; |
3741 | - if(Canceled[Pkt->ThreadCount] == YES) | |
3742 | - Pkt->Abort = ABORT_USER; | |
3743 | 3750 | DispTransferStatus(hDlg, NO, Pkt); |
3744 | 3751 | SetTimer(hDlg, TIMER_DISPLAY, DISPLAY_TIMING, NULL); |
3745 | 3752 | } |