+-------------------------------------------------------------------
+Mon Jul 23 20:52:26 CEST 2018 - aschnell@suse.com
+
+- fixed logging during shutdown of snapperd to avoid core dumps
+ (bsc#1051922 and others)
+
-------------------------------------------------------------------
Tue May 09 13:52:46 CEST 2017 - aschnell@suse.com
/*
* Copyright (c) [2012-2015] Novell, Inc.
- * Copyright (c) 2016 SUSE LLC
+ * Copyright (c) [2016,2018] SUSE LLC
*
* All Rights Reserved.
*
Snapshots& snapshots = snapper->getSnapshots();
Snapshots::iterator snap = snapshots.find(number);
- if (snap == snapshots.end())
- throw IllegalSnapshotException();
-
- for (unsigned int i = 0; i < use_count; ++i)
- snap->umountFilesystemSnapshot(false);
+ if (snap != snapshots.end())
+ for (unsigned int i = 0; i < use_count; ++i)
+ snap->umountFilesystemSnapshot(false);
}
}
}
delete *it;
+ *it = nullptr;
}
/*
* Copyright (c) [2004-2013] Novell, Inc.
+ * Copyright (c) 2018 SUSE LLC
*
* All Rights Reserved.
*
#include "snapper/AppUtil.h"
+#define LOG_FILENAME "/var/log/snapper.log"
+
+
namespace snapper
{
using namespace std;
- // Use a pointer to avoid a global destructor. Otherwise the Snapper
- // destructor in Factory.cc can be called after when logging does not work
- // anymore. TODO: nicer solution.
- string* filename = new string("/var/log/snapper.log");
+ namespace
+ {
+
+ struct LoggerData
+ {
+ LoggerData() : filename(LOG_FILENAME), mutex() {}
+
+ string filename;
+ boost::mutex mutex;
+ };
+
+
+ // Use pointer to avoid a global destructor. Otherwise other global
+ // destructors using logging can cause errors.
+
+ LoggerData* logger_data = new LoggerData();
+
+ }
+
LogDo log_do = NULL;
LogQuery log_query = NULL;
string prefix = sformat("%s %s libsnapper(%d) %s(%s):%d", datetime(time(0), false, true).c_str(),
ln[level], getpid(), file, func, line);
- static boost::mutex mutex;
-
- boost::lock_guard<boost::mutex> lock(mutex);
+ boost::lock_guard<boost::mutex> lock(logger_data->mutex);
- FILE* f = fopen(filename->c_str(), "ae");
+ FILE* f = fopen(logger_data->filename.c_str(), "ae");
if (f)
{
string tmp = text;
void
initDefaultLogger()
{
- delete filename;
- filename = new string("/var/log/snapper.log");
+ logger_data->filename = LOG_FILENAME;
if (geteuid())
{
{
memset(pwd.pw_passwd, 0, strlen(pwd.pw_passwd));
- delete filename;
- filename = new string(string(pwd.pw_dir) + "/.snapper.log");
+ logger_data->filename = string(pwd.pw_dir) + "/.snapper.log";
}
}