module-protocol-native: make demarshaling safe vs. reentering

The message structures returned by pw_protocol_native_connection_get_next
point to data that is contained in the buffer of the connection.

The data was invalidated when pw_protocol_native_connection_get_next was
called the next time, which made the connection loop non-reentrant, in
cases where it was re-entered from demarshal callbacks.

Fix this by allocating new buffers when reentering and stashing the old
buffers onto a stack. The returned message structure is also stored on
the stack to make lifetimes to match.
This commit is contained in:
Pauli Virtanen 2021-01-10 16:41:49 +02:00 committed by Wim Taymans
parent 09a690b123
commit 23f010541f
3 changed files with 156 additions and 3 deletions

View file

@ -99,6 +99,9 @@ pw_protocol_native_connection_flush(struct pw_protocol_native_connection *conn);
int
pw_protocol_native_connection_clear(struct pw_protocol_native_connection *conn);
void pw_protocol_native_connection_enter(struct pw_protocol_native_connection *conn);
void pw_protocol_native_connection_leave(struct pw_protocol_native_connection *conn);
#ifdef __cplusplus
} /* extern "C" */
#endif