diff options
author | Tim-Philipp Müller <tim@centricular.net> | 2006-12-12 16:10:21 +0000 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.net> | 2006-12-12 16:10:21 +0000 |
commit | d3c0b705eb74d4f33d8232ae6e67c842ea54bd30 (patch) | |
tree | 03bddb28fd23b7471e5f85f6dd41a4b636b6d8cb | |
parent | 9e71250a69ece783fddcc98d0a324b02d4c4e0ac (diff) | |
download | gst-plugins-bad-d3c0b705eb74d4f33d8232ae6e67c842ea54bd30.tar.gz gst-plugins-bad-d3c0b705eb74d4f33d8232ae6e67c842ea54bd30.tar.bz2 gst-plugins-bad-d3c0b705eb74d4f33d8232ae6e67c842ea54bd30.zip |
ext/neon/gstneonhttpsrc.c: Fix minor mem leak in redirect code.
Original commit message from CVS:
* ext/neon/gstneonhttpsrc.c: (gst_neonhttp_src_create),
(send_request_and_redirect):
Fix minor mem leak in redirect code.
* tests/check/Makefile.am:
* tests/check/elements/.cvsignore:
* tests/check/elements/neonhttpsrc.c: (handoff_cb),
(GST_START_TEST), (neonhttpsrc_suite):
* tests/check/gst-plugins-bad.supp:
Add super-basic unit test for #384140.
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | ext/neon/gstneonhttpsrc.c | 6 | ||||
-rw-r--r-- | tests/check/Makefile.am | 7 | ||||
-rw-r--r-- | tests/check/elements/.gitignore | 1 | ||||
-rw-r--r-- | tests/check/elements/neonhttpsrc.c | 103 | ||||
-rw-r--r-- | tests/check/gst-plugins-bad.supp | 9 |
6 files changed, 137 insertions, 2 deletions
@@ -2,6 +2,19 @@ * ext/neon/gstneonhttpsrc.c: (gst_neonhttp_src_create), (send_request_and_redirect): + Fix minor mem leak in redirect code. + + * tests/check/Makefile.am: + * tests/check/elements/.cvsignore: + * tests/check/elements/neonhttpsrc.c: (handoff_cb), + (GST_START_TEST), (neonhttpsrc_suite): + * tests/check/gst-plugins-bad.supp: + Add super-basic unit test for #384140. + +2006-12-12 Tim-Philipp Müller <tim at centricular dot net> + + * ext/neon/gstneonhttpsrc.c: (gst_neonhttp_src_create), + (send_request_and_redirect): Set offset on buffers pushed out (id3demux gets confused if the first buffer does not have an offset of 0). Fixes #384140. diff --git a/ext/neon/gstneonhttpsrc.c b/ext/neon/gstneonhttpsrc.c index 5c747139..5777dbb4 100644 --- a/ext/neon/gstneonhttpsrc.c +++ b/ext/neon/gstneonhttpsrc.c @@ -344,6 +344,8 @@ gst_neonhttp_src_create (GstPushSrc * psrc, GstBuffer ** outbuf) if (G_UNLIKELY (read < 0)) goto read_error; + GST_LOG_OBJECT (src, "returning %u bytes", GST_BUFFER_SIZE (*outbuf)); + done: return ret; @@ -411,8 +413,6 @@ send_request_and_redirect (GstNeonhttpSrc * src, gboolean do_redir) gint res; gint http_status = 0; - const gchar *redir = g_strdup (""); - guint request_count = 0; #ifndef GST_DISABLE_GST_DEBUG @@ -454,6 +454,8 @@ send_request_and_redirect (GstNeonhttpSrc * src, gboolean do_redir) * Reload the HTTP request with a new URI value */ http_status = ne_get_status (src->request)->code; if (http_status == 302) { + const gchar *redir; + /* the new URI value to go when redirecting can be found on the 'Location' HTTP header */ redir = ne_get_response_header (src->request, "Location"); if (redir != NULL) { diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index 4527d909..b086f354 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -32,6 +32,12 @@ else check_mpeg2enc = endif +if USE_NEON +check_neon = elements/neonhttpsrc +else +check_neon = +endif + if USE_WAVPACK check_wavpack = \ elements/wavpackparse \ @@ -52,6 +58,7 @@ VALGRIND_TESTS_DISABLE = \ check_PROGRAMS = \ $(check_mpeg2enc) \ + $(check_neon) \ elements/rganalysis \ elements/videocrop \ $(check_wavpack) \ diff --git a/tests/check/elements/.gitignore b/tests/check/elements/.gitignore index 7d3825fc..3216d000 100644 --- a/tests/check/elements/.gitignore +++ b/tests/check/elements/.gitignore @@ -10,3 +10,4 @@ wavpackparse videocrop rganalysis y4menc +neonhttpsrc.c diff --git a/tests/check/elements/neonhttpsrc.c b/tests/check/elements/neonhttpsrc.c new file mode 100644 index 00000000..4d4a892f --- /dev/null +++ b/tests/check/elements/neonhttpsrc.c @@ -0,0 +1,103 @@ +/* GStreamer unit tests for the neonhttpsrc element + * Copyright (C) 2006 Tim-Philipp Müller <tim centricular net> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <gst/check/gstcheck.h> + +static void +handoff_cb (GstElement * fakesink, GstBuffer * buf, GstPad * pad, + GstBuffer ** p_outbuf) +{ + GST_LOG ("handoff, buf = %p", buf); + if (*p_outbuf == NULL) + *p_outbuf = gst_buffer_ref (buf); +} + +GST_START_TEST (test_first_buffer_has_offset) +{ + GstStateChangeReturn ret; + GstElement *pipe, *src, *sink; + GstBuffer *buf = NULL; + + pipe = gst_pipeline_new (NULL); + + src = gst_element_factory_make ("neonhttpsrc", NULL); + fail_unless (src != NULL); + + sink = gst_element_factory_make ("fakesink", NULL); + fail_unless (sink != NULL); + + gst_bin_add (GST_BIN (pipe), src); + gst_bin_add (GST_BIN (pipe), sink); + fail_unless (gst_element_link (src, sink)); + + g_object_set (src, "location", "http://www.google.comadfadf", NULL); + g_object_set (src, "automatic-redirect", TRUE, NULL); + + g_object_set (sink, "signal-handoffs", TRUE, NULL); + g_signal_connect (sink, "preroll-handoff", G_CALLBACK (handoff_cb), &buf); + + ret = gst_element_set_state (pipe, GST_STATE_PAUSED); + if (ret != GST_STATE_CHANGE_ASYNC) { + GST_DEBUG ("failed to start up neon http src, ret = %d", ret); + goto done; + } + + /* don't wait for more than 10 seconds */ + ret = gst_element_get_state (pipe, NULL, NULL, 10 * GST_SECOND); + GST_LOG ("ret = %u", ret); + + if (buf == NULL) { + /* we want to test the buffer offset, nothing else; if there's a failure + * it might be for lots of reasons (no network connection, whatever), we're + * not interested in those */ + GST_DEBUG ("didn't manage to get data within 10 seconds, skipping test"); + goto done; + } + + GST_DEBUG ("buffer offset = %" G_GUINT64_FORMAT, GST_BUFFER_OFFSET (buf)); + + /* first buffer should have a 0 offset */ + fail_unless (GST_BUFFER_OFFSET (buf) == 0); + gst_buffer_unref (buf); + +done: + + gst_element_set_state (pipe, GST_STATE_NULL); + gst_object_unref (pipe); +} + +GST_END_TEST; + +static Suite * +neonhttpsrc_suite (void) +{ + Suite *s = suite_create ("neonhttpsrc"); + TCase *tc_chain = tcase_create ("general"); + + suite_add_tcase (s, tc_chain); + tcase_add_test (tc_chain, test_first_buffer_has_offset); + + return s; +} + +GST_CHECK_MAIN (neonhttpsrc); diff --git a/tests/check/gst-plugins-bad.supp b/tests/check/gst-plugins-bad.supp index e69de29b..93d50de8 100644 --- a/tests/check/gst-plugins-bad.supp +++ b/tests/check/gst-plugins-bad.supp @@ -0,0 +1,9 @@ +{ + <suppression for libneon-25.5dfsg5 on tpm's edgy/x86> + Memcheck:Param + socketcall.sendto(msg) + fun:sendto + fun:getaddrinfo + fun:ne_addr_resolve + fun:ne_begin_request +} |