[wing] Fix cancellable on non-iocp streams
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [wing] Fix cancellable on non-iocp streams
- Date: Thu, 30 May 2019 08:04:07 +0000 (UTC)
commit 9e8f1d37b4f7babb158847ac38ed9756c0cd2da5
Author: Davide Benotto <benotto amazon com>
Date: Tue May 14 12:40:13 2019 +0200
Fix cancellable on non-iocp streams
Cancellable was not checked, and the tasks was continuing instead of
being cancelled.
wing/winginputstream.c | 15 +++++++++++++++
wing/wingoutputstream.c | 15 +++++++++++++++
2 files changed, 30 insertions(+)
---
diff --git a/wing/winginputstream.c b/wing/winginputstream.c
index 1bacf7c..28bead8 100644
--- a/wing/winginputstream.c
+++ b/wing/winginputstream.c
@@ -243,12 +243,27 @@ read_async_ready (HANDLE handle,
WingInputStream *wing_stream;
WingInputStreamPrivate *priv;
GTask *task = user_data;
+ GCancellable *cancellable;
DWORD nread;
gboolean result;
wing_stream = g_task_get_source_object (task);
priv = wing_input_stream_get_instance_private (wing_stream);
+ cancellable = g_task_get_cancellable (task);
+ if (cancellable != NULL && g_cancellable_is_cancelled (cancellable))
+ {
+ CancelIo (priv->handle);
+ ResetEvent (priv->overlap.hEvent);
+
+ g_task_return_new_error (task, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ "Error reading from handle: the operation is cancelled");
+ g_object_unref (task);
+
+ return G_SOURCE_REMOVE;
+ }
+
result = GetOverlappedResult (priv->overlap.hEvent, &priv->overlap, &nread, FALSE);
if (!result && GetLastError () == ERROR_IO_INCOMPLETE)
{
diff --git a/wing/wingoutputstream.c b/wing/wingoutputstream.c
index ef3c9ba..d544d3d 100644
--- a/wing/wingoutputstream.c
+++ b/wing/wingoutputstream.c
@@ -230,12 +230,27 @@ write_async_ready (HANDLE handle,
WingOutputStream *wing_stream;
WingOutputStreamPrivate *priv;
GTask *task = user_data;
+ GCancellable *cancellable;
DWORD nwritten;
gboolean result;
wing_stream = g_task_get_source_object (task);
priv = wing_output_stream_get_instance_private (wing_stream);
+ cancellable = g_task_get_cancellable (task);
+ if (cancellable != NULL && g_cancellable_is_cancelled (cancellable))
+ {
+ CancelIo (priv->handle);
+ ResetEvent (priv->overlap.hEvent);
+
+ g_task_return_new_error (task, G_IO_ERROR,
+ G_IO_ERROR_CANCELLED,
+ "Error reading from handle: the operation is cancelled");
+ g_object_unref (task);
+
+ return G_SOURCE_REMOVE;
+ }
+
result = GetOverlappedResult (priv->overlap.hEvent, &priv->overlap, &nwritten, FALSE);
if (!result && GetLastError () == ERROR_IO_INCOMPLETE)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]