Ori.livneh has submitted this change and it was merged.

Change subject: Explicitly close streams in serve_xml()
......................................................................


Explicitly close streams in serve_xml()

Glib's documentation is not clear about whether it's the responsibility of
GThreadedSocketService callbacks to close & free the connection, and glib's
slice allocator makes using tools like Valgrind to check for uncollected
garbage difficult. After lots of experimentation and code-reading, I think I
have it right: it's up to us to close and unref the GUnixInputStream that we
create, but we should not attempt to free the GSocketConnection. If we don't
close it, it'll get closed anyway, but better to be explicit.

Change-Id: I2bb87ce95d4b0aa9bd40651e5b280cf5705c7368
---
M Makefile
M mwprof.c
2 files changed, 7 insertions(+), 2 deletions(-)

Approvals:
  Ori.livneh: Verified; Looks good to me, approved



diff --git a/Makefile b/Makefile
index 586bc57..23fb3e2 100644
--- a/Makefile
+++ b/Makefile
@@ -7,3 +7,7 @@
 
 clean:
        rm -f mwprof
+
+install:
+       mkdir -p /srv/deployment/mwprof/mwprof
+       cp mwprof /srv/deployment/mwprof/mwprof/mwprof
diff --git a/mwprof.c b/mwprof.c
index 05f7bef..616b5c2 100644
--- a/mwprof.c
+++ b/mwprof.c
@@ -16,7 +16,6 @@
 
 #define GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_32
 
-#include <errno.h>
 #include <glib.h>
 #include <gio/gio.h>
 #include <gio/gunixinputstream.h>
@@ -57,10 +56,12 @@
     out = g_io_stream_get_output_stream(G_IO_STREAM(connection));
     g_output_stream_splice(out, in, G_OUTPUT_STREAM_SPLICE_NONE, NULL, NULL);
 
+    g_output_stream_close(out, NULL, NULL);
+    g_input_stream_close(in, NULL, NULL);
     g_object_unref(in);
     fclose(temp);
 
-    return FALSE;
+    return TRUE;
 }
 
 /* Process profiling samples coming in via UDP. */

-- 
To view, visit https://gerrit.wikimedia.org/r/104132
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I2bb87ce95d4b0aa9bd40651e5b280cf5705c7368
Gerrit-PatchSet: 2
Gerrit-Project: operations/software/mwprof
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to