[glib-networking/wip/tlssplit: 4/6] base: add abstraction for push_io and pop_io
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking/wip/tlssplit: 4/6] base: add abstraction for push_io and pop_io
- Date: Tue, 13 Oct 2015 09:54:05 +0000 (UTC)
commit e164f17c1dfaefc57a214b2c533e90079cf1b156
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Sun Aug 16 13:53:16 2015 +0200
base: add abstraction for push_io and pop_io
This is needed because we need to set the cancellable or whether
the operation is blocking to the bio abstraction.
tls/base/gtlsconnection-base.c | 55 +++++++++++++++++++++++++++++-----------
tls/base/gtlsconnection-base.h | 9 ++++++
2 files changed, 49 insertions(+), 15 deletions(-)
---
diff --git a/tls/base/gtlsconnection-base.c b/tls/base/gtlsconnection-base.c
index e332a28..46298a7 100644
--- a/tls/base/gtlsconnection-base.c
+++ b/tls/base/gtlsconnection-base.c
@@ -388,14 +388,12 @@ yield_op (GTlsConnectionBase *tls,
g_mutex_unlock (&tls->op_mutex);
}
-void
-g_tls_connection_base_push_io (GTlsConnectionBase *tls,
- GIOCondition direction,
- gboolean blocking,
- GCancellable *cancellable)
+static void
+g_tls_connection_base_real_push_io (GTlsConnectionBase *tls,
+ GIOCondition direction,
+ gboolean blocking,
+ GCancellable *cancellable)
{
- g_assert (direction & (G_IO_IN | G_IO_OUT));
-
if (direction & G_IO_IN)
{
tls->read_blocking = blocking;
@@ -411,16 +409,26 @@ g_tls_connection_base_push_io (GTlsConnectionBase *tls,
}
}
-GTlsConnectionBaseStatus
-g_tls_connection_base_pop_io (GTlsConnectionBase *tls,
- GIOCondition direction,
- gboolean success,
- GError **error)
+void
+g_tls_connection_base_push_io (GTlsConnectionBase *tls,
+ GIOCondition direction,
+ gboolean blocking,
+ GCancellable *cancellable)
{
- GError *my_error = NULL;
-
g_assert (direction & (G_IO_IN | G_IO_OUT));
- g_assert (!error || !*error);
+ g_return_if_fail (G_IS_TLS_CONNECTION_BASE (tls));
+
+ G_TLS_CONNECTION_BASE_GET_CLASS (tls)->push_io (tls, direction,
+ blocking, cancellable);
+}
+
+static GTlsConnectionBaseStatus
+g_tls_connection_base_real_pop_io (GTlsConnectionBase *tls,
+ GIOCondition direction,
+ gboolean success,
+ GError **error)
+{
+ GError *my_error = NULL;
if (direction & G_IO_IN)
{
@@ -464,6 +472,20 @@ g_tls_connection_base_pop_io (GTlsConnectionBase *tls,
return G_TLS_CONNECTION_BASE_ERROR;
}
+GTlsConnectionBaseStatus
+g_tls_connection_base_pop_io (GTlsConnectionBase *tls,
+ GIOCondition direction,
+ gboolean success,
+ GError **error)
+{
+ g_assert (direction & (G_IO_IN | G_IO_OUT));
+ g_assert (!error || !*error);
+ g_return_val_if_fail (G_IS_TLS_CONNECTION_BASE (tls), G_TLS_CONNECTION_BASE_ERROR);
+
+ return G_TLS_CONNECTION_BASE_GET_CLASS (tls)->pop_io (tls, direction,
+ success, error);
+}
+
gboolean
g_tls_connection_base_check (GTlsConnectionBase *tls,
GIOCondition condition)
@@ -1136,6 +1158,9 @@ g_tls_connection_base_class_init (GTlsConnectionBaseClass *klass)
iostream_class->close_async = g_tls_connection_base_close_async;
iostream_class->close_finish = g_tls_connection_base_close_finish;
+ klass->push_io = g_tls_connection_base_real_push_io;
+ klass->pop_io = g_tls_connection_base_real_pop_io;
+
g_object_class_override_property (gobject_class, PROP_BASE_IO_STREAM, "base-io-stream");
g_object_class_override_property (gobject_class, PROP_REQUIRE_CLOSE_NOTIFY, "require-close-notify");
g_object_class_override_property (gobject_class, PROP_REHANDSHAKE_MODE, "rehandshake-mode");
diff --git a/tls/base/gtlsconnection-base.h b/tls/base/gtlsconnection-base.h
index 9f941b8..e77ec19 100644
--- a/tls/base/gtlsconnection-base.h
+++ b/tls/base/gtlsconnection-base.h
@@ -53,6 +53,15 @@ struct _GTlsConnectionBaseClass
GTlsConnectionBaseStatus (*complete_handshake) (GTlsConnectionBase *tls,
GError **error);
+ void (*push_io) (GTlsConnectionBase *tls,
+ GIOCondition direction,
+ gboolean blocking,
+ GCancellable *cancellable);
+ GTlsConnectionBaseStatus (*pop_io) (GTlsConnectionBase *tls,
+ GIOCondition direction,
+ gboolean success,
+ GError **error);
+
GTlsConnectionBaseStatus (*read_fn) (GTlsConnectionBase *tls,
void *buffer,
gsize count,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]