Subversion Repositories public

Compare Revisions

Regard whitespace Rev 70 → Rev 71

/incron/trunk/incrontab.5
1,4 → 1,4
.TH "incrontab" "5" "0.5.0" "Lukas Jelinek" "incron documentation"
.TH "incrontab" "5" "0.5.1" "Lukas Jelinek" "incron documentation"
.SH "NAME"
incrontab \- tables for driving inotify cron (incron)
.SH "DESCRIPTION"
/incron/trunk/CHANGELOG
1,4 → 1,10
0.5.0
0.5.1 2007-01-28
* lockfile location problems fixed (#0000137)
* lockfile configuration failure fixed (#0000140)
* CRLFs inside LICENCE-GPL changed to LFs (#0000138)
 
 
0.5.0 2007-01-27
* based on inotify-cxx 0.7.1
* bug related to events names fixed (#0000134)
* instance locking (only one instance allowed - also fixes #0000136)
/incron/trunk/appinst.cpp
26,19 → 26,19
 
#include "appinst.h"
 
#ifdef APPINST_LOCK_DIRECTORY
#define LOCKDIR APPINST_LOCK_DIRECTORY
#else
#define LOCKDIR "/tmp"
#endif // APPINST_LOCK_DIRECTORY
 
 
AppInstance::AppInstance(const std::string& rName)
: m_name(rName),
m_fLocked(false)
AppInstance::AppInstance(const std::string& rName, const std::string& rBase)
: m_fLocked(false)
{
std::string base(rBase);
if (base.empty())
base = APPLOCK_BASEDIR;
if (base[base.length()-1] == '/')
m_path = base + rName + ".pid";
else
m_path = base + "/" + rName + ".pid";
}
 
AppInstance::~AppInstance()
48,9 → 48,9
} catch (AppInstException e) {}
}
 
bool AppInstance::DoLock(const char* path)
bool AppInstance::DoLock()
{
int fd = open(path, O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
int fd = open(m_path.c_str(), O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
if (fd != -1) {
FILE* f = fdopen(fd, "w");
if (f == NULL) {
80,13 → 80,11
 
bool AppInstance::Lock()
{
std::string fn = GetLockfile();
for (int i=0; i<100; i++) {
if (DoLock(fn.c_str()))
if (DoLock())
return true;
FILE* f = fopen(fn.c_str(), "r");
FILE* f = fopen(m_path.c_str(), "r");
if (f == NULL) {
if (errno != ENOENT)
throw AppInstException(errno);
114,7 → 112,7
if (errno != ESRCH)
throw AppInstException(errno);
res = unlink(fn.c_str());
res = unlink(m_path.c_str());
if (res != 0 && errno != ENOENT)
throw AppInstException(errno);
}
128,7 → 126,7
if (!m_fLocked)
return;
if (unlink(GetLockfile().c_str()) != 0 && errno != ENOENT)
if (unlink(m_path.c_str()) != 0 && errno != ENOENT)
throw AppInstException(errno);
m_fLocked = false;
139,7 → 137,7
if (m_fLocked)
return true;
FILE* f = fopen(GetLockfile().c_str(), "r");
FILE* f = fopen(m_path.c_str(), "r");
if (f == NULL) {
if (errno == ENOENT)
return false;
167,7 → 165,7
 
bool AppInstance::SendSignal(int iSigNo) const
{
FILE* f = fopen(GetLockfile().c_str(), "r");
FILE* f = fopen(m_path.c_str(), "r");
if (f == NULL) {
if (errno == ENOENT)
return false;
196,7 → 194,3
return ok;
}
 
std::string AppInstance::GetLockfile() const
{
return std::string(LOCKDIR) + "/" + m_name + ".pid";
}
/incron/trunk/icd-main.cpp
298,10 → 298,19
return 0;
}
AppInstance app("incrond");
IncronCfg::Init();
std::string cfg;
if (!AppArgs::GetOption("config", cfg))
cfg = INCRON_CONFIG;
IncronCfg::Load(cfg);
std::string lckdir;
IncronCfg::GetValue("lockfile_dir", lckdir);
std::string lckfile;
IncronCfg::GetValue("lockfile_name", lckfile);
AppInstance app(lckfile, lckdir);
if (AppArgs::ExistsOption("kill")) {
fprintf(stderr, "attempting to terminate a running instance of incrond...\n");
if (app.SendSignal(SIGTERM)) {
322,11 → 331,6
syslog(LOG_NOTICE, "starting service (version %s, built on %s %s)", INCRON_VERSION, __DATE__, __TIME__);
std::string cfg;
if (!AppArgs::GetOption("config", cfg))
cfg = INCRON_CONFIG;
IncronCfg::Load(cfg);
AppArgs::Destroy();
int ret = 0;
/incron/trunk/incrond.8
1,4 → 1,4
.TH "incrond" "8" "0.5.0" "Lukas Jelinek" "incron documentation"
.TH "incrond" "8" "0.5.1" "Lukas Jelinek" "incron documentation"
.SH "NAME"
incrond \- inotify cron (incron) daemon
 
/incron/trunk/appinst.h
25,6 → 25,9
#include <string>
 
 
#define APPLOCK_BASEDIR "/var/run"
 
 
/// Exception class.
/**
* This class provides information about occurred errors.
64,8 → 67,12
/// Constructor.
/**
* \param[in] rName application name
* \param[in] rBase lockfile base directory
*
* \attention If an empty base directory is given it is replaced by
* the default value.
*/
AppInstance(const std::string& rName);
AppInstance(const std::string& rName, const std::string& rBase = APPLOCK_BASEDIR);
/// Destructor.
~AppInstance();
109,12 → 116,10
bool SendSignal(int iSigNo) const;
protected:
bool DoLock(const char* path);
bool DoLock();
 
std::string GetLockfile() const;
private:
std::string m_name;
std::string m_path;
bool m_fLocked;
};
 
/incron/trunk/incron.h
27,7 → 27,7
#define INCRONTAB_NAME "incrontab"
 
/// Application version (release)
#define INCRON_VERSION "0.5.0"
#define INCRON_VERSION "0.5.1"
 
/// Address for sending bugs
#define INCRON_BUG_ADDRESS "<bugs@aiken.cz>"
/incron/trunk/incrontab.1
1,4 → 1,4
.TH "incrontab" "1" "0.5.0" "Lukas Jelinek" "incron documentation"
.TH "incrontab" "1" "0.5.1" "Lukas Jelinek" "incron documentation"
.SH "NAME"
incrontab \- table manipulator for inotify cron (incron)
.SH "SYNOPSIS"