<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>apocryph.org &#187; mediatomb</title>
	<atom:link href="http://apocryph.org/tag/mediatomb/feed/" rel="self" type="application/rss+xml" />
	<link>http://apocryph.org</link>
	<description>Notes to my future self</description>
	<lastBuildDate>Mon, 09 Aug 2010 16:59:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Idea for improving MediaTomb</title>
		<link>http://apocryph.org/2005/11/28/idea_for_improving_mediatomb/</link>
		<comments>http://apocryph.org/2005/11/28/idea_for_improving_mediatomb/#comments</comments>
		<pubDate>Tue, 29 Nov 2005 04:11:23 +0000</pubDate>
		<dc:creator>anelson</dc:creator>
				<category><![CDATA[Migrated from Drupal]]></category>
		<category><![CDATA[jinzora]]></category>
		<category><![CDATA[mediatomb]]></category>
		<category><![CDATA[projects]]></category>

		<guid isPermaLink="false">http://apocryph.org/?p=84</guid>
		<description><![CDATA[If I ever get MediaTomb working, it occurs to me that it&#8217;d be great to integrate it with Jinzora. Since MediaTomb is building support for scripted containers, one could constructed such containers for things like &#8216;jinzora playlists&#8217;, &#8216;jinzora albums&#8217;, etc. That way you could expose your Jinzora2 music collection to MediaTomb. Mostly this is worthwhile [...]]]></description>
			<content:encoded><![CDATA[<p>If I ever get MediaTomb working, it occurs to me that it&#8217;d be great to integrate it with Jinzora.  Since MediaTomb is building support for scripted containers, one could constructed such containers for things like &#8216;jinzora playlists&#8217;, &#8216;jinzora albums&#8217;, etc.  That way you could expose your Jinzora2 music collection to MediaTomb.  Mostly this is worthwhile for the playlists.</p>
]]></content:encoded>
			<wfw:commentRss>http://apocryph.org/2005/11/28/idea_for_improving_mediatomb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Looking for Non-Lame Open-Source UPnP Media Server</title>
		<link>http://apocryph.org/2005/11/27/looking_nonlame_opensource_upnp_media_server/</link>
		<comments>http://apocryph.org/2005/11/27/looking_nonlame_opensource_upnp_media_server/#comments</comments>
		<pubDate>Sun, 27 Nov 2005 15:36:47 +0000</pubDate>
		<dc:creator>anelson</dc:creator>
				<category><![CDATA[Migrated from Drupal]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[libupnp]]></category>
		<category><![CDATA[mediatomb]]></category>
		<category><![CDATA[tech diary]]></category>
		<category><![CDATA[upnp]]></category>

		<guid isPermaLink="false">http://apocryph.org/?p=80</guid>
		<description><![CDATA[Ever since I got my Linksys wireless music system, I&#8217;ve wanted an open source UPnP music server to stream my music to it. As one might expect, it ships w/ Musicmatch Jukebox, which has a UPnP server feature, but MMJB isn&#8217;t open source and only runs on Windows. My music is stored on aenea, a [...]]]></description>
			<content:encoded><![CDATA[<p>Ever since I got my Linksys wireless music system, I&#8217;ve wanted an open source UPnP music server to stream my music to it.  As one might expect, it ships w/ Musicmatch Jukebox, which has a UPnP server feature, but MMJB isn&#8217;t open source and only runs on Windows.  My music is stored on <code>aenea</code>, a FreeBSD 6.0 box, so why can&#8217;t I run a media server <em>there</em>, where it makes the most sense?</p>
<p>I&#8217;ve found three potentially non-shitty media servers thus far:</p>
<ul>
<li><a href="http://www.nongnu.org/gmediaserver/">GMediaServer</a></li>
<li><a href="http://mediatomb.sourceforge.net/">MediaTomb</a></li>
<li>GeeXboX <a href="http://ushare.geexbox.org/">uShare</a></li>
</ul>
<p>As is the case with most trendy open source projects today, they&#8217;re all written for Linux.  Since I use FreeBSD,  there&#8217;s inevitably some degree of contortion required to make them work.</p>
<p>First is the installation of the FreeBSD port of <code>libupnp</code>, which is in <code>/usr/ports/devel/upnp</code>.  That built and installed without incident.</p>
<p>MediaTomb seems the most mature and feature rich, so I&#8217;ll start there.  I downloaded the source tarball, and am having quite a bit of trouble getting it to build.</p>
<p><code>configure</code> is failing somewhat stupidly.  First, it couldn&#8217;t find the <code>iconv.h</code> header file located in <code>/usr/local/include</code>, even when I point it there explicitly.  I had to set the <code>CPPFLAGS</code> env var to <code>-I/usr/local/include</code> to get past that point.</p>
<p>Next, <code>configure</code> can&#8217;t find <code>upnp/ixml.h</code>.  This one doesn&#8217;t appear to be <code>configure</code>&#8216;s fault; there really is no <code>ixml.h</code> in the port.  Perhaps part of the problem is the age of the FreeBSD <code>libupnp</code> port; it reports itself as version 1.0.4_1; whatever that means, it doesn&#8217;t sound at all like 1.2.1, the latest Linux version.  FreeBSD <a href="http://lists.freebsd.org/pipermail/freebsd-ports-bugs/2005-June/060358.html">ports bug 82347</a> was submitted back in June with diffs to update to the current version, but it appears nothing&#8217;s been done with them.</p>
<p>I&#8217;m trying to apply the aforementioned ports bug diff, with mostly success but a few problems.</p>
<p>Hunk #1 in <code>Makefile</code> failed to apply, and I can&#8217;t tell why.  For testing I&#8217;ll make the changes in that hunk manually; mostly they&#8217;re changing the version number, dist name, etc.</p>
<p>The only hunk that failed is in <code>pkg-plist</code>, and seems to reflect a significant refactoring of the <code>libupnp</code> code.</p>
<p>Hmm, no, this patch is still pretty fucked up.  The post-download patches themselves are broken now.  I&#8217;ll just build and install libupnp without a port.</p>
<p>Note to self: from the README:</p>
<blockquote><p>
    For the UPnP library to function correctly, Linux networking must be configured<br />
    properly for multicasting.  To do this:</p>
<p>    route add -net 239.0.0.0 netmask 255.0.0.0 eth0</p>
<p>    where &#8216;eth0&#8242; is the network adapter that the UPnP library will use.  Without<br />
    this addition, device advertisements and control point searches will not<br />
    function.
</p></blockquote>
<p>Keep this in mind if you ever get it to build.</p>
<p>&#8230;</p>
<p>Hmm, that didn&#8217;t get me very far:</p>
<pre><code> $ gmake
 gmake[1]: Entering directory `/home/anelson/libupnp-1.2.1/ixml'
 gmake[2]: Entering directory `/home/anelson/libupnp-1.2.1/ixml/src'
 gcc -Wall -I./ -I../inc -I../../pil/inc -fPIC -c -Wall -Os -DNDEBUG -I. -I../inc -Iinc -c ixml.c -o obj/ixml.o
 In file included from ../inc/ixml.h:37,
                  from inc/ixmlmembuf.h:36,
                  from ixml.c:32:
 /usr/include/malloc.h:3:2: #error "&lt;malloc.h&gt; has been replaced by &lt;stdlib.h&gt;"
 gmake[2]: *** [obj/ixml.o] Error 1
 gmake[2]: Leaving directory `/home/anelson/libupnp-1.2.1/ixml/src'
 gmake[1]: *** [all] Error 2
 gmake[1]: Leaving directory `/home/anelson/libupnp-1.2.1/ixml'
 gmake: *** [upnp] Error 2
</code></pre>
<p>Ok, so those patches in the port really do matter.</p>
<p>The <code>libupnp-1.2.1</code> <code>makefile</code> has changed pretty dramatically since the port (and presumably the port diff).  For example, it is modified to support cross-compilation, and has removed some hard-coded paths.  I&#8217;ve made some manual mods to it such as setting <code>MAKE</code> to <code>gmake</code>, and am deleting <code>patch-makefile</code>, in the hopes that this will be enough.</p>
<p>&#8230;</p>
<p>Def not.  It&#8217;s pretty badly broken.  Awesome.</p>
<p>Ok, so back to building without the port.</p>
<p>The problem above is <code>ixml.c</code> attempting to <code>#include</code> <code>malloc.h</code>, which is deprecated in favor of <code>stdlib.h</code>.  I commented it out in <code>ixml/inc/ixml.h</code>, but there&#8217;s more.  A quick <code>grep</code> yields a few files with this same affliction:</p>
<pre><code> ixml/inc/ixml.h:/*#include &lt;malloc.h&gt;*/
 threadutil/inc/FreeList.h:#include &lt;malloc.h&gt;
 threadutil/src/LinkedList.c:#include &lt;malloc.h&gt;
 threadutil/src/iasnprintf.c:#include &lt;malloc.h&gt;
 upnp/inc/ixml.h:/*#include &lt;malloc.h&gt;*/
 upnp/src/genlib/util/upnp_timeout.c:#include &lt;malloc.h&gt;
 upnp/src/inc/client_table.h:#include &lt;malloc.h&gt;
 upnp/src/inc/http_client.h:#include &lt;malloc.h&gt;
 upnp/src/inc/service_table.h:#include &lt;malloc.h&gt;
 upnp/src/inc/uri.h:#include &lt;malloc.h&gt;
</code></pre>
<p>I&#8217;ll fix them all then.</p>
<p>Next up is a <code>pthreads</code> issue:</p>
<pre><code> ThreadPool.c: In function `SetSeed':
 ThreadPool.c:344: error: invalid use of undefined type `struct pthread'
</code></pre>
<p>One of the makefile patches in the port had to do with the path to pthreads.</p>
<p>&#8230;.</p>
<p>Ok, I&#8217;ve gone through, error by error.  Most of them were already solved in the FreeBSD port patches, although due to various subtle changes in the library sources, the patches won&#8217;t work automatically.  For testing, I manually made the changes in the patches, and was able to do a build and install.  However, I only applied the changes necessary to build; there may still be runtime problems that I don&#8217;t know about.  I also had to change the <code>install</code> and <code>uninstall</code> targets, so files go to <code>/usr/local/whatever</code> instead of <code>/usr/whatever/</code>, which complicates the MediaTomb build later.</p>
<p>I&#8217;m now going to try to build MediaTomb and see how it runs.</p>
<p>First thing I discover is that the <code>configure</code> script needs <em>alot</em> of help.  In order to get it to find <code>iconv.h</code>, I had to add <code>CPPFLAGS=-I/usr/local/include</code>, even though <code>/usr/local/include</code> is supposed to be where it&#8217;s looking by default.</p>
<p>Then I discovered I hadn&#8217;t fully installed libupnp after all.  I kept getting:</p>
<pre><code> checking for upnp/upnp.h... no
 configure: error: upnp/upnp.h not found. Check libupnp installation
</code></pre>
<p>Even though <code>upnp/upnp.h</code> exists in <code>/usr/local/include</code>.  The problem with <code>configure</code> in general is that it does its checks by trying simple code snippets in the compiler, and if they fail, concludes the test fails.  However, without seeing the compiler error message, it&#8217;s hard to debug the problem.</p>
<p>I only figured it out when I read this in the <code>README</code> for MediaTomb:</p>
<blockquote><p>
    Installation of this package is not straight forward.<br />
        tar zxvf libupnp-1.2.1.tar.gz<br />
        cd libupnp-1.2.1<br />
        cd upnp<br />
        make<br />
        make install<br />
        cd ../ixml<br />
        make<br />
        make install<br />
        cd ../threadutil<br />
        make<br />
        make install<br />
        cd ..<br />
        cp upnp/inc/ixml.h /usr/include/
</p></blockquote>
<p>I only did the <code>make install</code> (actually, <code>gmake install</code>) for <code>upnp</code>, not for the other two folders.  Plus, I didn&#8217;t manually copy <code>ixml.h</code>.  So, the <code>configure</code> test failed not because it couldn&#8217;t find <code>upnp.h</code>, but because when it tried to compile <code>upnp.h</code>, it failed since dependent files were missing.  Lame.</p>
<p>Once I got <code>configure</code> to admit <code>upnp.h</code> was there, it ran to completion, with the following results:</p>
<pre><code> ======== CONFIGURATION SUMMARY =========
   sqlite3      : missing
   mysql        : yes
   java-script   : missing
   libmagic     : yes
   id3lib       : missing
   libextractor : disabled
   libexif      : missing
</code></pre>
<p>This isn&#8217;t acceptable.  I want to use sqlite as the database backend, and will definitely need id3 support.  java-script would be nice.  I suspect there are ports I can install to address this issue.</p>
<p><code>libexif</code> is in <code>graphics/libexif</code>.  No brainer, that.  It installed fine.</p>
<p><code>id3lib</code> is in <code>audio/id3lib</code>.  Also an obvious choice.  Took a bit, but installed ok too.</p>
<p>From the <code>configure</code> output, it appears the java-script functionality is provided by SpiderMonkey java-script Engine.  That&#8217;s in  <code>lang/p5-java-script-SpiderMonkey</code>.  It&#8217;s installing now, but might take a while.</p>
<p>While I wait, an interesting remark from the MediaTomb readme:</p>
<blockquote><p>
    NOTE: Write operations to sqlite3 database is VERY SLOW, use sqlite3 only if you don&#8217;t have another choise.
</p></blockquote>
<p>This is interesting.  In my experience with sqlite, there are few database engines faster.  I wonder what he&#8217;s doing that makes it suck so bad.  One thing that I found made a <em>huge</em> performance difference with sqlite is using large transactions.  If you&#8217;re doing a bulk insert, you simply <em>must</em> do a bunch of them in a single tx; the overhead associated with starting and commiting a transaction is unusually high, but the overhead associated with operatins within a tx is virtually zero, so you owe it to yourself to use large transactions.</p>
<p>I took a peek at the database interface API; sure enough, it&#8217;s really lightweight: an <code>exec</code> and a <code>query</code> method, and just a little glue.  Without transaction or bulk insert semantics, sqlite probably will suck.</p>
<p>&#8230;</p>
<p>Anyway, spidermonkey is done.  Re-ran <code>configure</code>; it picks up everything I added, except SpiderMonkey.  I get this:</p>
<pre><code> checking for jsapi.h... yes
 checking for JS_NewObject in -ljs... no
 checking for JS_NewObject in -lsmjs... no
</code></pre>
<p>So it finds the header file, but nfi what&#8217;s the deal with this <code>JS_NewObject</code> crap.  Actually, I&#8217;m getting a similar problem with sqlite:</p>
<pre><code> checking for sqlite3.h... yes
 checking for sqlite3_open in -lsqlite3... no
</code></pre>
<p>Of course, if the sqlite3 library doesn&#8217;t have <code>sqlite3_open</code>, it&#8217;s totally broken.  So, again, I really wish I could see what error <code>configure</code> is getting to make it think that.</p>
<p>Well, I haven&#8217;t figured out how to do that, but I did figure out the problem with <code>configure</code> not seeing the libs.  Just as I had to pass <code>CPPFLAGS=-I/usr/local/include</code> to get it to see the include files, I also had to pass <code>LDFLAGS=-L/usr/local/lib</code> to get it to find the libs.  Now the board is all green:</p>
<pre><code> $ ./configure CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib
 [snipped]
 ======== CONFIGURATION SUMMARY =========
   sqlite3      : yes
   mysql        : yes
   java-script   : yes
   libmagic     : yes
   id3lib       : yes
   libextractor : disabled
   libexif      : yes
</code></pre>
<p>Sweet.  Now let&#8217;s pull the trigger on the build.</p>
<p>I knew it couldn&#8217;t last:</p>
<pre><code> ../src/string_converter.cc: In member function `zmm::String StringConverter::convert(zmm::String)':
 ../src/string_converter.cc:72: error: invalid conversion from `char**' to `const char**'
 ../src/string_converter.cc:72: error:   initializing argument 2 of `size_t libiconv(void*, const char**, size_t*, char**, size_t*)'
</code></pre>
<p>Hmm</p>
<p>The line in question is:</p>
<pre><code> ret = iconv(cd, input_ptr, (size_t *)&amp;input_bytes,
                 output_ptr, (size_t *)&amp;output_bytes); --right here
</code></pre>
<p>I suspect the problem is <code>input_ptr</code>, which is a <code>char **</code>.  By convention, input strings are <code>const</code> in C, so I assume the <code>iconv</code> method expects a <code>const char**</code>.  I&#8217;ll try to cast it explicitly, but I suspect this belies a larger problem with the compiler settings; this really should be a warning, not an error, with all due respect to John Robbins.</p>
<p>Well, that got me past it.  Now it fails with my old friend:</p>
<pre><code> In file included from ../src/zmm/stringbuffer.cc:23:
 /usr/include/malloc.h:3:2: #error "&lt;malloc.h&gt; has been replaced by &lt;stdlib.h&gt;"
</code></pre>
<p>I had to fix a bunch of these in <code>libupnp</code> as well; I just replace them with <code>stdlib.h</code></p>
<pre><code> $ grep -r malloc.h *
 src/zmm/stringbuffer.cc:#include &lt;malloc.h&gt;
 src/zmm/strings.cc:#include &lt;malloc.h&gt;
 src/zmmf/array.cc:#include &lt;malloc.h&gt;
</code></pre>
<p>That didn&#8217;t carry me much further:</p>
<pre><code> ../src/zmmf/exception.cc:24:22: execinfo.h: No such file or directory
 ../src/zmmf/exception.cc: In constructor `zmm::Exception::Exception(zmm::String)':
 ../src/zmmf/exception.cc:36: error: `backtrace' undeclared (first use this function)
 ../src/zmmf/exception.cc:36: error: (Each undeclared identifier is reported only once for each function it appears in.)
 ../src/zmmf/exception.cc:40: error: `backtrace_symbols' undeclared (first use this function)
</code></pre>
<p>Looking at the code in <code>exception.cc</code>, it has some conditional logic to exclude the <code>execinfo.h</code> and associated functions if <code>__CYGWIN__</code> is defined, presumably because Cygwin doesn&#8217;t have <code>execinfo</code>.  Well, FBSD doesn&#8217;t either, so behold my mod to <code>exception.cc</code>:</p>
<pre><code> //anelson: FreeBSD doesn't have execinfo either, so present we're cygwin
 #define __CYGWIN__
</code></pre>
<p>Sometimes I amaze myself.</p>
<p>Next up is a linker error in libupnp:</p>
<pre><code> /usr/local/lib/libupnp.so: undefined reference to `gethostbyname_r'
 /usr/local/lib/libthreadutil.so: undefined reference to `ftime'
</code></pre>
<p>I feel like we&#8217;re almost there.  <code>gethostbyname_r</code> is a reentrant version of <code>gethostbyname</code>.</p>
<p>From [http://www.unobvious.com/bsd/freebsd-threads.html]():</p>
<blockquote><p>
    Some of these functions are available, some (notably the gethost* and other name resolver functions) are not. They are implemented as part of Linuxthreads. Note that the Linuxthreads implementations are &#8220;wrappers&#8221; around the non-reentrant forms of these functions. This has two implications. First, the performance will not be as good as if they were &#8220;natively&#8221; implemented (only one call to gethostbyname_r will actually do a lookup at any given time), and second, the Linuxthreads implementation can be used with the user threads library (as they depend on POSIX mutexes to lock the critical section).
</p></blockquote>
<p>That&#8217;s awesome, except the <code>Linuxthreads</code> port won&#8217;t build on amd64.  Doh.  Maybe there&#8217;s some way to get libupnp to not try to use the reentrant functions?  No; the code that makes the call has no conditional compilation.  According to <a href="http://lists.freebsd.org/pipermail/freebsd-questions/2003-November/025578.html">this list post</a>, this is a known issue.  Awesome.  Thanks alot.</p>
<p>I&#8217;ve added</p>
<pre><code> #define gethostbyname_r gethostbyname
</code></pre>
<p>To <code>upnp/src/inc/uri.h</code>, in the hopes this will address the issue.</p>
<p>Hmm, no, it&#8217;s more complicated than that.  The caller in <code>uri.</code> is passing in five or six args, but <code>gethostbyname</code> is only supposed to take two.</p>
<p>I don&#8217;t think this is going to work.</p>
<p>Since all the media servers I could find depend in libupnp, and libupnp is totally broken on FreeBSD, I&#8217;d say I&#8217;m pretty well fucked.</p>
<p>Astonishingly, it appears that there is a <a href="http://pkgsrc.se/wip/libupnp12">NetBSD pkgsrc package for libupnp12</a>.  Maybe I can use the diffs there?  Then again, maybe NetBSD doesn&#8217;t suck as bad as FreeBSD, and has things like gethostbyname_r, etc.</p>
<p>Well, I was able to apply all the NetBSD patches without error.  I had to re-fix the references to <code>malloc.h</code>, and remove the <code>LD_PATH</code> added by the NetBSD patches to <code>upnp/src/makefile</code>, but otherwise it worked unmodified.</p>
<p>Now I&#8217;m getting link errors in the <code>libmediatomb</code> with pthread functions; I suspect a missing -l switch.  I added <code>CXXFLAGS=-pthread</code> to the <code>configure</code> call and it proceeded.  Now the problem is:</p>
<pre><code> /usr/local/lib/libthreadutil.so: undefined reference to `ftime'
</code></pre>
<p>This is <code>libthreadutil.so</code>, which is part of the <code>libupnp</code> build.</p>
<p>From a <a href="http://lists.freebsd.org/pipermail/freebsd-stable/2003-December/005339.html">list post</a>, there&#8217;s a -lcompat argument that adds legacy stuff like this.  I&#8217;ll try adding that to the CC command when building libthreadutil.</p>
<p>Ok, when I built libupnp, I did:</p>
<p><code>gmake EXTRA_LIBS=-lcompat</code>, then did another install with <code>gmake PREFIX=/usr/local install</code>, and it seemed to do the trick.  I was able to build mediatomb through to the end with:</p>
<pre><code>  ./configure CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib CXXFLAGS=-pthread
  make
</code></pre>
<p>Now I did a <code>make install</code>, and that&#8217;s it.</p>
<p>According to the readme, the next step is <code>tomb-install</code>, which will create a configuration section in ~/.mediatomb.  <code>tome-install</code> is in <code>/usr/local/bin</code>:</p>
<pre><code>  $ /usr/local/bin/tomb-install

  MediaTomb installer 0.3

  Proceeding normally
  Creating directories... ok
  Creating database... ok
  Writing configuration... ok

  All done. You are now ready to launch MediaTomb!

  WARNING: Because of security reasons the UI is disabled by default!
  Please refer to the README file on how to enable it.

  Once it is enabled:
  When the server is running you can access the UI by opening
  ~/.mediatomb/mediatomb.html in your web browser.
</code></pre>
<p>The readme says it will default to sqlite3, since that can be done automatically, but that you should <em>really</em> use mysql instead.  I don&#8217;t care; I want to see that it&#8217;s working first.</p>
<p>The script you&#8217;re meant to start with is <code>mediatomb-service</code>, but it&#8217;s based on <code>init.d</code> scripts in <code>/etc/rc.d/init.d</code>, which isn&#8217;t how FreeBSD does things.</p>
<p>So, I&#8217;ll try my hand at the command line:</p>
<pre><code> $ mediatomb -d -u anelson -g anelson -P /home/anelson/mediatomb.pid -l /home/anelson/mediatomb.log
 Pid file: /home/anelson/mediatomb.pid
</code></pre>
<p>That didn&#8217;t work.  The process died for some reason; I imagine it doesn&#8217;t like not being run as root.</p>
<pre><code>  $ tail mediatomb.log
  2005-10-27 13:57:35 INFO: Config: option not found: /import/metadata-charset using default value: ISO-8859-1
  2005-10-27 13:57:35 INFO: checking ip..
  2005-10-27 13:57:35 INFO: Config: option not found: /server/ip using default value:
  2005-10-27 13:57:35 INFO: Config: option not found: /server/bookmark using default value: mediatomb.html
  2005-10-27 13:57:35 INFO: Config: option not found: /server/port using default value: 0
  2005-10-27 13:57:35 INFO: Config: option not found: /server/alive using default value: 180
  2005-10-27 13:57:35 INFO: Config: option not found: /import/magic-file using default value:
  2005-10-27 13:57:35 INFO: Configuration check succeeded.
  2005-10-27 13:57:35 INFO: Config: option not found: /server/ip using default value:
  2005-10-27 13:57:35 INFO: got ip: (null)
</code></pre>
<p>Nothing suggesting a failure&#8230;Ah, look at this from <code>/var/log/messages</code>:</p>
<pre><code> Nov 27 13:57:35 aenea kernel: pid 95269 (mediatomb), uid 1001: exited on signal 11
</code></pre>
<p>Great.  I&#8217;m out of my depth when it comes to debugging this stuff.</p>
<p>&#8230;</p>
<p>Time for a crash course (pun accidental) in <code>gdb</code>.</p>
<p>First, I just start <code>gdb</code> with the name of the image to run:</p>
<pre><code> gdb mediatomb
</code></pre>
<p>It starts, and gives me the standard prompt:</p>
<pre><code> (gdb)
</code></pre>
<p>I can type <code>run</code> followed by any arguments, and it&#8217;ll run the process under the debugger.  When I do, I get this interesting output:</p>
<pre><code>  (gdb) run -d -u anelson -g anelson -P /home/anelson/mediatomb.pid -l /home/anelson/mediatomb.log
  Starting program: /usr/local/bin/mediatomb -d -u anelson -g anelson -P /home/anelson/mediatomb.pid -l /home/anelson/mediatomb.log
  warning: Unable to get location for thread creation breakpoint: generic error
  [New LWP 100174]
  Pid file: /home/anelson/mediatomb.pid
  [New Thread 0x59e000 (LWP 100174)]

  Program exited normally.
  (gdb) Fatal error 'mutex is on list' at line 540 in file /usr/src/lib/libpthread/thread/thr_mutex.c (errno = 0)
</code></pre>
<p>My developer sense tells me the meaningful error is: <code>Fatal error 'mutex is on list'</code>.  Google, what say you?</p>
<p>Nothing but complaints yet, but I learned about <code>bt</code>, which produces what I in my Microsoft Visual Studio nomenclature would call a &#8216;call stack&#8217;.  It is:</p>
<pre><code> (gdb) bt
 No stack.
</code></pre>
<p><em>WTF</em>?</p>
<p>Amazingly, the only list posting seems to be in reference to this happening whilst running the JDK, and no responses whatsoever.  Outstanding.</p>
<p>Looking at the system source code <code>thr_mutex.c</code> line 540, this message is coming from an assert.  From my read, it appears it happens if trying to lock a mutex that is already locked.</p>
<p>I&#8217;m going to go out on a limb and conclude that mediatomb isn&#8217;t using pthreads as FreeBSD expects.  From this <a href="http://www.unobvious.com/bsd/freebsd-threads.html">great article on programmming threads in FreeBSD</a>, I conclude that I should try to build with libc_r instead.</p>
<p>Sadly, I can&#8217;t figure out how to do that.  I did come across a useful tool: <code>ldd</code>, when given the path to an image, dumps the shared libraries that image links to.  <code>mediatomb</code> links to <code>libpthread.so.2</code>.</p>
<p>Never mind; this <a href="http://www.freebsd.org/doc/en_US.ISO8859-1/articles/5-roadmap/major-issues.html">5.0 roadmap doc</a> makes clear that <code>libc_r</code> is being deprecated as thread support is going into the kernel directly.</p>
<p>At any rate, I&#8217;m pretty clearly screwed.  I&#8217;m out of my depth, and may have to slink back to Linux to run my media server.</p>
]]></content:encoded>
			<wfw:commentRss>http://apocryph.org/2005/11/27/looking_nonlame_opensource_upnp_media_server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
