Skip to content

Commit

Permalink
Backported CORE-6009: I/O error during "open" operation for file "/tm…
Browse files Browse the repository at this point in the history
…p/firebird/fb_trace_*" in firebird.log
  • Loading branch information
AlexPeshkoff committed Feb 22, 2019
1 parent f109188 commit 8e55180
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 8 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Expand Up @@ -823,7 +823,7 @@ dnl HP-UX atomic routines are in atomic library, not standard C library.
dnl If we can't find atomic routines in vendor library, look for atomic_ops.
AC_SEARCH_LIBS(atomic_inc, atomic,,
AC_CHECK_LIB(atomic_ops, main))

AC_CHECK_HEADERS(utime.h)

dnl Check for libraries for static C++ runtime linking
AC_CHECK_LIB(supc++, main, XE_APPEND(-lsupc++, STATIC_CXXSUPPORT_LIB))
Expand Down
5 changes: 5 additions & 0 deletions src/common/os/posix/os_utils.cpp
Expand Up @@ -73,6 +73,10 @@
#include <sys/signal.h>
#endif

#ifdef HAVE_UTIME_H
#include <utime.h>
#endif

using namespace Firebird;

namespace os_utils
Expand Down Expand Up @@ -237,6 +241,7 @@ bool touchFile(const char* pathname)

return true;
#else
errno = ENOSYS;
return false;
#endif
}
Expand Down
39 changes: 33 additions & 6 deletions src/jrd/trace/TraceConfigStorage.cpp
Expand Up @@ -29,6 +29,7 @@

#include "../../common/classes/TempFile.h"
#include "../../common/StatusArg.h"
#include "../../common/ScanDir.h"
#include "../../common/utils_proto.h"
#include "../../jrd/err_proto.h"
#include "../../common/isc_proto.h"
Expand Down Expand Up @@ -58,7 +59,7 @@ using namespace Firebird;

namespace Jrd {

static const FB_UINT64 TOUCH_INTERVAL = 60 * 60; // in seconds, one hour should be enough
static const FB_UINT64 TOUCH_INTERVAL = 60 * 60; // in seconds, one hour should be enough

void checkFileError(const char* filename, const char* operation, ISC_STATUS iscError)
{
Expand Down Expand Up @@ -588,15 +589,41 @@ bool ConfigStorage::getItemLength(ITEM& tag, ULONG& len)

void ConfigStorage::TouchFile::handler()
{
os_utils::touchFile(fileName);
FbLocalStatus s;
TimerInterfacePtr()->start(&s, this, TOUCH_INTERVAL * 1000 * 1000);
// ignore error in handler
try
{
ScanDir dir(dirName.c_str(), "*");
while (dir.next())
{
PathName cur(dir.getFilePath());
if (cur == "." || cur == "..")
continue;

try
{
if (!os_utils::touchFile(cur.c_str()))
system_call_failed::raise("utime");
}
catch (const Exception& e)
{
iscLogException("touchFile", e);
}
}

FbLocalStatus s;
TimerInterfacePtr()->start(&s, this, TOUCH_INTERVAL * 1000 * 1000);
s.check();
}
catch (const Exception& e)
{
iscLogException("Start TouchFile timer failed", e);
}
}

void ConfigStorage::TouchFile::start(const char* fName)
{
fileName = fName;
PathName dummy;
PathUtils::splitLastComponent(dirName, dummy, fName);

FbLocalStatus s;
TimerInterfacePtr()->start(&s, this, TOUCH_INTERVAL * 1000 * 1000);
check(&s);
Expand Down
6 changes: 5 additions & 1 deletion src/jrd/trace/TraceConfigStorage.h
Expand Up @@ -78,12 +78,16 @@ class ConfigStorage FB_FINAL : public Firebird::GlobalStorage, public Firebird::
public Firebird::RefCntIface<Firebird::ITimerImpl<TouchFile, Firebird::CheckStatusWrapper> >
{
public:
TouchFile()
: dirName(getPool())
{ }
void handler();
void start(const char* fName);
void stop();
int release();

private:
const char* fileName;
Firebird::PathName dirName;
};
Firebird::RefPtr<TouchFile> m_timer;

Expand Down

0 comments on commit 8e55180

Please sign in to comment.