recv improvements.
authorAndre Noll <maan@systemlinux.org>
Tue, 5 Jan 2010 18:20:54 +0000 (19:20 +0100)
committerAndre Noll <maan@systemlinux.org>
Tue, 5 Jan 2010 18:20:54 +0000 (19:20 +0100)
- Fix some memory leaks.
- kill http_recv's -B option.
- Move btr node creation to recv.c.

ggo/http_recv.m4
http_recv.c
recv.c

index abe91b5..14ae99a 100644 (file)
@@ -1,5 +1,4 @@
 include(header.m4)
-include(buffer_tree.m4)
 
 <qu>
 option "host" i
index 20e0003..0b83cb4 100644 (file)
@@ -180,6 +180,7 @@ static void http_recv_close(struct receiver_node *rn)
        close(phd->fd);
        free(rn->buf);
        free(rn->private_data);
+       http_recv_cmdline_parser_free(rn->conf);
 }
 
 static void *http_recv_parse_config(int argc, char **argv)
@@ -211,8 +212,6 @@ static int http_recv_open(struct receiver_node *rn)
        rn->private_data = phd = para_calloc(sizeof(struct private_http_recv_data));
        phd->fd = fd;
        phd->status = HTTP_CONNECTED;
-       if (conf->buffer_tree_given)
-               rn->btrn = btr_new_node("receiver", NULL, NULL, NULL);
        return 1;
 }
 
diff --git a/recv.c b/recv.c
index c8edb59..ca50556 100644 (file)
--- a/recv.c
+++ b/recv.c
@@ -92,6 +92,8 @@ int main(int argc, char *argv[])
        }
        r = &receivers[receiver_num];
        rn.receiver = r;
+       if (conf.buffer_tree_given)
+               rn.btrn = btr_new_node("receiver", NULL, NULL, NULL);
        ret = r->open(&rn);
        if (ret < 0)
                goto out;
@@ -113,10 +115,13 @@ int main(int argc, char *argv[])
 
        ret = schedule(&s);
 out:
-       if (conf.buffer_tree_given)
-               btr_free_node(sot.btrn);
        if (r_opened)
                r->close(&rn);
+       if (conf.buffer_tree_given) {
+               btr_free_node(rn.btrn);
+               btr_free_node(sot.btrn);
+       }
+       free(rn.conf);
        if (r)
                r->shutdown();
        if (ret < 0)