summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Catanzaro <mcatanzaro@gnome.org>2020-01-26 14:28:58 -0600
committerMichael Catanzaro <mcatanzaro@gnome.org>2020-09-01 13:24:12 -0500
commit629a14a438f91ad12991b30674e2aece9c2189c1 (patch)
treef9020f7003294bd203fe257936e193c44f6d5ee3
parent1ce0dd8d99e88d24fab3e4b661dac60683346f9f (diff)
downloadglib-networking-629a14a438f91ad12991b30674e2aece9c2189c1.tar.gz
Hold op_mutex during base_check
I'm not comfortable with accessing priv members without the mutex.
-rw-r--r--tls/base/gtlsconnection-base.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/tls/base/gtlsconnection-base.c b/tls/base/gtlsconnection-base.c
index 1d362fe..d77cdf5 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 {