<div dir="ltr">Hi<br><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 19, 2015 at 4:34 PM, Victor Toso <span dir="ltr"><<a href="mailto:victortoso@redhat.com" target="_blank">victortoso@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">PipeInputStream and PipeOutputStream should not fail when creating<br>
GPollableStream source. It is already checked and unref in case of<br>
existing source.<br>
---<br>
 gtk/giopipe.c | 6 ------<br>
 1 file changed, 6 deletions(-)<br>
<br>
diff --git a/gtk/giopipe.c b/gtk/giopipe.c<br>
index 440cae9..32fa4fa 100644<br>
--- a/gtk/giopipe.c<br>
+++ b/gtk/giopipe.c<br>
@@ -234,9 +234,6 @@ pipe_input_stream_create_source (GPollableInputStream *stream,<br>
     PipeInputStream *self = PIPE_INPUT_STREAM(stream);<br>
     GSource *pollable_source;<br>
<br>
-    g_return_val_if_fail (self->source == NULL ||<br>
-                          g_source_is_destroyed (self->source), NULL);<br>
-<br>
     if (self->source && g_source_is_destroyed (self->source))<br>
         g_source_unref (self->source);<br>
<br>
@@ -416,9 +413,6 @@ pipe_output_stream_create_source (GPollableOutputStream *stream,<br>
     PipeOutputStream *self = PIPE_OUTPUT_STREAM(stream);<br>
     GSource *pollable_source;<br>
<br>
-    g_return_val_if_fail (self->source == NULL ||<br>
-                          g_source_is_destroyed (self->source), NULL);<br>
-<br>
     if (self->source && g_source_is_destroyed (self->source))<br>
         g_source_unref (self->source);<br>
<span class=""></span></blockquote><div><br></div><div>The check was also preventing concurrent read/write. Without this check, it is possible to have several "active" sources on the same stream. However, it will notify only the last reader/writer. With your test though, the operations are sequential, the old source is destroyed when the loop ends the dispatch(). However, to avoid leaks, the  if (self->source && g_source_is_destroyed (self->source)) check must be changed to if (self->source).<br><br></div><div>This is potentially dangerous change. I would be okay with it, but it needs a strong warning, perhaps a debug() message. Other solution is to track all sources and notify the one that are not destroyed.<br><br><br><br></div></div>-- <br><div class="gmail_signature">Marc-André Lureau</div>
</div></div></div>