[glib-networking/mcatanzaro/#20: 13/18] Hold op_mutex during base_check
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking/mcatanzaro/#20: 13/18] Hold op_mutex during base_check
- Date: Tue, 1 Sep 2020 18:24:32 +0000 (UTC)
commit 629a14a438f91ad12991b30674e2aece9c2189c1
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sun Jan 26 14:28:58 2020 -0600
Hold op_mutex during base_check
I'm not comfortable with accessing priv members without the mutex.
tls/base/gtlsconnection-base.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/tls/base/gtlsconnection-base.c b/tls/base/gtlsconnection-base.c
index 1d362fed..d77cdf51 100644
--- a/tls/base/gtlsconnection-base.c
+++ b/tls/base/gtlsconnection-base.c
@@ -902,10 +902,15 @@ g_tls_connection_base_check (GTlsConnectionBase *tls,
GIOCondition condition)
{
GTlsConnectionBasePrivate *priv = g_tls_connection_base_get_instance_private (tls);
+ gboolean ret = FALSE;
+
+ g_mutex_lock (&priv->op_mutex);
- /* Racy, but worst case is that we just get WOULD_BLOCK back */
if (priv->need_finish_handshake)
- return TRUE;
+ {
+ ret = TRUE;
+ goto out;
+ }
/* If op or close is in progress, then tls_istream and tls_ostream are
* blocked, regardless of the base stream status. Note this also
@@ -913,10 +918,14 @@ g_tls_connection_base_check (GTlsConnectionBase *tls,
*/
if (((condition & G_IO_IN) && (priv->reading || priv->read_closing)) ||
((condition & G_IO_OUT) && (priv->writing || priv->write_closing)))
- return FALSE;
+ goto out;
/* Defer to the base stream or GDatagramBased. */
- return g_tls_connection_base_base_check (tls, condition);
+ ret = g_tls_connection_base_base_check (tls, condition);
+
+out:
+ g_mutex_unlock (&priv->op_mutex);
+ return ret;
}
typedef struct {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]