Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
epg: fix NULL grabber bug and improve logs
  • Loading branch information
perexg committed Aug 26, 2016
1 parent 65dfd15 commit edcd83b
Showing 1 changed file with 32 additions and 10 deletions.
42 changes: 32 additions & 10 deletions src/epg.c
Expand Up @@ -1553,6 +1553,7 @@ static void _epg_channel_timer_callback ( void *p )
time_t next = 0;
epg_broadcast_t *ebc, *cur, *nxt;
channel_t *ch = (channel_t*)p;
char tm1[32];

/* Clear now/next */
if ((cur = ch->ch_epg_now)) {
Expand Down Expand Up @@ -1605,8 +1606,8 @@ static void _epg_channel_timer_callback ( void *p )

/* re-arm */
if (next) {
tvhdebug(LS_EPG, "arm channel timer @ %"PRItime_t" for %s",
next, channel_get_name(ch));
tvhdebug(LS_EPG, "arm channel timer @ %s for %s",
gmtime2local(next, tm1, sizeof(tm1)), channel_get_name(ch));
gtimer_arm_absn(&ch->ch_epg_timer, _epg_channel_timer_callback, ch, next);
}

Expand All @@ -1621,6 +1622,16 @@ static epg_broadcast_t *_epg_channel_add_broadcast
{
int timer = 0;
epg_broadcast_t *ebc, *ret;
char tm1[32], tm2[32];

if (!src) {
tvherror(LS_EPG, "skipped event (!grabber) %u (%s) on %s @ %s to %s",
(*bcast)->id, epg_broadcast_get_title(*bcast, NULL),
channel_get_name(ch),
gmtime2local((*bcast)->start, tm1, sizeof(tm1)),
gmtime2local((*bcast)->stop, tm2, sizeof(tm2)));
return NULL;
}

/* Set channel */
(*bcast)->channel = ch;
Expand All @@ -1642,9 +1653,13 @@ static epg_broadcast_t *_epg_channel_add_broadcast
_epg_object_create(ret);
// Note: sets updated
_epg_object_getref(ret);
tvhtrace(LS_EPG, "added event %u (%s) on %s @ %"PRItime_t " to %"PRItime_t,
ret->grabber = src;
tvhtrace(LS_EPG, "added event %u (%s) on %s @ %s to %s (grabber %s)",
ret->id, epg_broadcast_get_title(ret, NULL),
channel_get_name(ch), ret->start, ret->stop);
channel_get_name(ch),
gmtime2local(ret->start, tm1, sizeof(tm1)),
gmtime2local(ret->stop, tm2, sizeof(tm2)),
src->id);

/* Existing */
} else {
Expand All @@ -1659,9 +1674,12 @@ static epg_broadcast_t *_epg_channel_add_broadcast
} else {
ret->stop = (*bcast)->stop;
_epg_object_set_updated(ret);
tvhtrace(LS_EPG, "updated event %u (%s) on %s @ %"PRItime_t " to %"PRItime_t,
tvhtrace(LS_EPG, "updated event %u (%s) on %s @ %s to %s (grabber %s)",
ret->id, epg_broadcast_get_title(ret, NULL),
channel_get_name(ch), ret->start, ret->stop);
channel_get_name(ch),
gmtime2local(ret->start, tm1, sizeof(tm1)),
gmtime2local(ret->stop, tm2, sizeof(tm2)),
src->id);
}
}
}
Expand All @@ -1677,9 +1695,11 @@ static epg_broadcast_t *_epg_channel_add_broadcast
_epg_channel_rem_broadcast(ch, ret, NULL);
return NULL;
}
tvhtrace(LS_EPG, "remove overlap (b) event %u (%s) on %s @ %"PRItime_t " to %"PRItime_t,
tvhtrace(LS_EPG, "remove overlap (b) event %u (%s) on %s @ %s to %s",
ebc->id, epg_broadcast_get_title(ebc, NULL),
channel_get_name(ch), ebc->start, ebc->stop);
channel_get_name(ch),
gmtime2local(ebc->start, tm1, sizeof(tm1)),
gmtime2local(ebc->stop, tm2, sizeof(tm2)));
_epg_channel_rem_broadcast(ch, ebc, ret);
}

Expand All @@ -1691,9 +1711,11 @@ static epg_broadcast_t *_epg_channel_add_broadcast
_epg_channel_rem_broadcast(ch, ret, NULL);
return NULL;
}
tvhtrace(LS_EPG, "remove overlap (a) event %u (%s) on %s @ %"PRItime_t " to %"PRItime_t,
tvhtrace(LS_EPG, "remove overlap (a) event %u (%s) on %s @ %s to %s",
ebc->id, epg_broadcast_get_title(ebc, NULL),
channel_get_name(ch), ebc->start, ebc->stop);
channel_get_name(ch),
gmtime2local(ebc->start, tm1, sizeof(tm1)),
gmtime2local(ebc->stop, tm2, sizeof(tm2)));
_epg_channel_rem_broadcast(ch, ebc, ret);
}

Expand Down

0 comments on commit edcd83b

Please sign in to comment.