mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
rfbsrc: Serialize write operations
Currently we send key events from seperate threads. IOStream does not allow concurrent write operations, so protect this operation using a mutex.
This commit is contained in:
parent
c8d2e234c4
commit
459bdaae3f
2 changed files with 11 additions and 0 deletions
|
@ -69,6 +69,8 @@ rfb_decoder_new (void)
|
|||
decoder->data_len = 0;
|
||||
decoder->error = NULL;
|
||||
|
||||
g_mutex_init (&decoder->write_lock);
|
||||
|
||||
return decoder;
|
||||
}
|
||||
|
||||
|
@ -87,6 +89,7 @@ rfb_decoder_free (RfbDecoder * decoder)
|
|||
g_clear_object (&decoder->socket_client);
|
||||
g_clear_error (&decoder->error);
|
||||
g_free (decoder->data);
|
||||
g_mutex_clear (&decoder->write_lock);
|
||||
g_free (decoder);
|
||||
}
|
||||
|
||||
|
@ -217,12 +220,16 @@ rfb_decoder_send (RfbDecoder * decoder, guint8 * buffer, guint len)
|
|||
g_return_val_if_fail (buffer != NULL, 0);
|
||||
g_return_val_if_fail (len > 0, 0);
|
||||
|
||||
g_mutex_lock (&decoder->write_lock);
|
||||
|
||||
out = g_io_stream_get_output_stream (G_IO_STREAM (decoder->connection));
|
||||
|
||||
if (!g_output_stream_write_all (out, buffer, len, NULL, decoder->cancellable,
|
||||
&err))
|
||||
goto send_error;
|
||||
|
||||
g_mutex_unlock (&decoder->write_lock);
|
||||
|
||||
return TRUE;
|
||||
|
||||
send_error:
|
||||
|
@ -237,6 +244,7 @@ send_error:
|
|||
}
|
||||
}
|
||||
g_clear_error (&err);
|
||||
g_mutex_unlock (&decoder->write_lock);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,6 +94,9 @@ struct _RfbDecoder
|
|||
/* some many used values */
|
||||
guint bytespp;
|
||||
guint line_size;
|
||||
|
||||
/* Seriliaze writes operations */
|
||||
GMutex write_lock;
|
||||
};
|
||||
|
||||
RfbDecoder *rfb_decoder_new (void);
|
||||
|
|
Loading…
Reference in a new issue