OSDN Git Service

Fix bugs of asyncronous socket control.
authors_kawamoto <s_kawamoto@users.sourceforge.jp>
Sat, 15 Oct 2011 07:22:08 +0000 (16:22 +0900)
committers_kawamoto <s_kawamoto@users.sourceforge.jp>
Sat, 15 Oct 2011 07:22:08 +0000 (16:22 +0900)
Fix bugs of deadlock around file deletion.
Adjust performance of simultaneous connection.
Fix bugs of UI for Kanji code of filenames.
Change handling timestamp that do not include year.
This version may be nearly stable (not for 1.99 but for 1.98b).

FFFTP_Eng_Release/FFFTP.exe
Release/FFFTP.exe
Resource_eng/FFFTP-eng.rc
filelist.c
ftpproc.c
getput.c
socket.c

index deaf886..d34dded 100644 (file)
Binary files a/FFFTP_Eng_Release/FFFTP.exe and b/FFFTP_Eng_Release/FFFTP.exe differ
index f8cb214..927d1ea 100644 (file)
Binary files a/Release/FFFTP.exe and b/Release/FFFTP.exe differ
index 13d2662..37c2411 100644 (file)
@@ -741,8 +741,8 @@ BEGIN
     CONTROL         "UTF-8",HSET_UTF8N_CNV,"Button",BS_AUTORADIOBUTTON,12,69,41,10\r
     CONTROL         "Hankaku to Zenkaku",HSET_HANCNV,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,12,96,90,10\r
     GROUPBOX        "&Filename Kanji Code",-1,107,7,97,116,WS_GROUP\r
-    CONTROL         "Automatic",HSET_FN_AUTO_CNV,"Button",BS_AUTORADIOBUTTON | WS_GROUP,114,21,65,10\r
-    CONTROL         "Shift_JIS",HSET_FN_SJIS_CNV,"Button",BS_AUTORADIOBUTTON | WS_GROUP,111,33,65,10\r
+    CONTROL         "Automatic",HSET_FN_AUTO_CNV,"Button",BS_AUTORADIOBUTTON | WS_GROUP,111,21,65,10\r
+    CONTROL         "Shift_JIS",HSET_FN_SJIS_CNV,"Button",BS_AUTORADIOBUTTON,111,33,65,10\r
     CONTROL         "JIS",HSET_FN_JIS_CNV,"Button",BS_AUTORADIOBUTTON,111,45,70,10\r
     CONTROL         "EUC",HSET_FN_EUC_CNV,"Button",BS_AUTORADIOBUTTON,111,57,41,10\r
     CONTROL         "Samba-HEX",HSET_FN_SMH_CNV,"Button",BS_AUTORADIOBUTTON,111,69,66,10\r
index 74d943c..65263b1 100644 (file)
@@ -4771,9 +4771,11 @@ static int ResolvFileInfo(char *Str, int ListType, char *Fname, LONGLONG *Size,
 \r
                                                /* 年がない */\r
                                                /* 現在の日付から推定 */\r
-                                               if((sTimeNow.wMonth == 12) && (sTime.wMonth == 1))\r
-                                                       sTime.wYear++;\r
-                                               else if(sTimeNow.wMonth+1 == sTime.wMonth)\r
+                                               // 恐らくホストとローカルの時刻が異なる場合の対処のようだがとりあえず無効にする\r
+//                                             if((sTimeNow.wMonth == 12) && (sTime.wMonth == 1))\r
+//                                                     sTime.wYear++;\r
+//                                             else if(sTimeNow.wMonth+1 == sTime.wMonth)\r
+                                               if(sTimeNow.wMonth+1 == sTime.wMonth)\r
                                                        /* nothing */;\r
                                                else if(sTimeNow.wMonth < sTime.wMonth)\r
                                                        sTime.wYear--;\r
index 7fdef82..09a5263 100644 (file)
--- a/ftpproc.c
+++ b/ftpproc.c
@@ -1960,6 +1960,8 @@ void DeleteProc(void)
        char CurDir[FMAX_PATH+1];\r
        char Tmp[FMAX_PATH+1];\r
 \r
+       // デッドロック対策\r
+       DisableUserOpe();\r
        Sts = YES;\r
        AskRemoteCurDir(CurDir, FMAX_PATH);\r
        FileListBase = NULL;\r
@@ -1979,7 +1981,8 @@ void DeleteProc(void)
 \r
        if(Sts == YES)\r
        {\r
-               DisableUserOpe();\r
+               // デッドロック対策\r
+//             DisableUserOpe();\r
 \r
                DelFlg = NO;\r
                Sts = NO;\r
@@ -2015,8 +2018,11 @@ void DeleteProc(void)
                                GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
                }\r
 \r
-               EnableUserOpe();\r
+               // デッドロック対策\r
+//             EnableUserOpe();\r
        }\r
+       // デッドロック対策\r
+       EnableUserOpe();\r
        return;\r
 }\r
 \r
