summaryrefslogtreecommitdiff
path: root/src/analysis/db/cdb.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-10-13 23:24:57 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-10-13 23:24:57 (GMT)
commitf439711a77e0719e7f1dcf4b5c5511157986c918 (patch)
treecac0cf37be2676fcf2dc958f9d9fd2fadea20653 /src/analysis/db/cdb.c
parent986125d4c2d8b049017b6d0770f16b9058076165 (diff)
Retrieved the current snapshot identifier from servers.
Diffstat (limited to 'src/analysis/db/cdb.c')
-rw-r--r--src/analysis/db/cdb.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/analysis/db/cdb.c b/src/analysis/db/cdb.c
index 2013750..8e8813a 100644
--- a/src/analysis/db/cdb.c
+++ b/src/analysis/db/cdb.c
@@ -841,6 +841,7 @@ static void *g_cdb_archive_process(GCdbArchive *archive)
DBError error; /* Bilan d'une opération */
packed_buffer out_pbuf; /* Tampon d'émission */
GDbCollection *collec; /* Collection visée au final */
+ snapshot_id_t id; /* Identifiant d'instantané */
char *msg; /* Erreur à faire remonter */
void interrupt_poll_with_sigusr1(int sig) { };
@@ -910,6 +911,8 @@ static void *g_cdb_archive_process(GCdbArchive *archive)
status = ssl_recv_packed_buffer(&in_pbuf, archive->clients[i].ssl_fd);
if (!status) goto gcap_bad_exchange;
+ next_command:
+
status = extract_packed_buffer(&in_pbuf, &tmp32, sizeof(uint32_t), true);
if (!status) goto gcap_bad_exchange;
@@ -1000,6 +1003,42 @@ static void *g_cdb_archive_process(GCdbArchive *archive)
break;
+ case DBC_GET_CUR_SNAPSHOT:
+
+ init_packed_buffer(&out_pbuf);
+
+ status = extend_packed_buffer(&out_pbuf, (uint32_t []) { DBC_CUR_SNAPSHOT_UPDATED },
+ sizeof(uint32_t), true);
+ if (!status) goto gcap_bad_reply;
+
+#ifndef NDEBUG
+ status = g_db_snapshot_get_current_id(archive->snapshot, &id);
+ assert(status);
+#else
+ g_db_snapshot_get_current_id(archive->snapshot, &id);
+#endif
+
+ status = pack_snapshot_id(&id, &out_pbuf);
+ if (!status) goto gcap_bad_reply;
+
+ status = ssl_send_packed_buffer(&out_pbuf, archive->clients[i].ssl_fd);
+ if (!status) goto gcap_bad_reply;
+
+ exit_packed_buffer(&out_pbuf);
+
+ break;
+
+ case DBC_CUR_SNAPSHOT_UPDATED:
+ log_variadic_message(LMT_INFO,
+ _("This command is not available on this side: 0x%08x"), command);
+ goto gcap_bad_exchange;
+ break;
+
+ case DBC_SET_CUR_SNAPSHOT:
+
+
+ break;
+
default:
asprintf(&msg, _("Bad protocol command: 0x%08x"), command);
LOG_ERROR(LMT_ERROR, msg);
@@ -1009,6 +1048,9 @@ static void *g_cdb_archive_process(GCdbArchive *archive)
}
+ if (has_more_data_in_packed_buffer(&in_pbuf))
+ goto next_command;
+
exit_packed_buffer(&in_pbuf);
continue;