summaryrefslogtreecommitdiffstats
path: root/src/pulsecore/pdispatch.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pulsecore/pdispatch.c')
-rw-r--r--src/pulsecore/pdispatch.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/pulsecore/pdispatch.c b/src/pulsecore/pdispatch.c
index 737b1b98..e6a6ae4d 100644
--- a/src/pulsecore/pdispatch.c
+++ b/src/pulsecore/pdispatch.c
@@ -1,5 +1,3 @@
-/* $Id$ */
-
/***
This file is part of PulseAudio.
@@ -38,6 +36,7 @@
#include <pulsecore/core-util.h>
#include <pulsecore/macro.h>
#include <pulsecore/refcnt.h>
+#include <pulsecore/flist.h>
#include "pdispatch.h"
@@ -98,6 +97,8 @@ static const char *command_names[PA_COMMAND_MAX] = {
#endif
+PA_STATIC_FLIST_DECLARE(reply_infos, 0, pa_xfree);
+
struct reply_info {
pa_pdispatch *pdispatch;
PA_LLIST_FIELDS(struct reply_info);
@@ -129,7 +130,8 @@ static void reply_info_free(struct reply_info *r) {
PA_LLIST_REMOVE(struct reply_info, r->pdispatch->replies, r);
- pa_xfree(r);
+ if (pa_flist_push(PA_STATIC_FLIST_GET(reply_infos), r) < 0)
+ pa_xfree(r);
}
pa_pdispatch* pa_pdispatch_new(pa_mainloop_api *mainloop, const pa_pdispatch_cb_t*table, unsigned entries) {
@@ -190,7 +192,7 @@ int pa_pdispatch_run(pa_pdispatch *pd, pa_packet*packet, const pa_creds *creds,
uint32_t tag, command;
pa_tagstruct *ts = NULL;
int ret = -1;
-
+
pa_assert(pd);
pa_assert(PA_REFCNT_VALUE(pd) >= 1);
pa_assert(packet);
@@ -255,7 +257,7 @@ finish:
static void timeout_callback(pa_mainloop_api*m, pa_time_event*e, PA_GCC_UNUSED const struct timeval *tv, void *userdata) {
struct reply_info*r = userdata;
-
+
pa_assert(r);
pa_assert(r->time_event == e);
pa_assert(r->pdispatch);
@@ -268,12 +270,14 @@ static void timeout_callback(pa_mainloop_api*m, pa_time_event*e, PA_GCC_UNUSED c
void pa_pdispatch_register_reply(pa_pdispatch *pd, uint32_t tag, int timeout, pa_pdispatch_cb_t cb, void *userdata, pa_free_cb_t free_cb) {
struct reply_info *r;
struct timeval tv;
-
+
pa_assert(pd);
pa_assert(PA_REFCNT_VALUE(pd) >= 1);
pa_assert(cb);
- r = pa_xnew(struct reply_info, 1);
+ if (!(r = pa_flist_pop(PA_STATIC_FLIST_GET(reply_infos))))
+ r = pa_xnew(struct reply_info, 1);
+
r->pdispatch = pd;
r->callback = cb;
r->userdata = userdata;