index 1a0b271..8526053 100644 (file)
--- a/getput.c
+++ b/getput.c
@@ -143,6 +143,9 @@ static int MoveToForeground = NO;           /* ウインドウを前面に移動するか
 static char CurDir[FMAX_PATH+1] = { "" };\r
 static char ErrMsg[ERR_MSG_LEN+7];\r
 \r
+// 同時接続対応\r
+static int WaitForMainThread = NO;\r
+\r
 /*===== 外部参照 =====*/\r
 \r
 /* 設定値 */\r
@@ -362,6 +365,7 @@ void AddTransFileList(TRANSPACKET *Pkt)
 //     WaitForSingleObject(hListAccMutex, INFINITE);\r
        while(WaitForSingleObject(hListAccMutex, 0) == WAIT_TIMEOUT)\r
        {\r
+               WaitForMainThread = YES;\r
                BackgrndMessageProc();\r
                Sleep(1);\r
        }\r
@@ -379,6 +383,8 @@ void AddTransFileList(TRANSPACKET *Pkt)
        if(NextTransPacketBase == NULL)\r
                NextTransPacketBase = TransPacketBase;\r
        ReleaseMutex(hListAccMutex);\r
+       // 同時接続対応\r
+       WaitForMainThread = NO;\r
 \r
        return;\r
 }\r
@@ -405,6 +411,7 @@ void AppendTransFileList(TRANSPACKET *Pkt)
 //     WaitForSingleObject(hListAccMutex, INFINITE);\r
        while(WaitForSingleObject(hListAccMutex, 0) == WAIT_TIMEOUT)\r
        {\r
+               WaitForMainThread = YES;\r
                BackgrndMessageProc();\r
                Sleep(1);\r
        }\r
@@ -436,6 +443,8 @@ void AppendTransFileList(TRANSPACKET *Pkt)
        }\r
 \r
        ReleaseMutex(hListAccMutex);\r
+       // 同時接続対応\r
+       WaitForMainThread = NO;\r
        return;\r
 }\r
 \r
@@ -492,6 +501,7 @@ static void EraseTransFileList(void)
 //     WaitForSingleObject(hListAccMutex, INFINITE);\r
        while(WaitForSingleObject(hListAccMutex, 0) == WAIT_TIMEOUT)\r
        {\r
+               WaitForMainThread = YES;\r
                BackgrndMessageProc();\r
                Sleep(1);\r
        }\r
@@ -525,6 +535,8 @@ static void EraseTransFileList(void)
        TransFiles = 0;\r
        PostMessage(GetMainHwnd(), WM_CHANGE_COND, 0, 0);\r
        ReleaseMutex(hListAccMutex);\r
+       // 同時接続対応\r
+       WaitForMainThread = NO;\r
 \r
        strcpy(Pkt.Cmd, "GOQUIT");\r
        AddTransFileList(&Pkt);\r
@@ -649,6 +661,7 @@ static ULONG WINAPI TransferThread(void *Dummy)
        CmdSkt = INVALID_SOCKET;\r
        NewCmdSkt = INVALID_SOCKET;\r
        TrnSkt = INVALID_SOCKET;\r
+       SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_LOWEST);\r
 \r
        while((TransPacketBase != NULL) ||\r
                  (WaitForSingleObject(hRunMutex, 200) == WAIT_TIMEOUT))\r
@@ -656,6 +669,13 @@ static ULONG WINAPI TransferThread(void *Dummy)
                if(fTransferThreadExit == TRUE)\r
                        break;\r
 \r
+               if(WaitForMainThread == YES)\r
+               {\r
+                       BackgrndMessageProc();\r
+                       Sleep(100);\r
+                       continue;\r
+               }\r
+\r
 //             WaitForSingleObject(hListAccMutex, INFINITE);\r
                while(WaitForSingleObject(hListAccMutex, 0) == WAIT_TIMEOUT)\r
                {\r
@@ -1089,7 +1109,8 @@ static ULONG WINAPI TransferThread(void *Dummy)
                                }\r
                        }\r
                        BackgrndMessageProc();\r
-                       Sleep(1);\r
+//                     Sleep(1);\r
+                       Sleep(100);\r
 \r
                        if(GoExit == YES)\r
                        {\r
@@ -1116,7 +1137,10 @@ static ULONG WINAPI TransferThread(void *Dummy)
                                hWndTrans = NULL;\r
                        }\r
                        BackgrndMessageProc();\r
-                       Sleep(1);\r
+                       if(ThreadCount < AskMaxThreadCount())\r
+                               Sleep(1);\r
+                       else\r
+                               Sleep(100);\r
                }\r
        }\r
        if(TrnSkt != INVALID_SOCKET)\r
index 86dac35..b3d4163 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -484,8 +484,8 @@ static int RegistAsyncTable(SOCKET s)
                {\r
                        // 強制的に閉じられたソケットがあると重複する可能性あり\r
 //                     MessageBox(GetMainHwnd(), "Async socket already registerd.", "FFFTP inner error", MB_OK);\r
+//                     break;\r
                        Signal[Pos].Socket = INVALID_SOCKET;\r
-                       break;\r
                }\r
        }\r
        // スレッド衝突のバグ修正\r