Byron Young
2012-Dec-11 04:18 UTC
[Icecast-dev] Adding additional mount info to xsl stylesheet
The following patch attempts to make the source client user agent and the max listener client connection duration information available to (icecast 2.3.2) xsl stylesheets. Will there be any memory leak issues in the lower level functions like the acl, etc. when the source is disconnected, when servicing queries, or otherwise? BEGIN icecast-2.3.2-moremntinfo.patch diff --git src/source.c src/source.c index 02bfc74..7e90d34 100644 --- src/source.c +++ src/source.c @@ -614,6 +614,10 @@ static void source_init (source_t *source) stats_event_args (source->mount, "listeners", "%lu", source->listeners); stats_event_args (source->mount, "listener_peak", "%lu", source->peak_listeners); stats_event_time (source->mount, "stream_start"); + stats_event_args (source->mount, "max_listener_duration", "%lu", source->max_listener_duration); + + const char * user_agent = httpp_getvar (source->client->parser, "user-agent"); + stats_event_args (source->mount, "user-agent", "%s", user_agent); DEBUG0("Source creation complete"); source->last_read = time (NULL); @@ -947,6 +951,8 @@ static void source_apply_mount (source_t *source, mount_proxy *mountinfo) source->max_listeners = mountinfo->max_listeners; source->fallback_override = mountinfo->fallback_override; source->hidden = mountinfo->hidden; + source->max_listener_duration = mountinfo->max_listener_duration; + source->user_agent = httpp_getvar (source->client->parser, "user-agent"); } /* if a setting is available in the mount details then use it, else diff --git src/source.h src/source.h index 7a526a0..9416222 100644 --- src/source.h +++ src/source.h @@ -52,6 +52,9 @@ typedef struct source_tag unsigned long peak_listeners; unsigned long listeners; unsigned long prev_listeners; + unsigned long max_listener_duration; + const char * user_agent; + long max_listeners; int yp_public; int fallback_override; diff --git web/status.xsl web/status.xsl index b7049a2..9a46945 100644 --- web/status.xsl +++ web/status.xsl @@ -92,6 +92,24 @@ <xsl:if test="genre"> <tr><td>Stream Genre:</td><td class="streamdata"> <xsl:value-of select="genre" /></td></tr> </xsl:if> + +<xsl:if test="user-agent"> +<tr><td>Source:</td><td class="streamdata"> <xsl:value-of select="user-agent" /></td></tr> +</xsl:if> + +<xsl:if test="max_listener_duration"> + <tr><td>Max Listener Connect Time:</td><td class="streamdata"> + <xsl:choose> + <xsl:when test="max_listener_duration = 0"> + Unlimited + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="max_listener_duration" /> (seconds) + </xsl:otherwise> + </xsl:choose> + </td></tr> +</xsl:if> + <xsl:if test="server_url"> <tr><td>Stream URL:</td><td class="streamdata"> <a target="_blank" href="{server_url}"><xsl:value-of select="server_url" /></a></td></tr> </xsl:if> END icecast-2.3.2-moremntinfo.patch
Philipp Schafft
2013-Jan-05 20:58 UTC
[Icecast-dev] Adding additional mount info to xsl stylesheet
reflum, On Mon, 2012-12-10 at 20:18 -0800, Byron Young wrote:> The following patch attempts to make the source client user agent and > the max listener client connection duration information available to > (icecast 2.3.2) xsl stylesheets.Thanks for your work. Does the diff still apply to current trunk? If not please send an updated version.> Will there be any memory leak issues in > the lower level functions like the acl, etc. when the source is > disconnected, when servicing queries, or otherwise?Don't know the scope of the HTTP vars (user agent). Will check this when I'm back at home (and got an updated patch). If it can go out of scope to early the string can be strduped. Out of curiosity: Why do you need those information? Wish you a nice weekend. :) -- Philipp. (Rah of PH2) -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 482 bytes Desc: This is a digitally signed message part Url : http://lists.xiph.org/pipermail/icecast-dev/attachments/20130105/00de426c/attachment.pgp
Byron Young
2013-Jan-07 21:11 UTC
[Icecast-dev] Adding additional mount info to xsl stylesheet
On Sat, 2013-01-05 at 21:58 +0100, Philipp Schafft wrote:> reflum, > > On Mon, 2012-12-10 at 20:18 -0800, Byron Young wrote: > > The following patch attempts to make the source client user agent and > > the max listener client connection duration information available to > > (icecast 2.3.2) xsl stylesheets. > > Thanks for your work. Does the diff still apply to current trunk? If not > please send an updated version.The patch for 2.3.2 successfully applies to, compiles with, and executes svn18756 (2.4-beta). For reference, a SRPM containing the patch for fc16 is at ftp://ftp.bkyoung.com/pub/specs/icecast-svn18756-1.fc16.src.rpm This srpm also adds basic systemd support and builds with no optimization. The current official rawhide (or even fc18) versions probably have better systemd support.> > > > Will there be any memory leak issues in > > the lower level functions like the acl, etc. when the source is > > disconnected, when servicing queries, or otherwise? > > Don't know the scope of the HTTP vars (user agent). Will check this when > I'm back at home (and got an updated patch). If it can go out of scope > to early the string can be strduped.Logically, they are "mount" scope, and should exist while the source client is mounted. The code probably follows the logic. The lower level code may strdup the pointers, which could cause memory leaks. Strdup'ing the pointer to prolong the data existence would also require free'ing on unmounting the client source. Not sure exactly where that should happen.> Out of curiosity: Why do you need those information?Because I'm lazy? And don't want to dig deeper into the lower code levels? But really, so that just in case if one person actually connects to and listens to my streaming media server, they will not receive a segfault and then complain to the development team.> > > Wish you a nice weekend. :) >