[glib-networking/mcatanzaro/#20: 3/6] Hold op_mutex during base_check
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking/mcatanzaro/#20: 3/6] Hold op_mutex during base_check
- Date: Sun, 26 Jan 2020 20:50:22 +0000 (UTC)
commit 6ca388a217268623a15627436b55933911638a4b
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 b35cee4..b0df15e 100644
--- a/tls/base/gtlsconnection-base.c
+++ b/tls/base/gtlsconnection-base.c
@@ -896,10 +896,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
@@ -907,10 +912,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]