diff options
| author | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-09-08 12:58:47 +0200 |
|---|---|---|
| committer | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-09-08 12:58:47 +0200 |
| commit | e883ab414abb843bf2178521aa3e67732b8ecee7 (patch) | |
| tree | 2385dffa74583d2288d0f9105efb14d6ce2f30a5 /src | |
| parent | e065ed970b01cd4d145466918921d592aeab952c (diff) | |
| parent | 9826b8f4a6b4f3735a00916fdfddef7dd3ef7023 (diff) | |
| download | abrt-e883ab414abb843bf2178521aa3e67732b8ecee7.tar.gz abrt-e883ab414abb843bf2178521aa3e67732b8ecee7.tar.xz abrt-e883ab414abb843bf2178521aa3e67732b8ecee7.zip | |
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Diffstat (limited to 'src')
| -rw-r--r-- | src/Daemon/CommLayerServer.h | 5 | ||||
| -rw-r--r-- | src/Daemon/CommLayerServerDBus.cpp | 48 | ||||
| -rw-r--r-- | src/Daemon/CommLayerServerDBus.h | 5 | ||||
| -rw-r--r-- | src/Daemon/CommLayerServerSocket.cpp | 5 | ||||
| -rw-r--r-- | src/Daemon/CommLayerServerSocket.h | 3 | ||||
| -rw-r--r-- | src/Daemon/CrashWatcher.cpp | 28 | ||||
| -rw-r--r-- | src/Daemon/CrashWatcher.h | 2 | ||||
| -rw-r--r-- | src/Daemon/Daemon.cpp | 15 | ||||
| -rw-r--r-- | src/Daemon/Daemon.h | 4 | ||||
| -rw-r--r-- | src/Daemon/MiddleWare.cpp | 22 |
10 files changed, 68 insertions, 69 deletions
diff --git a/src/Daemon/CommLayerServer.h b/src/Daemon/CommLayerServer.h index 2f4d66d..9beb945 100644 --- a/src/Daemon/CommLayerServer.h +++ b/src/Daemon/CommLayerServer.h @@ -14,12 +14,11 @@ class CCommLayerServer { /* just stubs to be called when not implemented in specific comm layer */ virtual void Crash(const std::string& progname, const std::string& uid) {} - virtual void AnalyzeComplete(const map_crash_report_t& arg1) {} virtual void Error(const std::string& arg1) {} virtual void Update(const std::string& pMessage, uint64_t pJobID) {}; virtual void Warning(const std::string& pMessage) {}; - virtual void JobDone(const std::string &pDest, uint64_t pJobID) = 0; - virtual void JobStarted(const std::string &pDest, uint64_t pJobID) {}; + virtual void JobDone(const char* pDest, uint64_t pJobID) = 0; + virtual void JobStarted(const char* pDest, uint64_t pJobID) {}; virtual void Warning(const std::string& pMessage, uint64_t pJobID) {}; }; diff --git a/src/Daemon/CommLayerServerDBus.cpp b/src/Daemon/CommLayerServerDBus.cpp index 8040400..41f5aba 100644 --- a/src/Daemon/CommLayerServerDBus.cpp +++ b/src/Daemon/CommLayerServerDBus.cpp @@ -347,7 +347,7 @@ static DBusMessage* new_signal_msg(const char* member) static void send_flush_and_unref(DBusMessage* msg) { if (!dbus_connection_send(s_pConn, msg, NULL /* &serial */)) - error_msg_and_die("Error sending DBus signal"); + error_msg_and_die("Error sending DBus message"); dbus_connection_flush(s_pConn); VERB3 log("DBus message sent"); dbus_message_unref(msg); @@ -363,38 +363,35 @@ void CCommLayerServerDBus::Crash(const std::string& progname, const std::string& DBUS_TYPE_STRING, &c_progname, DBUS_TYPE_STRING, &c_uid, DBUS_TYPE_INVALID); + VERB2 log("Sending signal Crash('%s','%s')", c_progname, c_uid); send_flush_and_unref(msg); } -/* Notify the clients that creating a report has finished */ -void CCommLayerServerDBus::AnalyzeComplete(const map_crash_report_t& arg1) -{ - DBusMessage* msg = new_signal_msg("AnalyzeComplete"); - DBusMessageIter out_iter; - dbus_message_iter_init_append(msg, &out_iter); - store_val(&out_iter, arg1); - send_flush_and_unref(msg); -} - -void CCommLayerServerDBus::JobDone(const std::string &pDest, uint64_t job_id) +void CCommLayerServerDBus::JobDone(const char* pDest, uint64_t job_id) { DBusMessage* msg = new_signal_msg("JobDone"); - const char* c_dest = pDest.c_str(); + /* send unicast dbus signal */ + if (!dbus_message_set_destination(msg, pDest)) + die_out_of_memory(); dbus_message_append_args(msg, - DBUS_TYPE_STRING, &c_dest, + DBUS_TYPE_STRING, &pDest, /* TODO: redundant parameter, remove from API */ DBUS_TYPE_UINT64, &job_id, DBUS_TYPE_INVALID); + VERB2 log("Sending signal JobDone('%s',%llx)", pDest, (unsigned long long)job_id); send_flush_and_unref(msg); } -void CCommLayerServerDBus::JobStarted(const std::string &pDest, uint64_t job_id) +void CCommLayerServerDBus::JobStarted(const char* pDest, uint64_t job_id) { DBusMessage* msg = new_signal_msg("JobStarted"); - const char* c_dest = pDest.c_str(); + /* send unicast dbus signal */ + if (!dbus_message_set_destination(msg, pDest)) + die_out_of_memory(); dbus_message_append_args(msg, - DBUS_TYPE_STRING, &c_dest, + DBUS_TYPE_STRING, &pDest, /* TODO: redundant parameter, remove from API */ DBUS_TYPE_UINT64, &job_id, DBUS_TYPE_INVALID); + VERB2 log("Sending signal JobStarted('%s',%llx)", pDest, (unsigned long long)job_id); send_flush_and_unref(msg); } @@ -419,6 +416,7 @@ void CCommLayerServerDBus::Update(const std::string& pMessage, uint64_t job_id) send_flush_and_unref(msg); } +/* TODO: one Warning()? */ void CCommLayerServerDBus::Warning(const std::string& pMessage) { DBusMessage* msg = new_signal_msg("Warning"); @@ -445,11 +443,13 @@ void CCommLayerServerDBus::Warning(const std::string& pMessage, uint64_t job_id) * DBus call handlers */ -static long get_remote_uid(DBusMessage* call) +static long get_remote_uid(DBusMessage* call, const char** ppSender = NULL) { DBusError err; dbus_error_init(&err); const char* sender = dbus_message_get_sender(call); + if (ppSender) + *ppSender = sender; long uid = dbus_bus_get_unix_user(s_pConn, sender, &err); if (dbus_error_is_set(&err)) { @@ -476,14 +476,14 @@ static int handle_GetCrashInfos(DBusMessage* call, DBusMessage* reply) static int handle_CreateReport(DBusMessage* call, DBusMessage* reply) { - const char* argin1; + const char* pUUID; DBusMessageIter in_iter; if (!dbus_message_iter_init(call, &in_iter)) { error_msg("dbus call %s: no parameters", "CreateReport"); return -1; } - int r = load_val(&in_iter, argin1); + int r = load_val(&in_iter, pUUID); if (r != LAST_FIELD) { if (r == MORE_FIELDS) @@ -491,10 +491,10 @@ static int handle_CreateReport(DBusMessage* call, DBusMessage* reply) return -1; } - long unix_uid = get_remote_uid(call); - VERB1 log("got %s('%s') call from uid %ld", "CreateReport", argin1, unix_uid); -//FIXME: duplicate dbus_message_get_sender in get_remote_uid - uint64_t argout1 = CreateReport_t(argin1, to_string(unix_uid), dbus_message_get_sender(call)); + const char* sender; + long unix_uid = get_remote_uid(call, &sender); + VERB1 log("got %s('%s') call from uid %ld", "CreateReport", pUUID, unix_uid); + uint64_t argout1 = CreateReport_t(pUUID, to_string(unix_uid).c_str(), sender); dbus_message_append_args(reply, DBUS_TYPE_UINT64, &argout1, diff --git a/src/Daemon/CommLayerServerDBus.h b/src/Daemon/CommLayerServerDBus.h index fffdd78..e205d91 100644 --- a/src/Daemon/CommLayerServerDBus.h +++ b/src/Daemon/CommLayerServerDBus.h @@ -12,12 +12,11 @@ class CCommLayerServerDBus /* DBus signal senders */ virtual void Crash(const std::string& progname, const std::string& uid); - virtual void AnalyzeComplete(const map_crash_report_t& arg1); virtual void Error(const std::string& arg1); virtual void Update(const std::string& pMessage, uint64_t pJobID); //the job id should be enough in jobdone - virtual void JobDone(const std::string& pDest, uint64_t pJobID); - virtual void JobStarted(const std::string& pDest, uint64_t pJobID); + virtual void JobDone(const char* pDest, uint64_t pJobID); + virtual void JobStarted(const char* pDest, uint64_t pJobID); virtual void Warning(const std::string& pMessage); virtual void Warning(const std::string& pMessage, uint64_t pJobID); }; diff --git a/src/Daemon/CommLayerServerSocket.cpp b/src/Daemon/CommLayerServerSocket.cpp index c88e0f3..ad14666 100644 --- a/src/Daemon/CommLayerServerSocket.cpp +++ b/src/Daemon/CommLayerServerSocket.cpp @@ -246,11 +246,6 @@ void CCommLayerServerSocket::Crash(const std::string& arg1) //Send("(CRASH)New Crash Detected: " + arg1); } -void CCommLayerServerSocket::AnalyzeComplete(const map_crash_report_t& arg1) -{ - //Send("(ANALYZE_COMPLETE)Analyze Complete."); -} - void CCommLayerServerSocket::Error(const std::string& arg1) { //Send("(ERROR)Error: " + arg1); diff --git a/src/Daemon/CommLayerServerSocket.h b/src/Daemon/CommLayerServerSocket.h index 078b713..3fae187 100644 --- a/src/Daemon/CommLayerServerSocket.h +++ b/src/Daemon/CommLayerServerSocket.h @@ -31,7 +31,6 @@ class CCommLayerServerSocket : public CCommLayerServer virtual bool DeleteDebugDump(const std::string& pUUID, const std::string& pSender); virtual void Crash(const std::string& arg1); - virtual void AnalyzeComplete(const map_crash_report_t& arg1); virtual void Error(const std::string& arg1); - virtual void JobStarted(const std::string &pDest, uint64_t pJobID) {}; + virtual void JobStarted(const char* pDest, uint64_t pJobID) {}; }; diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp index b691795..1b17af6 100644 --- a/src/Daemon/CrashWatcher.cpp +++ b/src/Daemon/CrashWatcher.cpp @@ -106,14 +106,14 @@ typedef struct thread_data_t { pthread_t thread_id; char* UUID; char* UID; - char *dest; + char* dest; } thread_data_t; static void *create_report(void *arg) { thread_data_t *thread_data = (thread_data_t *) arg; map_crash_info_t crashReport; - g_pCommLayer->JobStarted(thread_data->dest, thread_data->thread_id); + g_pCommLayer->JobStarted(thread_data->dest, uint64_t(thread_data->thread_id)); log("Creating report..."); try @@ -133,19 +133,17 @@ static void *create_report(void *arg) case MW_CORRUPTED: case MW_FILE_ERROR: default: - { - std::string debugDumpDir; - warn_client(std::string("Corrupted crash with UUID ") + thread_data->UUID + ", deleting"); - debugDumpDir = DeleteCrashInfo(thread_data->UUID, thread_data->UID); - DeleteDebugDumpDir(debugDumpDir); - } + warn_client(std::string("Corrupted crash with UUID ") + thread_data->UUID + ", deleting"); + std::string debugDumpDir = DeleteCrashInfo(thread_data->UUID, thread_data->UID); + DeleteDebugDumpDir(debugDumpDir); break; } /* only one thread can write */ pthread_mutex_lock(&g_pJobsMutex); - g_pending_jobs[std::string(thread_data->UID)][thread_data->thread_id] = crashReport; + g_pending_jobs[std::string(thread_data->UID)][uint64_t(thread_data->thread_id)] = crashReport; pthread_mutex_unlock(&g_pJobsMutex); - g_pCommLayer->JobDone(thread_data->dest, thread_data->thread_id); + + g_pCommLayer->JobDone(thread_data->dest, uint64_t(thread_data->thread_id)); } catch (CABRTException& e) { @@ -169,12 +167,12 @@ static void *create_report(void *arg) /* Bogus value. pthreads require us to return void* */ return NULL; } -uint64_t CreateReport_t(const std::string& pUUID, const std::string& pUID, const std::string& pSender) +uint64_t CreateReport_t(const char* pUUID, const char* pUID, const char* pSender) { thread_data_t *thread_data = (thread_data_t *)xzalloc(sizeof(thread_data_t)); - thread_data->UUID = xstrdup(pUUID.c_str()); - thread_data->UID = xstrdup(pUID.c_str()); - thread_data->dest = xstrdup(pSender.c_str()); + thread_data->UUID = xstrdup(pUUID); + thread_data->UID = xstrdup(pUID); + thread_data->dest = xstrdup(pSender); if (pthread_create(&thread_data->thread_id, NULL, create_report, (void *)thread_data) != 0) { free(thread_data->UUID); @@ -182,7 +180,7 @@ uint64_t CreateReport_t(const std::string& pUUID, const std::string& pUID, const free(thread_data->dest); free(thread_data); /* The only reason this may happen is system-wide resource starvation, - * or ulimit is exceeded (someoune floods us with CreateReport() dbus calls?) + * or ulimit is exceeded (someone floods us with CreateReport() dbus calls?) */ error_msg("cannot create thread"); return 0; diff --git a/src/Daemon/CrashWatcher.h b/src/Daemon/CrashWatcher.h index c30bbb2..f35e100 100644 --- a/src/Daemon/CrashWatcher.h +++ b/src/Daemon/CrashWatcher.h @@ -49,7 +49,7 @@ class CCrashWatcher }; vector_crash_infos_t GetCrashInfos(const std::string &pUID); -uint64_t CreateReport_t(const std::string& pUUID, const std::string& pUID, const std::string& pSender); +uint64_t CreateReport_t(const char* pUUID, const char* pUID, const char* pSender); bool DeleteDebugDump(const std::string& pUUID, const std::string& pUID); map_crash_report_t GetJobResult(uint64_t pJobID, const std::string& pSender); diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp index 781a1bc..149b2bd 100644 --- a/src/Daemon/Daemon.cpp +++ b/src/Daemon/Daemon.cpp @@ -51,13 +51,13 @@ * - GetCrashInfos(): returns a vector_crash_infos_t (vector_map_vector_string_t) * of crashes for given uid * v[N]["executable"/"uid"/"kernel"/"backtrace"][N] = "contents" - * - CreateReport(DIR): starts creating a report for given /var/cache/abrt/DIR. + * - CreateReport(UUID): starts creating a report for /var/cache/abrt/DIR with this UUID * Returns job id (uint64) + * - GetJobResult(job_id): returns map_crash_report_t (map_vector_string_t) * - Report(map_crash_report_t (map_vector_string_t)): * "Please report this crash": calls Report() of all registered reporter plugins * Returns report_status_t (map_vector_string_t) - the status of each call - * - DeleteDebugDump(DIR): delete /var/cache/abrt/DIR. Returns bool - * - GetJobResult(job_id): returns map_crash_report_t (map_vector_string_t) + * - DeleteDebugDump(UUID): delete corresponding /var/cache/abrt/DIR. Returns bool * - GetPluginsInfo(): returns vector_map_string_t * - GetPluginSettings(PluginName): returns map_plugin_settings_t (map_string_t) * - SetPluginSettings(PluginName, map_plugin_settings_t): returns void @@ -97,12 +97,12 @@ static uint8_t s_sig_caught; static GMainLoop* g_pMainloop; int g_verbose; -CCommLayerServer *g_pCommLayer; +CCommLayerServer* g_pCommLayer; /* * Map to cache the results from CreateReport_t - * <UID, <UUID, result>> + * <UID, <job_id, result>> */ -std::map<const std::string, std::map <int, map_crash_report_t > > g_pending_jobs; +std::map<const std::string, std::map<uint64_t, map_crash_report_t> > g_pending_jobs; /* mutex to protect g_pending_jobs */ pthread_mutex_t g_pJobsMutex; @@ -503,7 +503,8 @@ static gboolean handle_event_cb(GIOChannel *gio, GIOCondition condition, gpointe /* ignore lock files and such */ if (!(event->mask & IN_ISDIR)) { - VERB3 log("File '%s' creation detected, ignoring", name); + // Happens all the time during normal run + //VERB3 log("File '%s' creation detected, ignoring", name); continue; } diff --git a/src/Daemon/Daemon.h b/src/Daemon/Daemon.h index dbcfc29..8fcce71 100644 --- a/src/Daemon/Daemon.h +++ b/src/Daemon/Daemon.h @@ -49,8 +49,8 @@ extern CPluginManager* g_pPluginManager; */ extern set_string_t g_setBlackList; -/* Map <UID, <UUID, result>> to cache the results from CreateReport_t() */ -extern std::map<const std::string, std::map<int, map_crash_report_t> > g_pending_jobs; +/* Map <UID, <job_id, result>> to cache the results from CreateReport_t() */ +extern std::map<const std::string, std::map<uint64_t, map_crash_report_t> > g_pending_jobs; /* Mutex to protect g_pending_jobs */ extern pthread_mutex_t g_pJobsMutex; diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp index e6c9187..4f499d6 100644 --- a/src/Daemon/MiddleWare.cpp +++ b/src/Daemon/MiddleWare.cpp @@ -173,33 +173,42 @@ mw_result_t CreateCrashReport(const std::string& pUUID, const std::string& pUID, map_crash_report_t& pCrashReport) { - CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase); - database_row_t row; - database->Connect(); - row = database->GetUUIDData(pUUID, pUID); - database->DisConnect(); - CDebugDump dd; + VERB2 log("CreateCrashReport('%s','%',result)", pUUID.c_str(), pUID.c_str()); + database_row_t row; + if (pUUID != "") + { + CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase); + database->Connect(); + row = database->GetUUIDData(pUUID, pUID); + database->DisConnect(); + } if (pUUID == "" || row.m_sUUID != pUUID) { warn_client("CreateCrashReport(): UUID '"+pUUID+"' is not in database."); return MW_IN_DB_ERROR; } + CDebugDump dd; try { std::string analyzer; std::string gUUID; + VERB3 log(" LoadText(FILENAME_ANALYZER,'%s')", row.m_sDebugDumpDir.c_str()); dd.Open(row.m_sDebugDumpDir); dd.LoadText(FILENAME_ANALYZER, analyzer); dd.Close(); + VERB3 log(" CreateReport('%s')", analyzer.c_str()); CreateReport(analyzer, row.m_sDebugDumpDir); gUUID = GetGlobalUUID(analyzer, row.m_sDebugDumpDir); + VERB3 log(" GetGlobalUUID:'%s'", gUUID.c_str()); + VERB3 log(" RunAnalyzerActions"); RunAnalyzerActions(analyzer, row.m_sDebugDumpDir); + VERB3 log(" DebugDumpToCrashReport"); DebugDumpToCrashReport(row.m_sDebugDumpDir, pCrashReport); add_crash_data_to_crash_report(pCrashReport, CD_UUID, CD_TXT, CD_ISNOTEDITABLE, gUUID); @@ -245,7 +254,6 @@ void RunAction(const std::string& pActionDir, warn_client("RunAction(): " + e.what()); update_client("Execution of '"+pPluginName+"' was not successful: " + e.what()); } - } void RunActionsAndReporters(const std::string& pDebugDumpDir) |
