mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 06:25:19 +00:00
remote_daemon_stream: Fix @client locking in daemonStreamFilter()
When dispatching a message read from client it is first passed through registered filters. If one of the filters consumes the message no further processing of the message is done. However, the filter callbacks are called with the client object locked. This breaks lock ordering in case of virStream filter, we always acquire stream private data lock without the client object locked. In other words, the daemonStreamFilter() does not follow the lock ordering. Signed-off-by: LanceLiu <liu.lance.89@gmail.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
3a085d221e
commit
8ecab214de
@ -286,14 +286,16 @@ daemonStreamEvent(virStreamPtr st, int events, void *opaque)
|
||||
* -1 on fatal client error
|
||||
*/
|
||||
static int
|
||||
daemonStreamFilter(virNetServerClientPtr client G_GNUC_UNUSED,
|
||||
daemonStreamFilter(virNetServerClientPtr client,
|
||||
virNetMessagePtr msg,
|
||||
void *opaque)
|
||||
{
|
||||
daemonClientStream *stream = opaque;
|
||||
int ret = 0;
|
||||
|
||||
virObjectUnlock(client);
|
||||
virMutexLock(&stream->priv->lock);
|
||||
virObjectLock(client);
|
||||
|
||||
if (msg->header.type != VIR_NET_STREAM &&
|
||||
msg->header.type != VIR_NET_STREAM_HOLE)
|
||||
|
@ -40,6 +40,9 @@ typedef void (*virNetServerClientDispatchFunc)(virNetServerClientPtr client,
|
||||
virNetMessagePtr msg,
|
||||
void *opaque);
|
||||
|
||||
/*
|
||||
* @client is locked when this callback is called
|
||||
*/
|
||||
typedef int (*virNetServerClientFilterFunc)(virNetServerClientPtr client,
|
||||
virNetMessagePtr msg,
|
||||
void *opaque);
|
||||
|
Loading…
Reference in New Issue
Block a user