fix some bugs
authormichael <michael>
Sun, 2 Jul 2006 00:38:22 +0000 (00:38 +0000)
committermichael <michael>
Sun, 2 Jul 2006 00:38:22 +0000 (00:38 +0000)
common.c
http.c
mcast.c
sap.c

index 80327f5292ed0b711fefa261e485309087810916..8f000fd902a078a9463b3e61e68c90af03632b11 100644 (file)
--- a/common.c
+++ b/common.c
 
 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 ab798d9956f64cd55ee030d05fe45a3cd101cd29..c7e553cc7511bd7769356fb77c68c00bf52b6791 100644 (file)
--- 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 fc72056cb239f0e244208d054f6154fe2d5e41a5..fd88569f2b09521026644934892b1864092c1a74 100644 (file)
--- 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 f10bce8dfe64fb0e14955630d7aee618f5f52b92..684c509bf25c81c27365b78bd01b7dcda25d95e0 100644 (file)
--- 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;
 }
Impressum, Datenschutz