diff options
author | George Hazan <ghazan@miranda.im> | 2019-06-05 21:22:47 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-06-05 21:22:47 +0300 |
commit | c1a478e971db2e9c8836ec6fc2c7a26badaae7d2 (patch) | |
tree | 12df5b7e49f47f2d266fbbcd2a6df3047a1bf353 | |
parent | b515831e79209ee175978d2510a9d44ffe76b272 (diff) |
Db_autobackups: fix for broken dumps on exit if backup process takes too much time
-rw-r--r-- | plugins/Db_autobackups/src/backup.cpp | 13 | ||||
-rw-r--r-- | plugins/Db_autobackups/src/main.cpp | 2 | ||||
-rw-r--r-- | plugins/Db_autobackups/src/stdafx.h | 2 |
3 files changed, 10 insertions, 7 deletions
diff --git a/plugins/Db_autobackups/src/backup.cpp b/plugins/Db_autobackups/src/backup.cpp index 5a175ba098..34b13ca302 100644 --- a/plugins/Db_autobackups/src/backup.cpp +++ b/plugins/Db_autobackups/src/backup.cpp @@ -304,18 +304,21 @@ static void BackupThread(void *backup_filename) mir_free(backup_filename);
}
-void BackupStart(wchar_t *backup_filename)
+void BackupStart(wchar_t *backup_filename, bool bInThread)
{
LONG cur_state = InterlockedCompareExchange(&g_iState, 1, 0);
if (cur_state != 0) { // Backup allready in process.
ShowPopup(TranslateT("Database back up in process..."), TranslateT("Error"), nullptr);
return;
}
-
- wchar_t *tm = mir_wstrdup(backup_filename);
- if (mir_forkthread(BackupThread, tm) == INVALID_HANDLE_VALUE) {
+
+ if (bInThread) {
+ if (mir_forkthread(BackupThread, mir_wstrdup(backup_filename)) == INVALID_HANDLE_VALUE)
+ InterlockedExchange(&g_iState, 0); // Backup done.
+ }
+ else {
+ Backup(backup_filename);
InterlockedExchange(&g_iState, 0); // Backup done.
- mir_free(tm);
}
}
diff --git a/plugins/Db_autobackups/src/main.cpp b/plugins/Db_autobackups/src/main.cpp index 6291f9d0c1..b315b4a9a4 100644 --- a/plugins/Db_autobackups/src/main.cpp +++ b/plugins/Db_autobackups/src/main.cpp @@ -145,7 +145,7 @@ static int PreShutdown(WPARAM, LPARAM) g_plugin.bTerminated = true;
if (g_plugin.backup_types & BT_EXIT)
- BackupStart(nullptr);
+ BackupStart(nullptr, false);
return 0;
}
diff --git a/plugins/Db_autobackups/src/stdafx.h b/plugins/Db_autobackups/src/stdafx.h index 6441129c37..f4dd0be3bc 100644 --- a/plugins/Db_autobackups/src/stdafx.h +++ b/plugins/Db_autobackups/src/stdafx.h @@ -60,7 +60,7 @@ struct CMPlugin : public PLUGIN<CMPlugin> int SetBackupTimer(void);
int OptionsInit(WPARAM wParam, LPARAM lParam);
-void BackupStart(wchar_t *backup_filename);
+void BackupStart(wchar_t *backup_filename, bool bInThread = true);
struct ZipFile
{
|