Skip to content

Commit

Permalink
Merge pull request #128 from MrAnno/fix-half-init-diskq
Browse files Browse the repository at this point in the history
driver: release the queues of half-initialized pipes
  • Loading branch information
bazsi authored Jun 2, 2024
2 parents cff2314 + 629fb42 commit 4373a1e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
23 changes: 14 additions & 9 deletions lib/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,9 @@ _log_dest_driver_unregister_counters(LogDestDriver *self)
stats_unlock();
}

gboolean
log_dest_driver_deinit_method(LogPipe *s)
static inline void
_log_dest_driver_release_queues(LogDestDriver *self)
{
LogDestDriver *self = (LogDestDriver *) s;
GList *l, *l_next;

for (l = self->queues; l; l = l_next)
Expand All @@ -404,7 +403,16 @@ log_dest_driver_deinit_method(LogPipe *s)
* which automatically frees the ref on the list too */
log_dest_driver_release_queue(self, log_queue_ref(q));
}

g_assert(self->queues == NULL);
}

gboolean
log_dest_driver_deinit_method(LogPipe *s)
{
LogDestDriver *self = (LogDestDriver *) s;

_log_dest_driver_release_queues(self);

_log_dest_driver_unregister_counters(self);

Expand All @@ -431,12 +439,9 @@ void
log_dest_driver_free(LogPipe *s)
{
LogDestDriver *self = (LogDestDriver *) s;
GList *l;

for (l = self->queues; l; l = l->next)
{
log_queue_unref((LogQueue *) l->data);
}
g_list_free(self->queues);
/* half-initialized pipes can't release their queue in deinit() */
_log_dest_driver_release_queues(self);

log_driver_free(s);
}
6 changes: 5 additions & 1 deletion lib/logthrdest/logthrdestdrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1352,7 +1352,11 @@ _create_workers(LogThreadedDestDriver *self, gint stats_level, StatsClusterKeyBu

self->workers[self->created_workers] = dw;
if (!_acquire_worker_queue(dw, stats_level, driver_sck_builder))
return FALSE;
{
/* failed worker needs to be destroyed */
self->created_workers++;
return FALSE;
}
}

return TRUE;
Expand Down
3 changes: 3 additions & 0 deletions news/bugfix-128.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
`disk-buffer()`: fix crash when pipeline initialization fails

`log_queue_disk_free_method: assertion failed: (!qdisk_started(self->qdisk))`

0 comments on commit 4373a1e

Please sign in to comment.