diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-07 17:02:29 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-07 17:02:29 +0200 |
commit | caef0b615fc0cc11de65fae634bd9674b0c634d2 (patch) | |
tree | aced58c1e779a6678e67a227d14440f38983922c /src/Daemon | |
parent | bb46fd1f7466df6a7f0c45ad50c661a36fec0caf (diff) | |
download | abrt-caef0b615fc0cc11de65fae634bd9674b0c634d2.tar.gz abrt-caef0b615fc0cc11de65fae634bd9674b0c634d2.tar.xz abrt-caef0b615fc0cc11de65fae634bd9674b0c634d2.zip |
correct g_pending_jobs' type; eliminate redundant string passing
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'src/Daemon')
-rw-r--r-- | src/Daemon/CommLayerServer.h | 4 | ||||
-rw-r--r-- | src/Daemon/CommLayerServerDBus.cpp | 30 | ||||
-rw-r--r-- | src/Daemon/CommLayerServerDBus.h | 4 | ||||
-rw-r--r-- | src/Daemon/CommLayerServerSocket.h | 2 | ||||
-rw-r--r-- | src/Daemon/CrashWatcher.cpp | 25 | ||||
-rw-r--r-- | src/Daemon/CrashWatcher.h | 2 | ||||
-rw-r--r-- | src/Daemon/Daemon.cpp | 12 | ||||
-rw-r--r-- | src/Daemon/Daemon.h | 4 |
8 files changed, 41 insertions, 42 deletions
diff --git a/src/Daemon/CommLayerServer.h b/src/Daemon/CommLayerServer.h index 2f4d66d5..7e6f8d72 100644 --- a/src/Daemon/CommLayerServer.h +++ b/src/Daemon/CommLayerServer.h @@ -18,8 +18,8 @@ class CCommLayerServer { 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 8040400f..c3cef3b5 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); @@ -376,23 +376,23 @@ void CCommLayerServerDBus::AnalyzeComplete(const map_crash_report_t& 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(); + /* TODO: 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); 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(); + /* TODO: 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); send_flush_and_unref(msg); @@ -445,11 +445,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 +478,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 +493,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 fffdd783..6ac702d0 100644 --- a/src/Daemon/CommLayerServerDBus.h +++ b/src/Daemon/CommLayerServerDBus.h @@ -16,8 +16,8 @@ class CCommLayerServerDBus 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.h b/src/Daemon/CommLayerServerSocket.h index 078b713b..bf5b2ff2 100644 --- a/src/Daemon/CommLayerServerSocket.h +++ b/src/Daemon/CommLayerServerSocket.h @@ -33,5 +33,5 @@ class CCommLayerServerSocket : public CCommLayerServer 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 b691795f..06afabda 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,16 @@ 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 +166,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); diff --git a/src/Daemon/CrashWatcher.h b/src/Daemon/CrashWatcher.h index c30bbb26..f35e1001 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 781a1bc0..fc28e8b3 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; diff --git a/src/Daemon/Daemon.h b/src/Daemon/Daemon.h index dbcfc291..8fcce717 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; |