|
From: <ale...@us...> - 2014-06-30 11:46:29
|
Revision: 59796
http://sourceforge.net/p/firebird/code/59796
Author: alexpeshkoff
Date: 2014-06-30 11:46:26 +0000 (Mon, 30 Jun 2014)
Log Message:
-----------
Backported fix for CORE-4475: attempt to create lock files directory fails during cleanup
Modified Paths:
--------------
firebird/branches/B2_5_Release/builds/posix/Makefile.in.client.gfix
firebird/branches/B2_5_Release/builds/posix/Makefile.in.client.util
firebird/branches/B2_5_Release/builds/posix/Makefile.in.embed.gfix
firebird/branches/B2_5_Release/builds/posix/Makefile.in.embed.util
firebird/branches/B2_5_Release/builds/posix/prefix.aix_powerpc_xlc
firebird/branches/B2_5_Release/src/jrd/gds.cpp
firebird/branches/B2_5_Release/src/jrd/isc.cpp
firebird/branches/B2_5_Release/src/jrd/isc_proto.h
firebird/branches/B2_5_Release/src/jrd/isc_sync.cpp
firebird/branches/B2_5_Release/src/jrd/svc.cpp
firebird/branches/B2_5_Release/src/jrd/trace/TraceConfigStorage.cpp
firebird/branches/B2_5_Release/src/jrd/trace/TraceLog.cpp
Modified: firebird/branches/B2_5_Release/builds/posix/Makefile.in.client.gfix
===================================================================
--- firebird/branches/B2_5_Release/builds/posix/Makefile.in.client.gfix 2014-06-30 11:45:53 UTC (rev 59795)
+++ firebird/branches/B2_5_Release/builds/posix/Makefile.in.client.gfix 2014-06-30 11:46:26 UTC (rev 59796)
@@ -39,7 +39,8 @@
@SET_MAKE@
-GFIX_Other_Sources = jrd/isc.cpp jrd/ThreadData.cpp jrd/path_utils.cpp common/UtilSvc.cpp
+GFIX_Other_Sources = jrd/isc.cpp jrd/ThreadData.cpp jrd/path_utils.cpp common/UtilSvc.cpp \
+ $(OS_SPECIFIC_Sources)
GFIX_Files = alice_meta.epp alice.cpp exe.cpp tdr.cpp aliceMain.cpp
GFIX_Sources = $(addprefix alice/, $(GFIX_Files)) $(GFIX_Other_Sources)
Modified: firebird/branches/B2_5_Release/builds/posix/Makefile.in.client.util
===================================================================
--- firebird/branches/B2_5_Release/builds/posix/Makefile.in.client.util 2014-06-30 11:45:53 UTC (rev 59795)
+++ firebird/branches/B2_5_Release/builds/posix/Makefile.in.client.util 2014-06-30 11:46:26 UTC (rev 59796)
@@ -90,7 +90,7 @@
$(FBCLASSES_MsgObjects) $(CLUMPLETS_Objects) $(FBCOMMON_ClientObjects)
-FBGUARD_Other_Sources = jrd/isc.cpp jrd/divorce.cpp jrd/path_utils.cpp
+FBGUARD_Other_Sources = jrd/isc.cpp jrd/divorce.cpp jrd/path_utils.cpp $(OS_SPECIFIC_Sources)
FBGUARD_Files = guard.cpp util.cpp
FBGUARD_Sources = $(addprefix utilities/guard/, $(FBGUARD_Files)) $(FBGUARD_Other_Sources)
FBGUARD_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBGUARD_Sources)))) $(FBCLASSES_ClientObjects)
Modified: firebird/branches/B2_5_Release/builds/posix/Makefile.in.embed.gfix
===================================================================
--- firebird/branches/B2_5_Release/builds/posix/Makefile.in.embed.gfix 2014-06-30 11:45:53 UTC (rev 59795)
+++ firebird/branches/B2_5_Release/builds/posix/Makefile.in.embed.gfix 2014-06-30 11:46:26 UTC (rev 59796)
@@ -42,7 +42,8 @@
GFIX_Files = alice_meta.epp \
alice.cpp exe.cpp tdr.cpp aliceMain.cpp
-GFIX_Other_Sources += jrd/isc.cpp jrd/ThreadData.cpp jrd/path_utils.cpp common/UtilSvc.cpp
+GFIX_Other_Sources += jrd/isc.cpp jrd/ThreadData.cpp jrd/path_utils.cpp common/UtilSvc.cpp \
+ $(OS_SPECIFIC_Sources)
GFIX_Sources = $(addprefix alice/, $(GFIX_Files)) $(GFIX_Other_Sources)
GFIX_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(GFIX_Sources))))
Modified: firebird/branches/B2_5_Release/builds/posix/Makefile.in.embed.util
===================================================================
--- firebird/branches/B2_5_Release/builds/posix/Makefile.in.embed.util 2014-06-30 11:45:53 UTC (rev 59795)
+++ firebird/branches/B2_5_Release/builds/posix/Makefile.in.embed.util 2014-06-30 11:46:26 UTC (rev 59796)
@@ -103,7 +103,7 @@
$(FBCLASSES_MsgObjects) $(CLUMPLETS_Objects) $(FBCOMMON_ClientObjects)
-FBGUARD_Other_Sources = jrd/isc.cpp jrd/divorce.cpp jrd/path_utils.cpp
+FBGUARD_Other_Sources = jrd/isc.cpp jrd/divorce.cpp jrd/path_utils.cpp $(OS_SPECIFIC_Sources)
FBGUARD_Files = guard.cpp util.cpp
FBGUARD_Sources = $(addprefix utilities/guard/, $(FBGUARD_Files)) $(FBGUARD_Other_Sources)
FBGUARD_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBGUARD_Sources)))) $(FBCLASSES_ClientObjects)
Modified: firebird/branches/B2_5_Release/builds/posix/prefix.aix_powerpc_xlc
===================================================================
--- firebird/branches/B2_5_Release/builds/posix/prefix.aix_powerpc_xlc 2014-06-30 11:45:53 UTC (rev 59795)
+++ firebird/branches/B2_5_Release/builds/posix/prefix.aix_powerpc_xlc 2014-06-30 11:46:26 UTC (rev 59796)
@@ -118,7 +118,7 @@
common/classes/MsgPrint.cpp common/classes/SafeArg.cpp \
common/classes/BaseStream.cpp common/classes/fb_string.cpp \
common/classes/TempFile.cpp \
- jrd/gds.cpp jrd/isc.cpp \
+ jrd/gds.cpp jrd/isc.cpp $(OS_SPECIFIC_Sources)\
jrd/os/posix/path_utils.cpp jrd/os/posix/os_utils.cpp \
jrd/os/posix/config_root.cpp jrd/os/posix/fbsyslog.cpp
Modified: firebird/branches/B2_5_Release/src/jrd/gds.cpp
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/gds.cpp 2014-06-30 11:45:53 UTC (rev 59795)
+++ firebird/branches/B2_5_Release/src/jrd/gds.cpp 2014-06-30 11:46:26 UTC (rev 59796)
@@ -202,8 +202,6 @@
static void sanitize(Firebird::string& locale);
-static void safe_concat_path(TEXT* destbuf, const TEXT* srcbuf);
-
// New functions that try to be safe.
static SLONG safe_interpret(char* const s, const size_t bufsize,
const ISC_STATUS** const vector, bool legacy = false);
@@ -1736,7 +1734,7 @@
GDS_init_prefix();
strcpy(resultString, fb_prefix); // safe - no BO
- safe_concat_path(resultString, file);
+ iscSafeConcatPath(resultString, file);
}
@@ -1757,12 +1755,7 @@
GDS_init_prefix();
strcpy(string, fb_prefix_lock); // safe - no BO
-
- // if someone wants to know prefix for lock files,
- // sooner of all he wants that directory to exist
- os_utils::createLockDirectory(string);
-
- safe_concat_path(string, root);
+ iscSafeConcatPath(string, root);
}
@@ -1786,7 +1779,7 @@
GDS_init_prefix();
strcpy(string, fb_prefix_msg); // safe - no BO
- safe_concat_path(string, root);
+ iscSafeConcatPath(string, root);
}
@@ -3555,44 +3548,7 @@
}
}
-static void safe_concat_path(TEXT *resultString, const TEXT *appendString)
-{
-/**************************************
- *
- * s a f e _ c o n c a t _ p a t h
- *
- **************************************
- *
- * Functional description
- * Safely appends appendString to resultString using paths rules.
- * resultString must be at most MAXPATHLEN size.
- * Thread/signal safe code.
- *
- **************************************/
- size_t len = strlen(resultString);
- fb_assert(len > 0);
- if (resultString[len - 1] != PathUtils::dir_sep && len < MAXPATHLEN - 1)
- {
- resultString[len++] = PathUtils::dir_sep;
- resultString[len] = 0;
- }
-
- size_t alen = strlen(appendString);
- if (len + alen > MAXPATHLEN - 1)
- {
- alen = MAXPATHLEN - 1 - len;
- }
-
- fb_assert(len < MAXPATHLEN);
- fb_assert(alen < MAXPATHLEN);
- fb_assert(len + alen < MAXPATHLEN);
-
- memcpy(&resultString[len], appendString, alen);
- resultString[len + alen] = 0;
-}
-
-
void FB_EXPORTED gds__default_printer(void* /*arg*/, SSHORT offset, const TEXT* line)
{
printf("%4d %s\n", offset, line);
Modified: firebird/branches/B2_5_Release/src/jrd/isc.cpp
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/isc.cpp 2014-06-30 11:45:53 UTC (rev 59795)
+++ firebird/branches/B2_5_Release/src/jrd/isc.cpp 2014-06-30 11:46:26 UTC (rev 59796)
@@ -48,6 +48,8 @@
#include "../jrd/gds_proto.h"
#include "../jrd/isc_proto.h"
#include "../jrd/jrd_proto.h"
+#include "../jrd/os/os_utils.h"
+#include "../jrd/os/path_utils.h"
#include "../common/classes/init.h"
@@ -632,3 +634,61 @@
iscLogStatus(text, s);
}
+
+void iscPrefixLock(TEXT* string, const TEXT* root, bool createLockDir)
+{
+/**************************************
+ *
+ * i s c P r e f i x L o c k
+ *
+ **************************************
+ *
+ * Functional description
+ * Find appropriate Firebird lock file prefix.
+ *
+ **************************************/
+ gds__prefix_lock(string, "");
+
+ if (createLockDir)
+ os_utils::createLockDirectory(string);
+
+ iscSafeConcatPath(string, root);
+}
+
+
+void iscSafeConcatPath(TEXT *resultString, const TEXT *appendString)
+{
+/**************************************
+ *
+ * i s c S a f e C o n c a t P a t h
+ *
+ **************************************
+ *
+ * Functional description
+ * Safely appends appendString to resultString using paths rules.
+ * resultString must be at most MAXPATHLEN size.
+ * Thread/signal safe code.
+ *
+ **************************************/
+ size_t len = strlen(resultString);
+ fb_assert(len > 0);
+
+ if (resultString[len - 1] != PathUtils::dir_sep && len < MAXPATHLEN - 1)
+ {
+ resultString[len++] = PathUtils::dir_sep;
+ resultString[len] = 0;
+ }
+
+ size_t alen = strlen(appendString);
+ if (len + alen > MAXPATHLEN - 1)
+ {
+ alen = MAXPATHLEN - 1 - len;
+ }
+
+ fb_assert(len < MAXPATHLEN);
+ fb_assert(alen < MAXPATHLEN);
+ fb_assert(len + alen < MAXPATHLEN);
+
+ memcpy(&resultString[len], appendString, alen);
+ resultString[len + alen] = 0;
+}
Modified: firebird/branches/B2_5_Release/src/jrd/isc_proto.h
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/isc_proto.h 2014-06-30 11:45:53 UTC (rev 59795)
+++ firebird/branches/B2_5_Release/src/jrd/isc_proto.h 2014-06-30 11:46:26 UTC (rev 59796)
@@ -44,4 +44,7 @@
struct _SECURITY_ATTRIBUTES* ISC_get_security_desc();
#endif
+void iscPrefixLock(TEXT* string, const TEXT* root, bool createLockDir);
+void iscSafeConcatPath(TEXT *resultString, const TEXT *appendString);
+
#endif // JRD_ISC_PROTO_H
Modified: firebird/branches/B2_5_Release/src/jrd/isc_sync.cpp
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/isc_sync.cpp 2014-06-30 11:45:53 UTC (rev 59795)
+++ firebird/branches/B2_5_Release/src/jrd/isc_sync.cpp 2014-06-30 11:46:26 UTC (rev 59796)
@@ -2293,7 +2293,7 @@
{
#ifndef WIN_NT
TEXT expanded_filename[MAXPATHLEN];
- gds__prefix_lock(expanded_filename, filename);
+ iscPrefixLock(expanded_filename, filename, false);
// We can't do much (specially in dtors) when it fails
// therefore do not check for errors - at least it's just /tmp.
@@ -2329,7 +2329,7 @@
**************************************/
TEXT expanded_filename[MAXPATHLEN];
- gds__prefix_lock(expanded_filename, filename);
+ iscPrefixLock(expanded_filename, filename, true);
/* make the complete filename for the init file this file is to be used as a
master lock to eliminate possible race conditions with just a single file
@@ -2337,7 +2337,7 @@
lock to a LCK_SHARED lock is not atomic*/
TEXT init_filename[MAXPATHLEN];
- gds__prefix_lock(init_filename, INIT_FILE);
+ iscPrefixLock(init_filename, INIT_FILE, true);
const bool trunc_flag = (length != 0);
@@ -2370,7 +2370,7 @@
if (fdSem < 0)
{
TEXT sem_filename[MAXPATHLEN];
- gds__prefix_lock(sem_filename, SEM_FILE);
+ iscPrefixLock(sem_filename, SEM_FILE, true);
const int f = openFile(sem_filename);
if (f == -1)
{
@@ -2551,7 +2551,7 @@
int retry_count = 0;
TEXT expanded_filename[MAXPATHLEN];
- gds__prefix_lock(expanded_filename, filename);
+ iscPrefixLock(expanded_filename, filename, true);
const bool trunc_flag = (length != 0);
bool init_flag = false;
@@ -4189,7 +4189,7 @@
CloseHandle(shmem_data->sh_mem_hdr_object);
TEXT expanded_filename[MAXPATHLEN];
- gds__prefix_lock(expanded_filename, shmem_data->sh_mem_name);
+ iscPrefixLock(expanded_filename, shmem_data->sh_mem_name, false);
// Delete file only if it is not used by anyone else
HANDLE hFile = CreateFile(expanded_filename,
Modified: firebird/branches/B2_5_Release/src/jrd/svc.cpp
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/svc.cpp 2014-06-30 11:45:53 UTC (rev 59795)
+++ firebird/branches/B2_5_Release/src/jrd/svc.cpp 2014-06-30 11:46:26 UTC (rev 59796)
@@ -1329,7 +1329,7 @@
gds__prefix(auxBuf, "");
break;
case isc_info_svc_get_env_lock:
- gds__prefix_lock(auxBuf, "");
+ iscPrefixLock(auxBuf, "", false);
break;
case isc_info_svc_get_env_msg:
gds__prefix_msg(auxBuf, "");
@@ -1813,7 +1813,7 @@
gds__prefix(PathBuffer, "");
break;
case isc_info_svc_get_env_lock:
- gds__prefix_lock(PathBuffer, "");
+ iscPrefixLock(PathBuffer, "", false);
break;
case isc_info_svc_get_env_msg:
gds__prefix_msg(PathBuffer, "");
Modified: firebird/branches/B2_5_Release/src/jrd/trace/TraceConfigStorage.cpp
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/trace/TraceConfigStorage.cpp 2014-06-30 11:45:53 UTC (rev 59795)
+++ firebird/branches/B2_5_Release/src/jrd/trace/TraceConfigStorage.cpp 2014-06-30 11:46:26 UTC (rev 59796)
@@ -236,7 +236,7 @@
fb_assert(m_base->cnt_uses == 0);
char dir[MAXPATHLEN];
- gds__prefix_lock(dir, "");
+ iscPrefixLock(dir, "", true);
PathName filename = TempFile::create("fb_trace_", dir);
filename.copyTo(cfg_file_name, sizeof(m_base->cfg_file_name));
Modified: firebird/branches/B2_5_Release/src/jrd/trace/TraceLog.cpp
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/trace/TraceLog.cpp 2014-06-30 11:45:53 UTC (rev 59795)
+++ firebird/branches/B2_5_Release/src/jrd/trace/TraceLog.cpp 2014-06-30 11:46:26 UTC (rev 59796)
@@ -70,7 +70,7 @@
}
char dir[MAXPATHLEN];
- gds__prefix_lock(dir, "");
+ iscPrefixLock(dir, "", true);
PathUtils::concatPath(m_baseFileName, dir, fileName);
TraceLogGuard guard(this);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|