Merge remote-tracking branch 'origin/pr/317'

This commit is contained in:
Adam Sutton 2014-01-11 00:29:16 +00:00
commit 7517af8eb7
10 changed files with 39 additions and 12 deletions

View file

@ -490,7 +490,6 @@ cwc_send_msg(cwc_t *cwc, const uint8_t *msg, size_t len, int sid, int enq, uint1
tvhtrace("cwc", "sending message sid %d len %"PRIsize_t" enq %d", sid, len, enq);
tvhlog_hexdump("cwc", msg, len);
if (len < 0) return -1;
buf[0] = (len - 2) >> 8;
buf[1] = (len - 2) & 0xff;

View file

@ -191,7 +191,7 @@ epggrab_channel_t *epggrab_channel_find
epggrab_channel_t *ec;
static epggrab_channel_t *skel = NULL;
if (!skel) skel = calloc(1, sizeof(epggrab_channel_t));
skel->id = strdupa(id);
skel->id = tvh_strdupa(id);
/* Replace / with # */
// Note: this is a bit of a nasty fix for #1774, but will do for now

View file

@ -494,7 +494,7 @@ idnode_cmp_sort
case PT_STR:
{
int r;
const char *stra = strdupa(idnode_get_str(ina, sort->key) ?: "");
const char *stra = tvh_strdupa(idnode_get_str(ina, sort->key) ?: "");
const char *strb = idnode_get_str(inb, sort->key);
if (sort->dir == IS_ASC)
r = strcmp(stra ?: "", strb ?: "");
@ -666,7 +666,7 @@ void
idnode_set_sort
( idnode_set_t *is, idnode_sort_t *sort )
{
qsort_r(is->is_array, is->is_count, sizeof(idnode_t*), idnode_cmp_sort, sort);
qsort_r(is->is_array, is->is_count, sizeof(idnode_t*), idnode_cmp_sort, (void*)sort);
}
void

View file

@ -443,7 +443,7 @@ linuxdvb_mux_dvbs_class_orbital_set ( void *o, const void *s )
{
int pos, save = 0;
char dir;
char *tmp = strdupa(s);
char *tmp = tvh_strdupa(s);
linuxdvb_mux_t *lm = o;
dir = tmp[strlen(tmp)-1];

View file

@ -29,7 +29,6 @@
#include <limits.h>
#include <time.h>
#include <locale.h>
#include <sys/prctl.h>
#include <pwd.h>
#include <grp.h>
@ -65,6 +64,10 @@
#include "plumbing/transcoding.h"
#endif
#ifdef PLATFORM_LINUX
#include <sys/prctl.h>
#endif
/* Command line option struct */
typedef struct str_list
{
@ -690,9 +693,13 @@ main(int argc, char **argv)
/* Make dumpable */
if (opt_dump) {
#ifdef PLATFORM_LINUX
if (chdir("/tmp"))
tvhwarn("START", "failed to change cwd to /tmp");
prctl(PR_SET_DUMPABLE, 1);
#else
tvhwarn("START", "Coredumps not implemented on your platform");
#endif
}
umask(0);

View file

@ -33,6 +33,7 @@ char tvh_binshasum[20];
#include <limits.h>
#if ENABLE_EXECINFO
#include <execinfo.h>
#include <dlfcn.h>
#endif
#include <stdio.h>
#include <stdarg.h>
@ -52,6 +53,10 @@ static char tmpbuf[1024];
static char libs[1024];
static char self[PATH_MAX];
#ifdef PLATFORM_FREEBSD
extern char **environ;
#endif
static void
sappend(char *buf, size_t l, const char *fmt, ...)
{

View file

@ -603,12 +603,14 @@ int rmtree ( const char *path );
char *regexp_escape ( const char *str );
#ifdef PLATFORM_LINUX
/* glibc wrapper */
#if !__GLIBC_PREREQ(2,8)
void
qsort_r(void *base, size_t nmemb, size_t size,
int (*cmp)(const void *, const void *, void *), void *aux);
#endif
#endif /* PLATFORM_LINUX */
/* printing */
# if __WORDSIZE == 64

View file

@ -307,7 +307,7 @@ void tvhlogv ( const char *file, int line,
/* Basic message */
l = 0;
if (options & TVHLOG_OPT_THREAD) {
l += snprintf(buf + l, sizeof(buf) - l, "tid %ld: ", pthread_self());
l += snprintf(buf + l, sizeof(buf) - l, "tid %ld: ", (long)pthread_self());
}
l += snprintf(buf + l, sizeof(buf) - l, "%s: ", subsys);
if (options & TVHLOG_OPT_FILELINE && severity >= LOG_DEBUG)

View file

@ -3,10 +3,17 @@
#include <fcntl.h>
#include <sys/types.h> /* See NOTES */
#include <sys/socket.h>
#include <sys/prctl.h>
#include <unistd.h>
#include <pthread.h>
#ifdef PLATFORM_LINUX
#include <sys/prctl.h>
#endif
#ifdef PLATFORM_FREEBSD
#include <pthread_np.h>
#endif
int
tvh_open(const char *pathname, int flags, mode_t mode)
{
@ -94,12 +101,17 @@ thread_wrapper ( void *p )
{
struct thread_state *ts = p;
#if defined(PLATFORM_LINUX)
/* Set name */
prctl(PR_SET_NAME, ts->name);
#elif defined(PLATFORM_FREEBSD)
/* Set name of thread */
pthread_set_name_np(pthread_self(), ts->name);
#endif
/* Run */
tvhdebug("thread", "created thread %ld [%s / %p(%p)]",
pthread_self(), ts->name, ts->run, ts->arg);
(long)pthread_self(), ts->name, ts->run, ts->arg);
void *r = ts->run(ts->arg);
free(ts);
@ -123,6 +135,7 @@ tvhthread_create0
return r;
}
#ifdef PLATFORM_LINUX
/*
* qsort_r wrapper for pre GLIBC 2.8
*/
@ -148,3 +161,4 @@ qsort_r(void *base, size_t nmemb, size_t size,
qsort(base, nmemb, size, qsort_r_wrap);
}
#endif /* GLIBC < 2.8 */
#endif /* PLATFORM_LINUX */

View file

@ -7,8 +7,8 @@ INSTICON= ${DESTDIR}$(prefix)/share/icons/hicolor/scalable/apps
install: ${PROG} ${MAN}
install -d ${DESTDIR}${bindir}
install ${PROG} ${DESTDIR}${bindir}/tvheadend
install -d ${DESTDIR}${mandir}
install ${MAN} ${DESTDIR}${mandir}/tvheadend.1
install -d ${DESTDIR}${mandir}/man1
install ${MAN} ${DESTDIR}${mandir}/man1/tvheadend.1
for bundle in ${BUNDLES}; do \
mkdir -p ${DESTDIR}${datadir}/tvheadend/$$bundle ;\
@ -19,5 +19,5 @@ install: ${PROG} ${MAN}
uninstall:
rm -f ${DESTDIR}${bindir}/tvheadend
rm -f ${DESTDIR}${mandir}/tvheadend.1
rm -f ${DESTDIR}${mandir}/man1/tvheadend.1
rm -rf ${DESTDIR}${datadir}/tvheadend