srbchannel: Defer reading when setting up read callback

Calling the callback while setting it up can make things
complicated for clients, as the callback can do arbitrarily
things.

In this case, a protocol error caused the srbchannel to be
owned by both the pstream and the native connection.

Now the read callback is deferred, making sure the callback
is called from a cleaner context where errors are handled
appropriately.

Reported-by: Tanu Kaskinen <tanu.kaskinen@linux.intel.com>
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
This commit is contained in:
David Henningsson 2014-09-17 08:56:51 +02:00
parent f8aa823998
commit e521d38787
2 changed files with 21 additions and 6 deletions

View file

@ -52,9 +52,6 @@ size_t pa_srbchannel_read(pa_srbchannel *sr, void *data, size_t l);
*
* Return false to abort all processing (e g if the srbchannel has been freed during the callback).
* Otherwise return true.
*
* Note that the callback will be called immediately, to be able to process stuff that
* might already be in the buffer.
*/
typedef bool (*pa_srbchannel_cb_t)(pa_srbchannel *sr, void *userdata);
void pa_srbchannel_set_callback(pa_srbchannel *sr, pa_srbchannel_cb_t callback, void *userdata);