Skip to content

Commit

Permalink
udisksstate: Remove udisks_state_check_sync()
Browse files Browse the repository at this point in the history
Unused nowadays, replaced by explicit cleanup by block device number
and mutexes for cross-thread calls.
  • Loading branch information
tbzatek committed Jan 5, 2022
1 parent 4743876 commit 2308c5b
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 60 deletions.
1 change: 0 additions & 1 deletion doc/udisks2-sections.txt.daemon.sections.in
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ udisks_state_new
udisks_state_start_cleanup
udisks_state_stop_cleanup
udisks_state_check
udisks_state_check_sync
udisks_state_check_block
udisks_state_get_daemon
<SUBSECTION>
Expand Down
58 changes: 0 additions & 58 deletions src/udisksstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,64 +425,6 @@ udisks_state_check (UDisksState *state)
state);
}


typedef struct
{
UDisksState *state;
gboolean finished;
GCond cond;
GMutex data_mutex;
} UDisksStateCheckSyncData;

static gboolean
udisks_state_check_sync_func (UDisksStateCheckSyncData *data)
{
udisks_state_check_in_thread (data->state);

/* signal the calling thread the cleanup has finished */
g_mutex_lock (&data->data_mutex);
data->finished = TRUE;
g_cond_signal (&data->cond);
g_mutex_unlock (&data->data_mutex);

return FALSE;
}

/**
* udisks_state_check_sync:
* @state: A #UDisksState.
*
* Causes the clean-up thread for @state to check if anything should be cleaned up and perform the cleanup.
*
* This can be called from any thread and in contrast to udisks_state_check() will block the calling thread until cleanup is finished.
*/
void
udisks_state_check_sync (UDisksState *state)
{
UDisksStateCheckSyncData data = {0, };

g_return_if_fail (UDISKS_IS_STATE (state));
g_return_if_fail (state->thread != NULL);

g_cond_init (&data.cond);
g_mutex_init (&data.data_mutex);
data.state = state;
data.finished = FALSE;

g_mutex_lock (&data.data_mutex);
g_main_context_invoke (state->context,
(GSourceFunc) udisks_state_check_sync_func,
&data);

/* wait for the mainloop running in the cleanup thread to process our injected task */
while (!data.finished)
g_cond_wait (&data.cond, &data.data_mutex);
g_mutex_unlock (&data.data_mutex);

g_cond_clear (&data.cond);
g_mutex_clear (&data.data_mutex);
}

/**
* udisks_state_check_block:
* @state: A #UDisksState.
Expand Down
1 change: 0 additions & 1 deletion src/udisksstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ UDisksDaemon *udisks_state_get_daemon (UDisksState *state);
void udisks_state_start_cleanup (UDisksState *state);
void udisks_state_stop_cleanup (UDisksState *state);
void udisks_state_check (UDisksState *state);
void udisks_state_check_sync (UDisksState *state);
void udisks_state_check_block (UDisksState *state,
dev_t block_device);
/* mounted-fs */
Expand Down

0 comments on commit 2308c5b

Please sign in to comment.