diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2011-01-17 17:41:59 +0100 |
---|---|---|
committer | Denys Vlasenko <dvlasenk@redhat.com> | 2011-01-17 17:41:59 +0100 |
commit | b3330ba6dccd65f4d0bef843e092f4c0f2c56c7f (patch) | |
tree | 3edfb3c8ecffbf359ce77f18018b78768532212f | |
parent | 3a16d6494d6117c7515ad9000b1f9d86a54bb536 (diff) | |
download | abrt-b3330ba6dccd65f4d0bef843e092f4c0f2c56c7f.tar.gz abrt-b3330ba6dccd65f4d0bef843e092f4c0f2c56c7f.tar.xz abrt-b3330ba6dccd65f4d0bef843e092f4c0f2c56c7f.zip |
remove [ Cron ] handling
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
-rw-r--r-- | src/daemon/Daemon.cpp | 160 | ||||
-rw-r--r-- | src/daemon/Settings.cpp | 131 | ||||
-rw-r--r-- | src/daemon/Settings.h | 3 | ||||
-rw-r--r-- | src/daemon/abrt.conf | 9 | ||||
-rw-r--r-- | src/daemon/abrt.conf.5 | 12 |
5 files changed, 0 insertions, 315 deletions
diff --git a/src/daemon/Daemon.cpp b/src/daemon/Daemon.cpp index e864c466..1516f159 100644 --- a/src/daemon/Daemon.cpp +++ b/src/daemon/Daemon.cpp @@ -203,163 +203,6 @@ static void dumpsocket_shutdown() } } - -/* Cron handling */ - -typedef struct cron_callback_data_t -{ - std::string m_sPluginName; - std::string m_sPluginArgs; - unsigned int m_nTimeout; - - cron_callback_data_t( - const std::string& pPluginName, - const std::string& pPluginArgs, - const unsigned int& pTimeout) : - m_sPluginName(pPluginName), - m_sPluginArgs(pPluginArgs), - m_nTimeout(pTimeout) - {} -} cron_callback_data_t; - -static void cron_delete_callback_data_cb(gpointer data) -{ - cron_callback_data_t* cronDeleteCallbackData = static_cast<cron_callback_data_t*>(data); - delete cronDeleteCallbackData; -} - -static gboolean cron_activation_periodic_cb(gpointer data) -{ - cron_callback_data_t* cronPeriodicCallbackData = static_cast<cron_callback_data_t*>(data); - VERB1 log("Activating plugin: %s", cronPeriodicCallbackData->m_sPluginName.c_str()); - RunAction(DEBUG_DUMPS_DIR, - cronPeriodicCallbackData->m_sPluginName.c_str(), - cronPeriodicCallbackData->m_sPluginArgs.c_str() - ); - return TRUE; -} -static gboolean cron_activation_one_cb(gpointer data) -{ - cron_callback_data_t* cronOneCallbackData = static_cast<cron_callback_data_t*>(data); - VERB1 log("Activating plugin: %s", cronOneCallbackData->m_sPluginName.c_str()); - RunAction(DEBUG_DUMPS_DIR, - cronOneCallbackData->m_sPluginName.c_str(), - cronOneCallbackData->m_sPluginArgs.c_str() - ); - return FALSE; -} -static gboolean cron_activation_reshedule_cb(gpointer data) -{ - cron_callback_data_t* cronResheduleCallbackData = static_cast<cron_callback_data_t*>(data); - VERB1 log("Rescheduling plugin: %s", cronResheduleCallbackData->m_sPluginName.c_str()); - cron_callback_data_t* cronPeriodicCallbackData = new cron_callback_data_t(cronResheduleCallbackData->m_sPluginName, - cronResheduleCallbackData->m_sPluginArgs, - cronResheduleCallbackData->m_nTimeout); - g_timeout_add_seconds_full(G_PRIORITY_DEFAULT, - cronPeriodicCallbackData->m_nTimeout, - cron_activation_periodic_cb, - static_cast<gpointer>(cronPeriodicCallbackData), - cron_delete_callback_data_cb - ); - return FALSE; -} - -static int SetUpCron() -{ - map_cron_t::iterator it_c = g_settings_mapCron.begin(); - for (; it_c != g_settings_mapCron.end(); it_c++) - { - std::string::size_type pos = it_c->first.find(":"); - int timeout = 0; - int nH = -1; - int nM = -1; - int nS = -1; - -//TODO: rewrite using good old sscanf? - - if (pos != std::string::npos) - { - std::string sH; - std::string sM; - - sH = it_c->first.substr(0, pos); - nH = xatou(sH.c_str()); - nH = nH > 23 ? 23 : nH; - nH = nH < 0 ? 0 : nH; - timeout += nH * 60 * 60; - sM = it_c->first.substr(pos + 1); - nM = xatou(sM.c_str()); - nM = nM > 59 ? 59 : nM; - nM = nM < 0 ? 0 : nM; - timeout += nM * 60; - } - else - { - std::string sS; - - sS = it_c->first; - nS = xatou(sS.c_str()); - nS = nS <= 0 ? 1 : nS; - timeout = nS; - } - - if (nS != -1) - { - vector_pair_string_string_t::iterator it_ar = it_c->second.begin(); - for (; it_ar != it_c->second.end(); it_ar++) - { - cron_callback_data_t* cronPeriodicCallbackData = new cron_callback_data_t(it_ar->first, it_ar->second, timeout); - g_timeout_add_seconds_full(G_PRIORITY_DEFAULT, - timeout, - cron_activation_periodic_cb, - static_cast<gpointer>(cronPeriodicCallbackData), - cron_delete_callback_data_cb); - } - } - else - { - time_t actTime = time(NULL); - struct tm locTime; - localtime_r(&actTime, &locTime); - locTime.tm_hour = nH; - locTime.tm_min = nM; - locTime.tm_sec = 0; - time_t nextTime = mktime(&locTime); - if (nextTime == ((time_t)-1)) - { - /* paranoia */ - perror_msg("Can't set up cron time"); - return -1; - } - if (actTime > nextTime) - { - timeout = 24*60*60 + (nextTime - actTime); - } - else - { - timeout = nextTime - actTime; - } - vector_pair_string_string_t::iterator it_ar = it_c->second.begin(); - for (; it_ar != it_c->second.end(); it_ar++) - { - cron_callback_data_t* cronOneCallbackData = new cron_callback_data_t(it_ar->first, it_ar->second, timeout); - g_timeout_add_seconds_full(G_PRIORITY_DEFAULT, - timeout, - cron_activation_one_cb, - static_cast<gpointer>(cronOneCallbackData), - cron_delete_callback_data_cb); - cron_callback_data_t* cronResheduleCallbackData = new cron_callback_data_t(it_ar->first, it_ar->second, 24 * 60 * 60); - g_timeout_add_seconds_full(G_PRIORITY_DEFAULT, - timeout, - cron_activation_reshedule_cb, - static_cast<gpointer>(cronResheduleCallbackData), - cron_delete_callback_data_cb); - } - } - } - return 0; -} - static int CreatePidFile() { int fd; @@ -837,9 +680,6 @@ int main(int argc, char** argv) g_pPluginManager = new CPluginManager(); g_pPluginManager->LoadPlugins(); - if (SetUpCron() != 0) - throw 1; - /* Add an event source which waits for INT/TERM signal */ VERB1 log("Adding signal pipe watch to glib main loop"); channel_signal = g_io_channel_unix_new(s_signal_pipe[0]); diff --git a/src/daemon/Settings.cpp b/src/daemon/Settings.cpp index 63453933..d155b4ec 100644 --- a/src/daemon/Settings.cpp +++ b/src/daemon/Settings.cpp @@ -21,7 +21,6 @@ #define SECTION_COMMON "Common" #define SECTION_LOG_SCANNERS "LogScanners" -#define SECTION_CRON "Cron" /* Conf file has this format: * [ section_name1 ] @@ -38,8 +37,6 @@ * If the same name found on more than one line, * the values are appended, separated by comma: map["name"] = "value1,value2" */ static map_string_t s_mapSectionCommon; -/* ... from [ Cron ] */ -static map_string_t s_mapSectionCron; /* Public data */ /* Written out exactly in this order by SaveSettings() */ @@ -58,10 +55,6 @@ bool g_settings_bProcessUnpackaged = false; /* [ LogScanners ] */ char * g_settings_sLogScanners = NULL; -/* [ Cron ] */ -/* many lines, one per key: "map_key = aa_first,bb_first(bb_second),cc_first" */ -map_cron_t g_settings_mapCron; - /* * Loading @@ -90,101 +83,6 @@ static GList *parse_list(const char* list) return l; } -/* Format: name, name(param),name("param with spaces \"and quotes\"") */ -static vector_pair_string_string_t ParseListWithArgs(const char *pValue, int *err) -{ - VERB3 log(" ParseListWithArgs(%s)", pValue); - - vector_pair_string_string_t pluginsWithArgs; - std::string item; - std::string action; - bool is_quote = false; - bool is_arg = false; - for (int ii = 0; pValue[ii]; ii++) - { - if (is_quote && pValue[ii] == '\\' && pValue[ii + 1]) - { - ii++; - item += pValue[ii]; - continue; - } - if (pValue[ii] == '"') - { - is_quote = !is_quote; - /*item += pValue[ii]; - wrong! name("param") must be == name(param) */ - continue; - } - if (is_quote) - { - item += pValue[ii]; - continue; - } - if (pValue[ii] == '(') - { - if (!is_arg) - { - action = item; - item = ""; - is_arg = true; - } - else - { - *err = 1; - error_msg("Parser error: Invalid syntax on column %d in \"%s\"", ii, pValue); - } - - continue; - } - if (pValue[ii] == ')') - { - if (is_arg) - { - VERB3 log(" adding (%s,%s)", action.c_str(), item.c_str()); - pluginsWithArgs.push_back(make_pair(action, item)); - item = ""; - is_arg = false; - action = ""; - } - else - { - *err = 1; - error_msg("Parser error: Invalid syntax on column %d in \"%s\"", ii, pValue); - } - - continue; - } - if (pValue[ii] == ',' && !is_arg) - { - if (item != "") - { - VERB3 log(" adding (%s,%s)", item.c_str(), ""); - pluginsWithArgs.push_back(make_pair(item, "")); - item = ""; - } - continue; - } - item += pValue[ii]; - } - - if (is_quote) - { - *err = 1; - error_msg("Parser error: Unclosed quote in \"%s\"", pValue); - } - - if (is_arg) - { - *err = 1; - error_msg("Parser error: Unclosed argument in \"%s\"", pValue); - } - else if (item != "") - { - VERB3 log(" adding (%s,%s)", item.c_str(), ""); - pluginsWithArgs.push_back(make_pair(item, "")); - } - return pluginsWithArgs; -} - static int ParseCommon() { map_string_t::const_iterator end = s_mapSectionCommon.end(); @@ -221,20 +119,6 @@ static int ParseCommon() return 0; /* no error */ } -static int ParseCron() -{ - map_string_t::iterator it = s_mapSectionCron.begin(); - for (; it != s_mapSectionCron.end(); it++) - { - int err = 0; - vector_pair_string_string_t actionsAndReporters = ParseListWithArgs(it->second.c_str(), &err); - if (err) - return err; - g_settings_mapCron[it->first] = actionsAndReporters; - } - return 0; /* no error */ -} - static void LoadGPGKeys() { FILE *fp = fopen(CONF_DIR"/gpg_keys", "r"); @@ -360,12 +244,6 @@ static int ReadConfigurationFromFile(FILE *fp) { g_settings_sLogScanners = xstrdup(value.c_str()); } - else if (section == SECTION_CRON) - { - if (s_mapSectionCron[key] != "") - s_mapSectionCron[key] += ","; - s_mapSectionCron[key] += value; - } else { error_msg("abrt.conf: Ignoring entry in invalid section [%s]", section.c_str()); @@ -396,8 +274,6 @@ int LoadSettings() if (err == 0) err = ParseCommon(); - if (err == 0) - err = ParseCron(); if (err == 0) { @@ -420,7 +296,6 @@ map_abrt_settings_t GetSettings() map_abrt_settings_t ABRTSettings; ABRTSettings[SECTION_COMMON] = s_mapSectionCommon; - ABRTSettings[SECTION_CRON] = s_mapSectionCron; return ABRTSettings; } @@ -435,12 +310,6 @@ void SetSettings(const map_abrt_settings_t& pSettings, const char *dbus_sender) s_mapSectionCommon = it->second; ParseCommon(); } - it = pSettings.find(SECTION_CRON); - if (it != end) - { - s_mapSectionCron = it->second; - ParseCron(); - } } void settings_free() diff --git a/src/daemon/Settings.h b/src/daemon/Settings.h index 01cd1adc..49790e01 100644 --- a/src/daemon/Settings.h +++ b/src/daemon/Settings.h @@ -22,7 +22,6 @@ #include "abrt_types.h" #include <glib.h> -typedef map_vector_pair_string_string_t map_cron_t; typedef map_map_string_t map_abrt_settings_t; extern GList *g_settings_setOpenGPGPublicKeys; @@ -35,8 +34,6 @@ extern char * g_settings_sWatchCrashdumpArchiveDir; extern char * g_settings_sLogScanners; -extern map_cron_t g_settings_mapCron; - int LoadSettings(); void SaveSettings(); void SetSettings(const map_abrt_settings_t& pSettings, const char * dbus_sender); diff --git a/src/daemon/abrt.conf b/src/daemon/abrt.conf index fedefea0..7f5a9c58 100644 --- a/src/daemon/abrt.conf +++ b/src/daemon/abrt.conf @@ -34,12 +34,3 @@ MaxCrashReportsSize = 1000 # [ LogScanners ] abrt-dump-oops = abrt-dump-oops -drw /var/log/messages - - -# Which Action plugins to run repeatedly -# -[ Cron ] -# h:m - at h:m -# s - every s seconds - -#02:00 = FileTransfer diff --git a/src/daemon/abrt.conf.5 b/src/daemon/abrt.conf.5 index 3f9d8c39..84c8f002 100644 --- a/src/daemon/abrt.conf.5 +++ b/src/daemon/abrt.conf.5 @@ -65,18 +65,6 @@ all the C/C++ programs. .TP .B Kerneloops = \fIplugin\fP This plugin will be used in the case of kernel crashes. -.SS [ Cron ] -This section specifies tasks that will be run at some specified time. You can specify -either a time of day in the format -.br -.B hh:mm = \fIplugin\fP -.br -or an interval -.br -.B ss = \fIplugin2\fP -.br -in this case, \fIplugin2\fP will be run every \fIss\fP seconds (this number -can be greater than 60). .SH "SEE ALSO" .IR abrtd (8), .IR abrt-plugins (7) |