module: handle work queue create errors

Handle NULL when creating a work queue instead of crashing. The
create can fail when we run out of fds.
This commit is contained in:
Wim Taymans 2021-06-18 16:29:23 +02:00
parent bbbc79647f
commit 1f04e911c5
7 changed files with 49 additions and 8 deletions

View file

@ -500,6 +500,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
struct pw_context *context = pw_impl_module_get_context(module);
struct pw_impl_factory *factory;
struct factory_data *data;
int res;
factory = pw_context_create_factory(context,
"link-factory",
@ -516,6 +517,13 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
data->this = factory;
data->module = module;
data->work = pw_context_get_work_queue(context);
if (data->work == NULL) {
res = -errno;
pw_log_error( "can't get work queue: %m");
pw_impl_factory_destroy(factory);
return res;
}
spa_list_init(&data->link_list);
pw_log_debug("module %p: new", module);