From: michael Date: Sun, 2 Jul 2006 00:38:22 +0000 (+0000) Subject: fix some bugs X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/record-dvb/commitdiff_plain/90d8d87bb07bd2e77fc19df4efe41c23464cbbf0?hp=b06a3250f425fa8d8d389a71ed2edd2131fcc169 fix some bugs --- diff --git a/common.c b/common.c index 80327f5..8f000fd 100644 --- a/common.c +++ b/common.c @@ -10,12 +10,14 @@ struct dvb_host *parse(char *urlpart, char *defport) { - struct dvb_host *dvbhost; + static struct dvb_host *dvbhost = NULL; char *pos; - if (!(dvbhost = malloc(sizeof(struct dvb_host)))) { - perror("malloc"); - exit(EXIT_FAILURE); + if (!dvbhost) { + if (!(dvbhost = malloc(sizeof(struct dvb_host)))) { + perror("malloc"); + exit(EXIT_FAILURE); + } } bzero(dvbhost, sizeof(struct dvb_host)); diff --git a/http.c b/http.c index ab798d9..c7e553c 100644 --- a/http.c +++ b/http.c @@ -27,17 +27,15 @@ int open_http(char *url) { int fd; struct sockaddr_in server; - static struct dvb_host *dvbhost = NULL; + struct dvb_host *dvbhost = NULL; char c, buffer[BUFFSIZE], *pos; int lines = 0; if(!is_http(url)) return -1; - if (!dvbhost) { - dvbhost = parse(&(url[7]), "80"); - dvbhost->socktype = SOCK_STREAM; - } + dvbhost = parse(&(url[7]), "80"); + dvbhost->socktype = SOCK_STREAM; if (resolve(dvbhost, &server) < 0) { return -1; diff --git a/mcast.c b/mcast.c index fc72056..fd88569 100644 --- a/mcast.c +++ b/mcast.c @@ -22,7 +22,7 @@ int is_mcast(char *url) int open_mcast(char *url) { - static struct dvb_host *dvbhost = NULL; + struct dvb_host *dvbhost = NULL; struct sockaddr_in server; struct ip_mreq mreq; int val; @@ -31,10 +31,8 @@ int open_mcast(char *url) if(!is_mcast(url)) return -1; - if (!dvbhost) { - dvbhost = parse(&(url[6]), "2000"); - dvbhost->socktype = SOCK_DGRAM; - } + dvbhost = parse(&(url[6]), "2000"); + dvbhost->socktype = SOCK_DGRAM; if (resolve(dvbhost, &server) < 0) { return -1; diff --git a/sap.c b/sap.c index f10bce8..684c509 100644 --- a/sap.c +++ b/sap.c @@ -197,5 +197,7 @@ char *get_url_from_sap(char *service) mreq.imr_interface.s_addr = INADDR_ANY; setsockopt (fd, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq)); + close(fd); + return url; }