-
Notifications
You must be signed in to change notification settings - Fork 176
provider: don't idle on single thread each device for multithread probe all devices #1459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -287,6 +287,22 @@ uevent_is_spurious (GUdevDevice *dev) | |
| return FALSE; | ||
| } | ||
|
|
||
| static void | ||
| probe_device_thread_func (GTask *task, gpointer source_object, gpointer task_data, GCancellable *cancellable) | ||
| { | ||
| ProbeRequest *request = task_data; | ||
| request->udisks_device = udisks_linux_device_new_sync (request->udev_device, udisks_linux_provider_get_udev_client(request->provider)); | ||
| g_task_return_pointer (task, request, NULL); | ||
| } | ||
|
|
||
| static void | ||
| on_probe_job_completed (GObject *source_object, GAsyncResult *res, gpointer user_data) | ||
| { | ||
| GTask *task = G_TASK (res); | ||
| ProbeRequest *request = g_task_propagate_pointer (task, NULL); | ||
| g_idle_add (on_idle_with_probed_uevent, request); | ||
| } | ||
|
|
||
| static gpointer | ||
| probe_request_thread_func (gpointer user_data) | ||
| { | ||
|
|
@@ -324,13 +340,16 @@ probe_request_thread_func (gpointer user_data) | |
|
|
||
| /* ignore spurious uevents */ | ||
| if (!request->known_block && uevent_is_spurious (request->udev_device)) | ||
| continue; | ||
|
|
||
| /* probe the device - this may take a while */ | ||
| request->udisks_device = udisks_linux_device_new_sync (request->udev_device, provider->gudev_client); | ||
| { | ||
| probe_request_free (request); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I make separate PR with this fix leak.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Included in #1472 keeping your credits |
||
| continue; | ||
| } | ||
|
|
||
| /* now that we've probed the device, post the request back to the main thread */ | ||
| g_idle_add (on_idle_with_probed_uevent, request); | ||
| GTask *task = g_task_new (provider, NULL, on_probe_job_completed, NULL); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please move the variable declaration to the top of the function along to others. |
||
| g_task_set_task_data (task, request, (GDestroyNotify) probe_request_free); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Do you have any assumptions on how to get around double free, maybe do the check inside function?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just pass |
||
| g_task_run_in_thread (task, probe_device_thread_func); | ||
| g_object_unref (task); | ||
| } | ||
| while (TRUE); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space before the opening parenthesis.