From bafe0bf53fcdb0399387c2591d0921e26513a478 Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Mon, 2 Jul 2012 15:02:39 +0100 Subject: [PATCH] Fix problem with not storing owner module in epggrab_channel entries which results in things going horrible wrong. --- src/epggrab/channel.c | 13 ++++++++----- src/epggrab/module.c | 2 +- src/epggrab/module/opentv.c | 3 ++- src/epggrab/module/pyepg.c | 11 +++++++---- src/epggrab/module/xmltv.c | 12 ++++++++---- src/epggrab/private.h | 3 ++- 6 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/epggrab/channel.c b/src/epggrab/channel.c index f08afe9a..abd57633 100644 --- a/src/epggrab/channel.c +++ b/src/epggrab/channel.c @@ -210,10 +210,12 @@ static int _ch_id_cmp ( void *a, void *b ) /* Find/Create channel in the list */ epggrab_channel_t *epggrab_channel_find - ( epggrab_channel_tree_t *tree, const char *id, int create, int *save ) + ( epggrab_channel_tree_t *tree, const char *id, int create, int *save, + epggrab_module_t *owner ) { epggrab_channel_t *ec; static epggrab_channel_t *skel = NULL; + assert(owner); if (!skel) skel = calloc(1, sizeof(epggrab_channel_t)); skel->id = (char*)id; @@ -225,10 +227,11 @@ epggrab_channel_t *epggrab_channel_find } else { ec = RB_INSERT_SORTED(tree, skel, link, _ch_id_cmp); if (!ec) { - ec = skel; - skel = NULL; - ec->id = strdup(id); - *save = 1; + ec = skel; + skel = NULL; + ec->id = strdup(id); + ec->mod = owner; + *save = 1; } } return ec; diff --git a/src/epggrab/module.c b/src/epggrab/module.c index e34f3272..bf075455 100644 --- a/src/epggrab/module.c +++ b/src/epggrab/module.c @@ -216,7 +216,7 @@ static void _epggrab_module_channel_load htsmsg_t *a; htsmsg_field_t *f; - epggrab_channel_t *ch = epggrab_channel_find(mod->channels, id, 1, &save); + epggrab_channel_t *ch = epggrab_channel_find(mod->channels, id, 1, &save, mod); if ((str = htsmsg_get_str(m, "name"))) ch->name = strdup(str); diff --git a/src/epggrab/module/opentv.c b/src/epggrab/module/opentv.c index ca2b34c7..8fb2219b 100644 --- a/src/epggrab/module/opentv.c +++ b/src/epggrab/module/opentv.c @@ -185,7 +185,8 @@ static epggrab_channel_t *_opentv_find_epggrab_channel { char chid[32]; sprintf(chid, "%s-%d", mod->id, cid); - return epggrab_channel_find(&_opentv_channels, chid, create, save); + return epggrab_channel_find(&_opentv_channels, chid, create, save, + (epggrab_module_t*)mod); } static epg_season_t *_opentv_find_season diff --git a/src/epggrab/module/pyepg.c b/src/epggrab/module/pyepg.c index 4dc7268a..8793f7d2 100644 --- a/src/epggrab/module/pyepg.c +++ b/src/epggrab/module/pyepg.c @@ -30,11 +30,13 @@ #include "epggrab/private.h" static epggrab_channel_tree_t _pyepg_channels; +static epggrab_module_t *_pyepg_module; // primary module static epggrab_channel_t *_pyepg_channel_find ( const char *id, int create, int *save ) { - return epggrab_channel_find(&_pyepg_channels, id, create, save); + return epggrab_channel_find(&_pyepg_channels, id, create, save, + _pyepg_module); } /* ************************************************************************** @@ -439,9 +441,10 @@ void pyepg_init ( void ) NULL, _pyepg_parse, NULL, NULL); /* External module */ - epggrab_module_ext_create(NULL, "pyepg", "PyEPG", "pyepg", - _pyepg_parse, NULL, - &_pyepg_channels); + _pyepg_module = (epggrab_module_t*) + epggrab_module_ext_create(NULL, "pyepg", "PyEPG", "pyepg", + _pyepg_parse, NULL, + &_pyepg_channels); } void pyepg_load ( void ) diff --git a/src/epggrab/module/xmltv.c b/src/epggrab/module/xmltv.c index 546f367a..b34fab50 100644 --- a/src/epggrab/module/xmltv.c +++ b/src/epggrab/module/xmltv.c @@ -40,11 +40,14 @@ #define XMLTV_FIND_GRABBERS "/usr/bin/tv_find_grabbers" static epggrab_channel_tree_t _xmltv_channels; +static epggrab_module_t *_xmltv_module; static epggrab_channel_t *_xmltv_channel_find ( const char *id, int create, int *save ) { - return epggrab_channel_find(&_xmltv_channels, id, create, save); + + return epggrab_channel_find(&_xmltv_channels, id, create, save, + _xmltv_module); } /* ************************************************************************** @@ -494,9 +497,10 @@ static void _xmltv_load_grabbers ( void ) void xmltv_init ( void ) { /* External module */ - epggrab_module_ext_create(NULL, "xmltv", "XMLTV", "xmltv", - _xmltv_parse, NULL, - &_xmltv_channels); + _xmltv_module = (epggrab_module_t*) + epggrab_module_ext_create(NULL, "xmltv", "XMLTV", "xmltv", + _xmltv_parse, NULL, + &_xmltv_channels); /* Standard modules */ _xmltv_load_grabbers(); diff --git a/src/epggrab/private.h b/src/epggrab/private.h index ed1942d9..c4b94374 100644 --- a/src/epggrab/private.h +++ b/src/epggrab/private.h @@ -48,7 +48,8 @@ void epggrab_module_channels_load ( epggrab_module_t *m ); int epggrab_channel_link ( epggrab_channel_t *ec, struct channel *ch ); epggrab_channel_t *epggrab_channel_find - ( epggrab_channel_tree_t *chs, const char *id, int create, int *save ); + ( epggrab_channel_tree_t *chs, const char *id, int create, int *save, + epggrab_module_t *owner ); /* ************************************************************************** * Internal module routines