summaryrefslogtreecommitdiff
path: root/src/analysis/db
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/db')
-rw-r--r--src/analysis/db/cdb.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/src/analysis/db/cdb.c b/src/analysis/db/cdb.c
index 92624f6..f93d32d 100644
--- a/src/analysis/db/cdb.c
+++ b/src/analysis/db/cdb.c
@@ -157,6 +157,9 @@ static bool g_cdb_archive_send_snapshot_update(GCdbArchive *, packed_buffer *);
static bool g_cdb_archive_send_snapshot_change(GCdbArchive *, packed_buffer *);
/* Dissocie un utilisateur de l'archive. */
+static void _g_cdb_archive_remove_client(GCdbArchive *, size_t);
+
+/* Dissocie un utilisateur de l'archive. */
static void g_cdb_archive_remove_client(GCdbArchive *, size_t);
@@ -1215,6 +1218,8 @@ static void g_cdb_archive_send_reply_to_all_clients(GCdbArchive *archive, packed
size_t i; /* Boucle de parcours */
bool status; /* Bilan d'une émission */
+ g_mutex_lock(&archive->clients_access);
+
for (i = 0; i < archive->count; i++)
{
status = ssl_send_packed_buffer(pbuf, archive->clients[i].ssl_fd);
@@ -1222,13 +1227,15 @@ static void g_cdb_archive_send_reply_to_all_clients(GCdbArchive *archive, packed
{
log_variadic_message(LMT_ERROR, _("Error while replying to client %zu"), i);
- g_cdb_archive_remove_client(archive, i);
+ _g_cdb_archive_remove_client(archive, i);
i--;
}
}
+ g_mutex_unlock(&archive->clients_access);
+
}
@@ -1419,13 +1426,13 @@ void g_cdb_archive_add_client(GCdbArchive *archive, SSL *fd)
* *
******************************************************************************/
-static void g_cdb_archive_remove_client(GCdbArchive *archive, size_t index)
+static void _g_cdb_archive_remove_client(GCdbArchive *archive, size_t index)
{
cdb_client *client; /* Client à traiter */
- client = &archive->clients[index];
+ assert(!g_mutex_trylock(&archive->clients_access));
- g_mutex_lock(&archive->clients_access);
+ client = &archive->clients[index];
SSL_free(client->ssl_fd);
free(client->user);
@@ -1436,6 +1443,28 @@ static void g_cdb_archive_remove_client(GCdbArchive *archive, size_t index)
archive->clients = realloc(archive->clients, --archive->count * sizeof(cdb_client));
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : archive = archive à connecter avec un utilisateur. *
+* index = indice de l'utilisateur concerné. *
+* *
+* Description : Dissocie un utilisateur de l'archive. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_cdb_archive_remove_client(GCdbArchive *archive, size_t index)
+{
+ g_mutex_lock(&archive->clients_access);
+
+ _g_cdb_archive_remove_client(archive, index);
+
g_mutex_unlock(&archive->clients_access);
}