Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[storage] Unregister service inotify prior to removal. JB#53294
In __connman_storage_remove_service() the service inotify should be
removed always prior to removal of the service. Otherwise it may result
in double attempt to remove the service, as inotify calls
storage_inotify_cb() to remove the service after the file has been
removed from disk.
  • Loading branch information
LaakkonenJussi committed Mar 11, 2021
1 parent a745409 commit 9f0799a
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions connman/src/storage.c
Expand Up @@ -1244,6 +1244,9 @@ static int remove_dir(const char *service_id)

bool __connman_storage_remove_service(const char *service_id)
{
struct storage_subdir key = { .name = (gchar*) service_id };
GList *subdirs;
GList *pos;
bool removed = false;
gchar *pathname;
const char *storagedir;
Expand All @@ -1253,26 +1256,23 @@ bool __connman_storage_remove_service(const char *service_id)
if (!service_id || !service_id_is_valid(service_id))
return false;

if (storage.only_unload) {
struct storage_subdir key = { .name = (gchar*) service_id };
GList *subdirs;
GList *pos;

DBG("Unload service %s", service_id);
if (is_user_dir(service_id))
subdirs = storage.user_subdirs;
else
subdirs = storage.subdirs;

if (is_user_dir(service_id))
subdirs = storage.user_subdirs;
else
subdirs = storage.subdirs;
pos = g_list_find_custom(subdirs, &key, storage_subdir_cmp);
if (pos)
storage_subdir_unregister(pos->data);

pos = g_list_find_custom(subdirs, &key, storage_subdir_cmp);
if (!pos) {
if (storage.only_unload) {
if (pos) {
DBG("Unregister service %s", service_id);
return true;
} else {
DBG("cannot unregister %s", service_id);
return false;
}

storage_subdir_unregister(pos->data);
return true;
}

storagedir = storagedir_for(service_id);
Expand Down

0 comments on commit 9f0799a

Please sign in to comment.