|
From: <ale...@us...> - 2011-05-25 12:59:48
|
Revision: 53011
http://firebird.svn.sourceforge.net/firebird/?rev=53011&view=rev
Author: alexpeshkoff
Date: 2011-05-25 12:59:41 +0000 (Wed, 25 May 2011)
Log Message:
-----------
Frontported fix for CORE-3482: nbackup ctrl-c segfaults and leaves db locked (delta file continues to grow)
Modified Paths:
--------------
firebird/trunk/lang_helpers/gds_codes.ftn
firebird/trunk/lang_helpers/gds_codes.pas
firebird/trunk/src/include/gen/codetext.h
firebird/trunk/src/include/gen/iberror.h
firebird/trunk/src/include/gen/msgs.h
firebird/trunk/src/include/gen/sql_code.h
firebird/trunk/src/include/gen/sql_state.h
firebird/trunk/src/msgs/facilities2.sql
firebird/trunk/src/msgs/messages2.sql
firebird/trunk/src/msgs/system_errors2.sql
firebird/trunk/src/utilities/nbackup/nbackup.cpp
Modified: firebird/trunk/lang_helpers/gds_codes.ftn
===================================================================
--- firebird/trunk/lang_helpers/gds_codes.ftn 2011-05-25 11:50:25 UTC (rev 53010)
+++ firebird/trunk/lang_helpers/gds_codes.ftn 2011-05-25 12:59:41 UTC (rev 53011)
@@ -2274,6 +2274,8 @@
PARAMETER (GDS__nbackup_lostguid_l0bk = 337117251)
INTEGER*4 GDS__nbackup_switchd_parameter
PARAMETER (GDS__nbackup_switchd_parameter = 337117255)
+ INTEGER*4 GDS__nbackup_user_stop
+ PARAMETER (GDS__nbackup_user_stop = 337117257)
INTEGER*4 GDS__trace_conflict_acts
PARAMETER (GDS__trace_conflict_acts = 337182750)
INTEGER*4 GDS__trace_act_notfound
Modified: firebird/trunk/lang_helpers/gds_codes.pas
===================================================================
--- firebird/trunk/lang_helpers/gds_codes.pas 2011-05-25 11:50:25 UTC (rev 53010)
+++ firebird/trunk/lang_helpers/gds_codes.pas 2011-05-25 12:59:41 UTC (rev 53011)
@@ -1144,6 +1144,7 @@
gds_nbackup_err_eofhdr_restdb = 337117250;
gds_nbackup_lostguid_l0bk = 337117251;
gds_nbackup_switchd_parameter = 337117255;
+ gds_nbackup_user_stop = 337117257;
gds_trace_conflict_acts = 337182750;
gds_trace_act_notfound = 337182751;
gds_trace_switch_once = 337182752;
Modified: firebird/trunk/src/include/gen/codetext.h
===================================================================
--- firebird/trunk/src/include/gen/codetext.h 2011-05-25 11:50:25 UTC (rev 53010)
+++ firebird/trunk/src/include/gen/codetext.h 2011-05-25 12:59:41 UTC (rev 53011)
@@ -1133,6 +1133,7 @@
{"nbackup_err_eofhdr_restdb", 337117250},
{"nbackup_lostguid_l0bk", 337117251},
{"nbackup_switchd_parameter", 337117255},
+ {"nbackup_user_stop", 337117257},
{"trace_conflict_acts", 337182750},
{"trace_act_notfound", 337182751},
{"trace_switch_once", 337182752},
Modified: firebird/trunk/src/include/gen/iberror.h
===================================================================
--- firebird/trunk/src/include/gen/iberror.h 2011-05-25 11:50:25 UTC (rev 53010)
+++ firebird/trunk/src/include/gen/iberror.h 2011-05-25 12:59:41 UTC (rev 53011)
@@ -1167,6 +1167,7 @@
const ISC_STATUS isc_nbackup_err_eofhdr_restdb = 337117250L;
const ISC_STATUS isc_nbackup_lostguid_l0bk = 337117251L;
const ISC_STATUS isc_nbackup_switchd_parameter = 337117255L;
+const ISC_STATUS isc_nbackup_user_stop = 337117257L;
const ISC_STATUS isc_trace_conflict_acts = 337182750L;
const ISC_STATUS isc_trace_act_notfound = 337182751L;
const ISC_STATUS isc_trace_switch_once = 337182752L;
@@ -1178,7 +1179,7 @@
const ISC_STATUS isc_trace_switch_param_miss = 337182758L;
const ISC_STATUS isc_trace_param_act_notcompat = 337182759L;
const ISC_STATUS isc_trace_mandatory_switch_miss = 337182760L;
-const ISC_STATUS isc_err_max = 1122;
+const ISC_STATUS isc_err_max = 1123;
#else /* c definitions */
@@ -2315,6 +2316,7 @@
#define isc_nbackup_err_eofhdr_restdb 337117250L
#define isc_nbackup_lostguid_l0bk 337117251L
#define isc_nbackup_switchd_parameter 337117255L
+#define isc_nbackup_user_stop 337117257L
#define isc_trace_conflict_acts 337182750L
#define isc_trace_act_notfound 337182751L
#define isc_trace_switch_once 337182752L
@@ -2326,7 +2328,7 @@
#define isc_trace_switch_param_miss 337182758L
#define isc_trace_param_act_notcompat 337182759L
#define isc_trace_mandatory_switch_miss 337182760L
-#define isc_err_max 1122
+#define isc_err_max 1123
#endif
Modified: firebird/trunk/src/include/gen/msgs.h
===================================================================
--- firebird/trunk/src/include/gen/msgs.h 2011-05-25 11:50:25 UTC (rev 53010)
+++ firebird/trunk/src/include/gen/msgs.h 2011-05-25 12:59:41 UTC (rev 53011)
@@ -1136,6 +1136,7 @@
{337117250, "Unexpected end of file when reading header of restored database file (stage @1)"}, /* nbackup_err_eofhdr_restdb */
{337117251, "Cannot get backup guid clumplet from L0 backup"}, /* nbackup_lostguid_l0bk */
{337117255, "Wrong parameter @1 for switch -D, need ON or OFF"}, /* nbackup_switchd_parameter */
+ {337117257, "Terminated due to user request"}, /* nbackup_user_stop */
{337182750, "conflicting actions \"@1\" and \"@2\" found"}, /* trace_conflict_acts */
{337182751, "action switch not found"}, /* trace_act_notfound */
{337182752, "switch \"@1\" must be set only once"}, /* trace_switch_once */
Modified: firebird/trunk/src/include/gen/sql_code.h
===================================================================
--- firebird/trunk/src/include/gen/sql_code.h 2011-05-25 11:50:25 UTC (rev 53010)
+++ firebird/trunk/src/include/gen/sql_code.h 2011-05-25 12:59:41 UTC (rev 53011)
@@ -1132,6 +1132,7 @@
{337117250, -901}, /* 66 nbackup_err_eofhdr_restdb */
{337117251, -901}, /* 67 nbackup_lostguid_l0bk */
{337117255, -901}, /* 71 nbackup_switchd_parameter */
+ {337117257, -901}, /* 73 nbackup_user_stop */
{337182750, -901}, /* 30 trace_conflict_acts */
{337182751, -901}, /* 31 trace_act_notfound */
{337182752, -901}, /* 32 trace_switch_once */
Modified: firebird/trunk/src/include/gen/sql_state.h
===================================================================
--- firebird/trunk/src/include/gen/sql_state.h 2011-05-25 11:50:25 UTC (rev 53010)
+++ firebird/trunk/src/include/gen/sql_state.h 2011-05-25 12:59:41 UTC (rev 53011)
@@ -1132,6 +1132,7 @@
{337117250, "00000"}, // 66 nbackup_err_eofhdr_restdb
{337117251, "00000"}, // 67 nbackup_lostguid_l0bk
{337117255, "00000"}, // 71 nbackup_switchd_parameter
+ {337117257, "08006"}, // 73 nbackup_user_stop
{337182750, "00000"}, // 30 trace_conflict_acts
{337182751, "00000"}, // 31 trace_act_notfound
{337182752, "00000"}, // 32 trace_switch_once
Modified: firebird/trunk/src/msgs/facilities2.sql
===================================================================
--- firebird/trunk/src/msgs/facilities2.sql 2011-05-25 11:50:25 UTC (rev 53010)
+++ firebird/trunk/src/msgs/facilities2.sql 2011-05-25 12:59:41 UTC (rev 53011)
@@ -35,7 +35,7 @@
('2009-12-26 14:22:00', 'GSTAT', 21, 50)
('2009-12-18 19:33:34', 'FBSVCMGR', 22, 57)
('2009-07-18 12:12:12', 'UTL', 23, 2)
-('2009-12-19 06:19:15', 'NBACKUP', 24, 73)
+('2011-05-25 16:17:34', 'NBACKUP', 24, 74)
('2009-07-20 07:55:48', 'FBTRACEMGR', 25, 41)
stop
Modified: firebird/trunk/src/msgs/messages2.sql
===================================================================
--- firebird/trunk/src/msgs/messages2.sql 2011-05-25 11:50:25 UTC (rev 53010)
+++ firebird/trunk/src/msgs/messages2.sql 2011-05-25 12:59:41 UTC (rev 53011)
@@ -3147,6 +3147,7 @@
(NULL, 'usage', 'nbackup.cpp', NULL, 24, 70, NULL, ' -D(IRECT) [ON | OFF] Use or not direct I/O when backing up database', NULL, NULL)
('nbackup_switchd_parameter', 'main', 'nbackup.cpp', NULL, 24, 71, NULL, 'Wrong parameter @1 for switch -D, need ON or OFF', NULL, NULL)
(NULL, 'usage', 'nbackup.cpp', NULL, 24, 72, NULL, 'special options are:', NULL, NULL)
+('nbackup_user_stop', 'checkCtrlC()', 'nbackup.cpp', NULL, 24, 73, NULL, 'Terminated due to user request', NULL, NULL)
-- FBTRACEMGR
-- All messages use the new format.
(NULL, 'usage', 'TraceCmdLine.cpp', NULL, 25, 1, NULL, 'Firebird Trace Manager version @1', NULL, NULL)
Modified: firebird/trunk/src/msgs/system_errors2.sql
===================================================================
--- firebird/trunk/src/msgs/system_errors2.sql 2011-05-25 11:50:25 UTC (rev 53010)
+++ firebird/trunk/src/msgs/system_errors2.sql 2011-05-25 12:59:41 UTC (rev 53011)
@@ -1130,6 +1130,7 @@
(-901, '00', '000', 24, 66, 'nbackup_err_eofhdr_restdb', NULL, NULL)
(-901, '00', '000', 24, 67, 'nbackup_lostguid_l0bk', NULL, NULL)
(-901, '00', '000', 24, 71, 'nbackup_switchd_parameter', NULL, NULL)
+(-901, '08', '006', 24, 73, 'nbackup_user_stop', NULL, NULL)
-- FBTRACEMGR
(-901, '00', '000', 25, 30, 'trace_conflict_acts', NULL, NULL)
(-901, '00', '000', 25, 31, 'trace_act_notfound', NULL, NULL)
Modified: firebird/trunk/src/utilities/nbackup/nbackup.cpp
===================================================================
--- firebird/trunk/src/utilities/nbackup/nbackup.cpp 2011-05-25 11:50:25 UTC (rev 53010)
+++ firebird/trunk/src/utilities/nbackup/nbackup.cpp 2011-05-25 12:59:41 UTC (rev 53011)
@@ -212,10 +212,30 @@
}
#endif // HAVE_POSIX_FADVISE
+ bool flShutdown = false;
+
+ int nbackupShutdown(const int reason, const int, void*)
+ {
+ if (reason == fb_shutrsn_signal)
+ {
+ flShutdown = true;
+ return FB_FAILURE;
+ }
+ return FB_SUCCESS;
+ }
+
} // namespace
+static void checkCtrlC(UtilSvc* uSvc)
+{
+ if (flShutdown)
+ {
+ Arg::Gds(isc_nbackup_user_stop).raise();
+ }
+}
+
#ifdef WIN_NT
#define FILE_HANDLE HANDLE
#else
@@ -261,6 +281,15 @@
if (!ResolveDatabaseAlias(db, dbname, NULL))
dbname = db;
+
+ if (!uSvc->isService())
+ {
+ // It's time to take care about shutdown handling
+ if (fb_shutdown_callback(status, nbackupShutdown, fb_shut_confirmation, NULL))
+ {
+ pr_error(status, "setting shutdown callback");
+ }
+ }
}
typedef ObjectsArray<PathName> BackupFiles;
@@ -960,6 +989,8 @@
page_writes++;
}
+ checkCtrlC(uSvc);
+
if ((db_size_pages != 0) && (db_size == 0))
break;
@@ -1241,6 +1272,7 @@
}
seek_file(dbase, ((SINT64) pageNum) * bakheader.page_size);
write_file(dbase, page_buffer, bakheader.page_size);
+ checkCtrlC(uSvc);
}
delete_database = false;
}
@@ -1252,6 +1284,7 @@
status_exception::raise(Arg::Gds(isc_nbackup_err_copy) <<
dbname.c_str() << bakname.c_str() << Arg::OsError());
}
+ checkCtrlC(uSvc);
delete_database = true; // database is possibly broken
open_database_write();
#else
@@ -1263,6 +1296,7 @@
if (bytesRead == 0)
break;
write_file(dbase, buffer, bytesRead);
+ checkCtrlC(uSvc);
}
seek_file(dbase, 0);
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|