diff options
Diffstat (limited to 'src')
26 files changed, 62 insertions, 58 deletions
diff --git a/src/modules/gconf/module-gconf.c b/src/modules/gconf/module-gconf.c index a2a43278..e2b0f7c0 100644 --- a/src/modules/gconf/module-gconf.c +++ b/src/modules/gconf/module-gconf.c @@ -142,7 +142,7 @@ static void unload_one_module(struct userdata *u, struct module_info*m, unsigned return; pa_log_debug("Unloading module #%i", m->items[i].index); - pa_module_unload_by_index(u->core, m->items[i].index); + pa_module_unload_by_index(u->core, m->items[i].index, TRUE); m->items[i].index = PA_INVALID_INDEX; pa_xfree(m->items[i].name); pa_xfree(m->items[i].args); @@ -324,7 +324,7 @@ static void io_event_cb( u->io_event = NULL; } - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); } } diff --git a/src/modules/module-always-sink.c b/src/modules/module-always-sink.c index 8b67a36d..9d60c29e 100644 --- a/src/modules/module-always-sink.c +++ b/src/modules/module-always-sink.c @@ -108,7 +108,7 @@ static pa_hook_result_t put_hook_callback(pa_core *c, pa_sink *sink, void* userd pa_log_info("A new sink has been discovered. Unloading null-sink."); - pa_module_unload_request(u->null_module); + pa_module_unload_request(u->null_module, TRUE); u->null_module = NULL; return PA_HOOK_OK; @@ -171,7 +171,7 @@ void pa__done(pa_module*m) { if (u->unlink_slot) pa_hook_slot_free(u->unlink_slot); if (u->null_module) - pa_module_unload_request(u->null_module); + pa_module_unload_request(u->null_module, TRUE); pa_xfree(u->sink_name); pa_xfree(u); diff --git a/src/modules/module-cli.c b/src/modules/module-cli.c index df7783fa..7a58877a 100644 --- a/src/modules/module-cli.c +++ b/src/modules/module-cli.c @@ -53,7 +53,7 @@ static void eof_and_unload_cb(pa_cli*c, void *userdata) { pa_assert(c); pa_assert(m); - pa_module_unload_request(m); + pa_module_unload_request(m, TRUE); } static void eof_and_exit_cb(pa_cli*c, void *userdata) { diff --git a/src/modules/module-combine.c b/src/modules/module-combine.c index 0a0b8d20..1bfe4b4c 100644 --- a/src/modules/module-combine.c +++ b/src/modules/module-combine.c @@ -489,7 +489,7 @@ static void sink_input_kill_cb(pa_sink_input *i) { pa_sink_input_assert_ref(i); pa_assert(o = i->userdata); - pa_module_unload_request(o->userdata->module); + pa_module_unload_request(o->userdata->module, TRUE); output_free(o); } diff --git a/src/modules/module-detect.c b/src/modules/module-detect.c index 13bcfcd1..09b720df 100644 --- a/src/modules/module-detect.c +++ b/src/modules/module-detect.c @@ -256,7 +256,7 @@ int pa__init(pa_module*m) { pa_log_info("loaded %i modules.", n); /* We were successful and can unload ourselves now. */ - pa_module_unload_request(m); + pa_module_unload_request(m, TRUE); pa_modargs_free(ma); diff --git a/src/modules/module-esound-compat-spawnfd.c b/src/modules/module-esound-compat-spawnfd.c index 8eb4985b..578ad3b5 100644 --- a/src/modules/module-esound-compat-spawnfd.c +++ b/src/modules/module-esound-compat-spawnfd.c @@ -66,7 +66,7 @@ int pa__init(pa_module*m) { pa_assert_se(pa_close(fd) == 0); - pa_module_unload_request(m); + pa_module_unload_request(m, TRUE); ret = 0; diff --git a/src/modules/module-esound-compat-spawnpid.c b/src/modules/module-esound-compat-spawnpid.c index 67f0a231..f75335d5 100644 --- a/src/modules/module-esound-compat-spawnpid.c +++ b/src/modules/module-esound-compat-spawnpid.c @@ -65,7 +65,7 @@ int pa__init(pa_module*m) { if (kill(pid, SIGUSR1) < 0) pa_log_warn("kill(%u) failed: %s", pid, pa_cstrerror(errno)); - pa_module_unload_request(m); + pa_module_unload_request(m, TRUE); ret = 0; diff --git a/src/modules/module-esound-sink.c b/src/modules/module-esound-sink.c index 6ca64978..f748808e 100644 --- a/src/modules/module-esound-sink.c +++ b/src/modules/module-esound-sink.c @@ -479,7 +479,7 @@ static void io_callback(PA_GCC_UNUSED pa_iochannel *io, void*userdata) { u->io = NULL; } - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); } } @@ -491,7 +491,7 @@ static void on_connection(PA_GCC_UNUSED pa_socket_client *c, pa_iochannel*io, vo if (!io) { pa_log("Connection failed: %s", pa_cstrerror(errno)); - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); return; } diff --git a/src/modules/module-hal-detect.c b/src/modules/module-hal-detect.c index bfabd91a..caa7a1fa 100644 --- a/src/modules/module-hal-detect.c +++ b/src/modules/module-hal-detect.c @@ -511,7 +511,7 @@ static void device_removed_cb(LibHalContext* context, const char *udi) { pa_log_debug("Device removed: %s", udi); if ((d = pa_hashmap_remove(u->devices, udi))) { - pa_module_unload_by_index(u->core, d->index); + pa_module_unload_by_index(u->core, d->index, TRUE); hal_device_free(d); } } diff --git a/src/modules/module-ladspa-sink.c b/src/modules/module-ladspa-sink.c index eae80086..23eeb340 100644 --- a/src/modules/module-ladspa-sink.c +++ b/src/modules/module-ladspa-sink.c @@ -340,7 +340,7 @@ static void sink_input_kill_cb(pa_sink_input *i) { pa_sink_input_unref(u->sink_input); u->sink_input = NULL; - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); } /* Called from IO thread context */ diff --git a/src/modules/module-lirc.c b/src/modules/module-lirc.c index 0570a6a1..f34f7be3 100644 --- a/src/modules/module-lirc.c +++ b/src/modules/module-lirc.c @@ -178,7 +178,7 @@ fail: u->module->core->mainloop->io_free(u->io); u->io = NULL; - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); pa_xfree(code); } diff --git a/src/modules/module-mmkbd-evdev.c b/src/modules/module-mmkbd-evdev.c index 4388e49c..7da77c0d 100644 --- a/src/modules/module-mmkbd-evdev.c +++ b/src/modules/module-mmkbd-evdev.c @@ -159,7 +159,7 @@ fail: u->module->core->mainloop->io_free(u->io); u->io = NULL; - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); } #define test_bit(bit, array) (array[bit/8] & (1<<(bit%8))) diff --git a/src/modules/module-remap-sink.c b/src/modules/module-remap-sink.c index bd86f4d6..5b2be118 100644 --- a/src/modules/module-remap-sink.c +++ b/src/modules/module-remap-sink.c @@ -255,7 +255,7 @@ static void sink_input_kill_cb(pa_sink_input *i) { pa_sink_input_unref(u->sink_input); u->sink_input = NULL; - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); } /* Called from IO thread context */ diff --git a/src/modules/module-sine.c b/src/modules/module-sine.c index 38780f24..a6324526 100644 --- a/src/modules/module-sine.c +++ b/src/modules/module-sine.c @@ -99,7 +99,7 @@ static void sink_input_kill_cb(pa_sink_input *i) { pa_sink_input_unref(u->sink_input); u->sink_input = NULL; - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); } /* Called from IO thread context */ diff --git a/src/modules/module-tunnel.c b/src/modules/module-tunnel.c index af27ce74..79ce1dd2 100644 --- a/src/modules/module-tunnel.c +++ b/src/modules/module-tunnel.c @@ -231,7 +231,7 @@ static void command_stream_killed(pa_pdispatch *pd, uint32_t command, uint32_t pa_assert(u->pdispatch == pd); pa_log_warn("Stream killed"); - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); } /* Called from main context */ @@ -262,7 +262,7 @@ static void command_suspended(pa_pdispatch *pd, uint32_t command, uint32_t tag pa_tagstruct_get_boolean(t, &suspended) < 0 || !pa_tagstruct_eof(t)) { pa_log("Invalid packet"); - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); return; } @@ -652,7 +652,7 @@ static void command_request(pa_pdispatch *pd, uint32_t command, uint32_t tag, p return; fail: - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); } #endif @@ -765,7 +765,7 @@ static void stream_get_latency_callback(pa_pdispatch *pd, uint32_t command, uint fail: - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); } /* Called from main context */ @@ -902,7 +902,7 @@ static void server_info_cb(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa return; fail: - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); } #ifdef TUNNEL_SINK @@ -979,7 +979,7 @@ static void sink_info_cb(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_t return; fail: - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); pa_proplist_free(pl); } @@ -1066,7 +1066,7 @@ static void sink_input_info_cb(pa_pdispatch *pd, uint32_t command, uint32_t tag return; fail: - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); pa_proplist_free(pl); } @@ -1142,7 +1142,7 @@ static void source_info_cb(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa return; fail: - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); pa_proplist_free(pl); } @@ -1204,7 +1204,7 @@ static void command_subscribe_event(pa_pdispatch *pd, uint32_t command, uint32 if (pa_tagstruct_getu32(t, &e) < 0 || pa_tagstruct_getu32(t, &idx) < 0) { pa_log("Invalid protocol reply"); - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); return; } @@ -1344,7 +1344,7 @@ parse_error: pa_log("Invalid reply. (Create stream)"); fail: - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); } @@ -1502,7 +1502,7 @@ static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t return; fail: - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); } /* Called from main context */ @@ -1513,7 +1513,7 @@ static void pstream_die_callback(pa_pstream *p, void *userdata) { pa_assert(u); pa_log_warn("Stream died."); - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); } /* Called from main context */ @@ -1526,7 +1526,7 @@ static void pstream_packet_callback(pa_pstream *p, pa_packet *packet, const pa_c if (pa_pdispatch_run(u->pdispatch, packet, creds, u) < 0) { pa_log("Invalid packet"); - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); return; } } @@ -1542,7 +1542,7 @@ static void pstream_memblock_callback(pa_pstream *p, uint32_t channel, int64_t o if (channel != u->channel) { pa_log("Recieved memory block on bad channel."); - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); return; } @@ -1568,7 +1568,7 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata if (!io) { pa_log("Connection failed: %s", pa_cstrerror(errno)); - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); return; } diff --git a/src/modules/module-x11-bell.c b/src/modules/module-x11-bell.c index f7be48f7..ae16b9ae 100644 --- a/src/modules/module-x11-bell.c +++ b/src/modules/module-x11-bell.c @@ -106,7 +106,7 @@ static void x11_kill_cb(pa_x11_wrapper *w, void *userdata) { u->x11_client = NULL; u->x11_wrapper = NULL; - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); } int pa__init(pa_module*m) { diff --git a/src/modules/module-x11-publish.c b/src/modules/module-x11-publish.c index 1dbc939d..c6c5bacd 100644 --- a/src/modules/module-x11-publish.c +++ b/src/modules/module-x11-publish.c @@ -126,7 +126,7 @@ static void x11_kill_cb(pa_x11_wrapper *w, void *userdata) { u->x11_client = NULL; u->x11_wrapper = NULL; - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); } int pa__init(pa_module*m) { diff --git a/src/modules/module-x11-xsmp.c b/src/modules/module-x11-xsmp.c index 0b2e375a..12e100b7 100644 --- a/src/modules/module-x11-xsmp.c +++ b/src/modules/module-x11-xsmp.c @@ -77,7 +77,7 @@ static void die_cb(SmcConn connection, SmPointer client_data){ pa_x11_wrapper_unref(u->x11); u->x11 = NULL; - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); } static void save_complete_cb(SmcConn connection, SmPointer client_data) { diff --git a/src/modules/module-zeroconf-discover.c b/src/modules/module-zeroconf-discover.c index 2fc81370..a4fbf020 100644 --- a/src/modules/module-zeroconf-discover.c +++ b/src/modules/module-zeroconf-discover.c @@ -286,7 +286,7 @@ static void browser_cb( struct tunnel *t2; if ((t2 = pa_hashmap_get(u->tunnels, t))) { - pa_module_unload_by_index(u->core, t2->module_index); + pa_module_unload_by_index(u->core, t2->module_index, TRUE); pa_hashmap_remove(u->tunnels, t2); tunnel_free(t2); } @@ -319,7 +319,7 @@ static void client_callback(AvahiClient *c, AvahiClientState state, void *userda browser_cb, u))) { pa_log("avahi_service_browser_new() failed: %s", avahi_strerror(avahi_client_errno(c))); - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); } } @@ -334,7 +334,7 @@ static void client_callback(AvahiClient *c, AvahiClientState state, void *userda browser_cb, u))) { pa_log("avahi_service_browser_new() failed: %s", avahi_strerror(avahi_client_errno(c))); - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); } } @@ -348,7 +348,7 @@ static void client_callback(AvahiClient *c, AvahiClientState state, void *userda if (!(u->client = avahi_client_new(u->avahi_poll, AVAHI_CLIENT_NO_FAIL, client_callback, u, &error))) { pa_log("avahi_client_new() failed: %s", avahi_strerror(error)); - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); } } @@ -427,7 +427,7 @@ void pa__done(pa_module*m) { struct tunnel *t; while ((t = pa_hashmap_steal_first(u->tunnels))) { - pa_module_unload_by_index(u->core, t->module_index); + pa_module_unload_by_index(u->core, t->module_index, TRUE); tunnel_free(t); } diff --git a/src/modules/module-zeroconf-publish.c b/src/modules/module-zeroconf-publish.c index 78929179..985564f4 100644 --- a/src/modules/module-zeroconf-publish.c +++ b/src/modules/module-zeroconf-publish.c @@ -539,7 +539,7 @@ static void client_callback(AvahiClient *c, AvahiClientState state, void *userda if (!(u->client = avahi_client_new(u->avahi_poll, AVAHI_CLIENT_NO_FAIL, client_callback, u, &error))) { pa_log("avahi_client_new() failed: %s", avahi_strerror(error)); - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); } } diff --git a/src/modules/rtp/module-rtp-send.c b/src/modules/rtp/module-rtp-send.c index d0d06c4d..5e542253 100644 --- a/src/modules/rtp/module-rtp-send.c +++ b/src/modules/rtp/module-rtp-send.c @@ -139,7 +139,7 @@ static void source_output_kill(pa_source_output* o) { pa_source_output_assert_ref(o); pa_assert_se(u = o->userdata); - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); pa_source_output_unlink(u->source_output); pa_source_output_unref(u->source_output); diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c index 0bd4070c..8e8f5f28 100644 --- a/src/pulsecore/cli-command.c +++ b/src/pulsecore/cli-command.c @@ -415,7 +415,7 @@ static int pa_cli_command_unload(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa return -1; } - pa_module_unload_request(m); + pa_module_unload_request(m, FALSE); return 0; } diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c index aa8de8df..5e40ea88 100644 --- a/src/pulsecore/core.c +++ b/src/pulsecore/core.c @@ -56,7 +56,7 @@ static int core_process_msg(pa_msgobject *o, int code, void *userdata, int64_t o switch (code) { case PA_CORE_MESSAGE_UNLOAD_MODULE: - pa_module_unload(c, userdata); + pa_module_unload(c, userdata, TRUE); return 0; default: diff --git a/src/pulsecore/module.c b/src/pulsecore/module.c index edd0b0a7..dbafa8c9 100644 --- a/src/pulsecore/module.c +++ b/src/pulsecore/module.c @@ -156,9 +156,6 @@ static void pa_module_free(pa_module *m) { pa_assert(m); pa_assert(m->core); - if (m->core->disallow_module_loading) - return; - pa_log_info("Unloading \"%s\" (index: #%u).", m->name, m->index); if (m->done) @@ -175,22 +172,27 @@ static void pa_module_free(pa_module *m) { pa_xfree(m); } -void pa_module_unload(pa_core *c, pa_module *m) { +void pa_module_unload(pa_core *c, pa_module *m, pa_bool_t force) { pa_assert(c); pa_assert(m); - pa_assert(c->modules); + if (m->core->disallow_module_loading && !force) + return; + if (!(m = pa_idxset_remove_by_data(c->modules, m, NULL))) return; pa_module_free(m); } -void pa_module_unload_by_index(pa_core *c, uint32_t idx) { +void pa_module_unload_by_index(pa_core *c, uint32_t idx, pa_bool_t force) { pa_module *m; pa_assert(c); pa_assert(idx != PA_IDXSET_INVALID); + if (m->core->disallow_module_loading && !force) + return; + if (!(m = pa_idxset_remove_by_index(c->modules, idx))) return; @@ -198,7 +200,6 @@ void pa_module_unload_by_index(pa_core *c, uint32_t idx) { } void pa_module_unload_all(pa_core *c) { - pa_assert(c); if (c->modules) { @@ -245,7 +246,7 @@ void pa_module_unload_unused(pa_core *c) { if (m->last_used_time + m->core->module_idle_time > now) continue; - pa_module_unload(c, m); + pa_module_unload(c, m, FALSE); } } @@ -262,12 +263,15 @@ static void defer_cb(pa_mainloop_api*api, pa_defer_event *e, void *userdata) { while ((m = pa_idxset_iterate(c->modules, &state, NULL))) if (m->unload_requested) - pa_module_unload(c, m); + pa_module_unload(c, m, TRUE); } -void pa_module_unload_request(pa_module *m) { +void pa_module_unload_request(pa_module *m, pa_bool_t force) { pa_assert(m); + if (m->core->disallow_module_loading && !force) + return; + m->unload_requested = TRUE; if (!m->core->module_defer_unload_event) diff --git a/src/pulsecore/module.h b/src/pulsecore/module.h index bb3a3f57..365ab67e 100644 --- a/src/pulsecore/module.h +++ b/src/pulsecore/module.h @@ -52,13 +52,13 @@ struct pa_module { }; pa_module* pa_module_load(pa_core *c, const char *name, const char*argument); -void pa_module_unload(pa_core *c, pa_module *m); -void pa_module_unload_by_index(pa_core *c, uint32_t idx); +void pa_module_unload(pa_core *c, pa_module *m, pa_bool_t force); +void pa_module_unload_by_index(pa_core *c, uint32_t idx, pa_bool_t force); void pa_module_unload_all(pa_core *c); void pa_module_unload_unused(pa_core *c); -void pa_module_unload_request(pa_module *m); +void pa_module_unload_request(pa_module *m, pa_bool_t force); void pa_module_set_used(pa_module*m, int used); diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index 3c3c1e5f..9378477b 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -3568,7 +3568,7 @@ static void command_unload_module(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED m = pa_idxset_get_by_index(c->protocol->core->modules, idx); CHECK_VALIDITY(c->pstream, m, tag, PA_ERR_NOENTITY); - pa_module_unload_request(m); + pa_module_unload_request(m, FALSE); pa_pstream_send_simple_ack(c->pstream, tag); } |