[glib-networking/mcatanzaro/#20: 5/10] Implement tls_source_sync() using check functions
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking/mcatanzaro/#20: 5/10] Implement tls_source_sync() using check functions
- Date: Tue, 25 Aug 2020 20:54:23 +0000 (UTC)
commit b32dd1977ed0e1152d18762eb150476ed55a6cc1
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sun Jan 26 14:26:38 2020 -0600
Implement tls_source_sync() using check functions
This is semantically elegant, and will help avoid code duplication.
tls/base/gtlsconnection-base.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
---
diff --git a/tls/base/gtlsconnection-base.c b/tls/base/gtlsconnection-base.c
index 7001104..1d362fe 100644
--- a/tls/base/gtlsconnection-base.c
+++ b/tls/base/gtlsconnection-base.c
@@ -950,30 +950,25 @@ tls_source_sync (GTlsConnectionBaseSource *tls_source)
{
GTlsConnectionBase *tls = tls_source->tls;
GTlsConnectionBasePrivate *priv = g_tls_connection_base_get_instance_private (tls);
- gboolean io_waiting, op_waiting;
+ gboolean check;
+ gboolean base_check;
+ gboolean io_waiting;
+ gboolean op_waiting;
/* Was the source destroyed earlier in this main context iteration? */
if (g_source_is_destroyed ((GSource *)tls_source))
return;
- g_mutex_lock (&priv->op_mutex);
- if (((tls_source->condition & G_IO_IN) && priv->reading) ||
- ((tls_source->condition & G_IO_OUT) && priv->writing) ||
- (priv->handshaking && !priv->need_finish_handshake))
- op_waiting = TRUE;
- else
- op_waiting = FALSE;
+ check = g_tls_connection_base_check (tls, tls_source->condition);
+ base_check = g_tls_connection_base_base_check (tls, tls_source->condition);
- if (!op_waiting && !priv->need_handshake &&
- !priv->need_finish_handshake)
- io_waiting = TRUE;
- else
- io_waiting = FALSE;
- g_mutex_unlock (&priv->op_mutex);
+ op_waiting = !check && base_check;
+ io_waiting = check && !base_check;
if (op_waiting == tls_source->op_waiting &&
io_waiting == tls_source->io_waiting)
return;
+
tls_source->op_waiting = op_waiting;
tls_source->io_waiting = io_waiting;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]