diff options
Diffstat (limited to 'src/analysis')
-rw-r--r-- | src/analysis/binary.c | 41 | ||||
-rw-r--r-- | src/analysis/db/client.c | 3 | ||||
-rw-r--r-- | src/analysis/loaded-int.h | 2 | ||||
-rw-r--r-- | src/analysis/loaded.c | 19 | ||||
-rw-r--r-- | src/analysis/loaded.h | 4 | ||||
-rw-r--r-- | src/analysis/project.c | 4 |
6 files changed, 43 insertions, 30 deletions
diff --git a/src/analysis/binary.c b/src/analysis/binary.c index ec129b1..cf680c3 100644 --- a/src/analysis/binary.c +++ b/src/analysis/binary.c @@ -44,7 +44,6 @@ #include "../common/cpp.h" #include "../common/xdg.h" #include "../core/collections.h" -#include "../core/global.h" #include "../core/logs.h" #include "../core/params.h" #include "../core/processors.h" @@ -169,7 +168,7 @@ static GBinContent *g_loaded_binary_get_content(const GLoadedBinary *); static const char *g_loaded_binary_get_format_name(const GLoadedBinary *); /* Assure le désassemblage en différé. */ -static bool g_loaded_binary_analyze(GLoadedBinary *, bool, wgroup_id_t, GtkStatusStack *); +static bool g_loaded_binary_analyze(GLoadedBinary *, bool, bool, wgroup_id_t, GtkStatusStack *); /* Prend note d'une variation des instructions désassemblées. */ static void on_binary_processor_changed(GArchProcessor *, GArchInstruction *, gboolean, GLoadedBinary *); @@ -1088,23 +1087,30 @@ bool _g_loaded_binary_add_to_collection(GLoadedBinary *binary, GDbItem *item, bo if (storage == DBS_ALL_REMOTE) client = binary->remote; else - client = NULL; + client = binary->local; if (client == NULL) - client = binary->local; + { + log_simple_message(LMT_ERROR, _("No connection to a server in order to forward the item")); + result = false; + } - init_packed_buffer(&out_pbuf); + else + { + init_packed_buffer(&out_pbuf); - fd = g_hub_client_get_fd(client); + fd = g_hub_client_get_fd(client); - result = g_db_collection_pack(collec, &out_pbuf, DBA_ADD_ITEM, item); + result = g_db_collection_pack(collec, &out_pbuf, DBA_ADD_ITEM, item); - g_hub_client_put_fd(client); + g_hub_client_put_fd(client); - if (result) - result = send_packed_buffer(&out_pbuf, fd); + if (result) + result = send_packed_buffer(&out_pbuf, fd); - exit_packed_buffer(&out_pbuf); + exit_packed_buffer(&out_pbuf); + + } } @@ -1645,10 +1651,11 @@ static const char *g_loaded_binary_get_format_name(const GLoadedBinary *binary) /****************************************************************************** * * -* Paramètres : binary = élément chargé dont l'analyse est lancée. * -* cache = précise si la préparation d'un rendu est demandée. * -* gid = groupe de travail dédié. * -* status = barre de statut à tenir informée. * +* Paramètres : binary = élément chargé dont l'analyse est lancée. * +* connect = organise le lancement des connexions aux serveurs. * +* cache = précise si la préparation d'un rendu est demandée. * +* gid = groupe de travail dédié. * +* status = barre de statut à tenir informée. * * * * Description : Assure le désassemblage en différé. * * * @@ -1658,7 +1665,7 @@ static const char *g_loaded_binary_get_format_name(const GLoadedBinary *binary) * * ******************************************************************************/ -static bool g_loaded_binary_analyze(GLoadedBinary *binary, bool cache, wgroup_id_t gid, GtkStatusStack *status) +static bool g_loaded_binary_analyze(GLoadedBinary *binary, bool connect, bool cache, wgroup_id_t gid, GtkStatusStack *status) { bool result; /* Bilan à retourner */ GBinFormat *format; /* Format lié au binaire */ @@ -1715,7 +1722,7 @@ static bool g_loaded_binary_analyze(GLoadedBinary *binary, bool cache, wgroup_id /* Phase de désassemblage pur */ - if (!is_batch_mode()) + if (connect) g_loaded_binary_connect_internal(binary); disassemble_binary(binary, gid, status, &context); diff --git a/src/analysis/db/client.c b/src/analysis/db/client.c index c608bfa..9252ccc 100644 --- a/src/analysis/db/client.c +++ b/src/analysis/db/client.c @@ -856,7 +856,8 @@ void g_hub_client_stop(GHubClient *client) ret = close(fd); if (ret == -1) LOG_ERROR_N("close"); - g_thread_join(client->update); + if (g_thread_self() != client->update) + g_thread_join(client->update); /* Environnement TLS */ diff --git a/src/analysis/loaded-int.h b/src/analysis/loaded-int.h index c1cba2a..1b04fab 100644 --- a/src/analysis/loaded-int.h +++ b/src/analysis/loaded-int.h @@ -43,7 +43,7 @@ typedef GBinContent * (* get_content_fc) (const GLoadedContent *); typedef const char * (* get_format_name_fc) (const GLoadedContent *); /* Assure l'analyse d'un contenu chargé en différé. */ -typedef bool (* analyze_loaded_fc) (GLoadedContent *, bool, wgroup_id_t, GtkStatusStack *); +typedef bool (* analyze_loaded_fc) (GLoadedContent *, bool, bool, wgroup_id_t, GtkStatusStack *); /* Fournit le désignation associée à l'élément chargé. */ typedef const char * (* describe_loaded_fc) (const GLoadedContent *, bool); diff --git a/src/analysis/loaded.c b/src/analysis/loaded.c index 6f79bf8..f8b25d5 100644 --- a/src/analysis/loaded.c +++ b/src/analysis/loaded.c @@ -69,6 +69,7 @@ struct _GLoadedAnalysis GDelayedWork parent; /* A laisser en premier */ GLoadedContent *content; /* Cible de l'analyse à mener */ + bool connect; /* Lancement de connexions ? */ bool cache; /* Degré d'opération à mener */ bool success; /* Bilan de l'opération */ @@ -99,7 +100,7 @@ static void g_loaded_analysis_dispose(GLoadedAnalysis *); static void g_loaded_analysis_finalize(GLoadedAnalysis *); /* Crée une tâche d'analyse de contenu différée. */ -static GLoadedAnalysis *g_loaded_analysis_new(GLoadedContent *, bool); +static GLoadedAnalysis *g_loaded_analysis_new(GLoadedContent *, bool, bool); /* Assure l'analyse d'un contenu chargé en différé. */ static void g_loaded_analysis_process(GLoadedAnalysis *, GtkStatusStack *); @@ -261,6 +262,7 @@ const char *g_loaded_content_get_format_name(const GLoadedContent *content) /****************************************************************************** * * * Paramètres : content = élément chargé à manipuler. * +* connect = organise le lancement des connexions aux serveurs. * * cache = précise si la préparation d'un rendu est demandée. * * * * Description : Lance l'analyse propre à l'élément chargé. * @@ -271,12 +273,12 @@ const char *g_loaded_content_get_format_name(const GLoadedContent *content) * * ******************************************************************************/ -void g_loaded_content_analyze(GLoadedContent *content, bool cache) +void g_loaded_content_analyze(GLoadedContent *content, bool connect, bool cache) { GLoadedAnalysis *analysis; /* Analyse à mener */ GWorkQueue *queue; /* Gestionnaire de différés */ - analysis = g_loaded_analysis_new(content, cache); + analysis = g_loaded_analysis_new(content, connect, cache); g_signal_connect(analysis, "work-completed", G_CALLBACK(on_loaded_content_analysis_completed), content); @@ -311,6 +313,7 @@ static void on_loaded_content_analysis_completed(GLoadedAnalysis *analysis, GLoa /****************************************************************************** * * * Paramètres : content = élément chargé à manipuler. * +* connect = organise le lancement des connexions aux serveurs. * * cache = précise si la préparation d'un rendu est demandée. * * * * Description : Lance l'analyse de l'élément chargé et attend sa conclusion. * @@ -321,14 +324,14 @@ static void on_loaded_content_analysis_completed(GLoadedAnalysis *analysis, GLoa * * ******************************************************************************/ -bool g_loaded_content_analyze_and_wait(GLoadedContent *content, bool cache) +bool g_loaded_content_analyze_and_wait(GLoadedContent *content, bool connect, bool cache) { bool result; /* Bilan à retourner */ GLoadedAnalysis *analysis; /* Analyse à mener */ GWorkQueue *queue; /* Gestionnaire de différés */ wgroup_id_t gid; /* Identifiant pour les tâches */ - analysis = g_loaded_analysis_new(content, cache); + analysis = g_loaded_analysis_new(content, connect, cache); g_object_ref(G_OBJECT(analysis)); queue = get_work_queue(); @@ -647,6 +650,7 @@ static void g_loaded_analysis_finalize(GLoadedAnalysis *analysis) /****************************************************************************** * * * Paramètres : content = contenu chargé à traiter. * +* connect = organise le lancement des connexions aux serveurs. * * cache = précise si la préparation d'un rendu est demandée. * * * * Description : Crée une tâche d'analyse de contenu différée. * @@ -657,7 +661,7 @@ static void g_loaded_analysis_finalize(GLoadedAnalysis *analysis) * * ******************************************************************************/ -static GLoadedAnalysis *g_loaded_analysis_new(GLoadedContent *content, bool cache) +static GLoadedAnalysis *g_loaded_analysis_new(GLoadedContent *content, bool connect, bool cache) { GLoadedAnalysis *result; /* Tâche à retourner */ @@ -666,6 +670,7 @@ static GLoadedAnalysis *g_loaded_analysis_new(GLoadedContent *content, bool cach result->content = content; g_object_ref(G_OBJECT(content)); + result->connect = connect; result->cache = cache; return result; @@ -698,7 +703,7 @@ static void g_loaded_analysis_process(GLoadedAnalysis *analysis, GtkStatusStack gid = g_work_queue_define_work_group(queue); - analysis->success = iface->analyze(analysis->content, analysis->cache, gid, status); + analysis->success = iface->analyze(analysis->content, analysis->connect, analysis->cache, gid, status); if (analysis->success) handle_loaded_content(PGA_CONTENT_ANALYZED, analysis->content, gid, status); diff --git a/src/analysis/loaded.h b/src/analysis/loaded.h index 1d41cef..ee919f2 100644 --- a/src/analysis/loaded.h +++ b/src/analysis/loaded.h @@ -71,10 +71,10 @@ GBinContent *g_loaded_content_get_content(const GLoadedContent *); const char *g_loaded_content_get_format_name(const GLoadedContent *); /* Lance l'analyse propre à l'élément chargé. */ -void g_loaded_content_analyze(GLoadedContent *, bool); +void g_loaded_content_analyze(GLoadedContent *, bool, bool); /* Lance l'analyse de l'élément chargé et attend sa conclusion. */ -bool g_loaded_content_analyze_and_wait(GLoadedContent *, bool); +bool g_loaded_content_analyze_and_wait(GLoadedContent *, bool, bool); /* Fournit le désignation associée à l'élément chargé. */ const char *g_loaded_content_describe(const GLoadedContent *, bool); diff --git a/src/analysis/project.c b/src/analysis/project.c index 84b5d7b..8285e7a 100644 --- a/src/analysis/project.c +++ b/src/analysis/project.c @@ -1299,7 +1299,7 @@ static void on_new_content_resolved(GContentResolver *resolver, wgroup_id_t wid, g_signal_connect(available[i], "analyzed", G_CALLBACK(on_loaded_content_analyzed), handler->project); - g_loaded_content_analyze(available[i], handler->cache); + g_loaded_content_analyze(available[i], !is_batch_mode(), handler->cache); } @@ -1337,7 +1337,7 @@ static void on_new_content_resolved(GContentResolver *resolver, wgroup_id_t wid, g_signal_connect(available[i], "analyzed", G_CALLBACK(on_loaded_content_analyzed), handler->project); - g_loaded_content_analyze(available[i], handler->cache); + g_loaded_content_analyze(available[i], !is_batch_mode(), handler->cache); } |