[Pkg-privacy-commits] [onioncat] 117/241: minor fixes in local Tor listener code (socket acceptor)

Intrigeri intrigeri at moszumanska.debian.org
Wed Aug 26 16:16:46 UTC 2015


This is an automated email from the git hooks/post-receive script.

intrigeri pushed a commit to branch upstream-master
in repository onioncat.

commit cac201e184f6a0df7db2304219ef15c55599ddc3
Author: eagle <eagle at 58e1ccc2-750e-0410-8d0d-f93ca75ab447>
Date:   Sun Jan 11 18:10:31 2009 +0000

    minor fixes in local Tor listener code (socket acceptor)
    
    git-svn-id: https://www.cypherpunk.at/svn/onioncat/trunk@429 58e1ccc2-750e-0410-8d0d-f93ca75ab447
---
 TODO            |  1 +
 src/ocateth.c   |  6 +++++-
 src/ocatlibe.c  |  4 ++++
 src/ocatroute.c | 25 +++++++++++++++++--------
 4 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/TODO b/TODO
index 1a577ac..f7c2c15 100644
--- a/TODO
+++ b/TODO
@@ -1,3 +1,4 @@
+* work on header compression (start at RFC2507 or 3095)
 * disconnected permanent peers are not reconnected sometimes
 * peer reconnections timeout should be implemented (to not reconnect to fast)
 * log connect log to OC console
diff --git a/src/ocateth.c b/src/ocateth.c
index 65eada7..748181f 100644
--- a/src/ocateth.c
+++ b/src/ocateth.c
@@ -34,7 +34,7 @@ static pthread_mutex_t mac_mutex_ = PTHREAD_MUTEX_INITIALIZER;
 /*! Pseudo header for IPv6 checksum calculation.
  *  RFC2460 8.1, (RFC1885 2.3) RFC2463, RFC1071. */
 /* RFC2461, rfc2462, RFC2464 ipv6 ethernet enc.
- * 2373 addrassng ipv6
+ * RFC2373 is obsoleted by RFC3513 addressing ipv6
  * RFC2461 is obsoleted by RFC4861
  * RFC4862 IPv6 Stateless Address Autoconfiguration
  */
@@ -69,7 +69,9 @@ void print_mac_tbl(FILE *f)
 void mac_cleanup(void)
 {
    int i;
+#ifdef DEBUG
    char hw[20];
+#endif
 
    pthread_mutex_lock(&mac_mutex_);
 
@@ -297,7 +299,9 @@ int ndp_soladv(char *buf, int rlen)
    ndp6_t *ndp6 = (ndp6_t*) (buf + 4);
    struct nd_opt_hdr *ohd = (struct nd_opt_hdr*) (ndp6 + 1);
    uint16_t *ckb, cksum;
+#ifdef DEBUG
    char hw[20];
+#endif
 
    if (ndp6->eth.ether_dhost[0] & 1)
    {
diff --git a/src/ocatlibe.c b/src/ocatlibe.c
index b9ba778..3077445 100644
--- a/src/ocatlibe.c
+++ b/src/ocatlibe.c
@@ -147,9 +147,13 @@ void add_listener(const char *buf, const char *def)
 
    if (!(CNF(oc_listen)[CNF(oc_listen_cnt) - 1] = calloc(1, sizeof(struct sockaddr_in6))))
       log_msg(LOG_ERR, "could not get memory for listener : \"%s\"", strerror(errno)), exit(1);
+
+   CNF(oc_listen_fd)[CNF(oc_listen_cnt) - 1] = -1;
+
    if (def)
       if (strsockaddr(def, CNF(oc_listen)[CNF(oc_listen_cnt) - 1]) == -1)
          log_msg(LOG_EMERG, "illegal default string '%s'", def), exit(1);
+
    if (strsockaddr(buf, CNF(oc_listen)[CNF(oc_listen_cnt) - 1]) == -1)
       log_msg(LOG_EMERG, "could not convert address string '%s'", buf), exit(1);
 }
diff --git a/src/ocatroute.c b/src/ocatroute.c
index ecc47e9..658455a 100644
--- a/src/ocatroute.c
+++ b/src/ocatroute.c
@@ -653,36 +653,44 @@ int create_listener(struct sockaddr *addr, int sock_len)
  *         connection arrives.
  *  @return File descriptor or -1 on error.
  */
-int run_listeners(struct sockaddr **addr, int *sockfd, int (action_accept)(int))
+int run_listeners(struct sockaddr **addr, int *sockfd, int cnt, int (action_accept)(int))
 {
    int fd;
-   struct sockaddr *saddr;
+   //struct sockaddr *saddr;
    struct sockaddr_in6 in6;
    fd_set rset;
-   int maxfd, i, cnt;
+   int maxfd, i;
    socklen_t alen;
    char iabuf[INET6_ADDRSTRLEN];
 
-   for (i = 0; i < CNF(oc_listen_cnt); i++)
+   for (i = 0; i < cnt; i++)
    {
       log_debug("create listener");
-      if ((sockfd[i] = create_listener(CNF(oc_listen)[i], SOCKADDR_SIZE(CNF(oc_listen)[i]))) == -1)
+      if ((sockfd[i] = create_listener(addr[i], SOCKADDR_SIZE(addr[i]))) == -1)
          log_msg(LOG_EMERG, "exiting"), exit(1);
    }
-   cnt = i;
 
    for (;;)
    {
       log_debug("setting up fd_set");
       FD_ZERO(&rset);
-      maxfd = 0;
+      maxfd = -1;
       for (i = 0; i < cnt; i++)
       {
+         if (sockfd[i] == -1)
+            continue;
+
          FD_SET(sockfd[i], &rset);
          if (sockfd[i] > maxfd)
             maxfd = sockfd[i];
       }
 
+      if (maxfd == -1)
+      {
+         log_debug("no active listener fds available");
+         break;
+      }
+
       log_debug("selecting locally (maxfd = %d)", maxfd);
       if ((maxfd = select(maxfd + 1, &rset, NULL, NULL, NULL)) == -1)
       {
@@ -714,6 +722,7 @@ int run_listeners(struct sockaddr **addr, int *sockfd, int (action_accept)(int))
          (void) action_accept(fd);
       }
    }
+   log_debug("run_listeners returns");
    return 0;
 }
 
@@ -803,7 +812,7 @@ int run_local_listeners(short port, int *sockfd, int (action_accept)(int))
 void *socket_acceptor(void *p)
 {
    //run_local_listeners(CNF(ocat_listen_port), sockfd_, insert_anon_peer);
-   run_listeners(CNF(oc_listen), CNF(oc_listen_fd), insert_anon_peer);
+   run_listeners(CNF(oc_listen), CNF(oc_listen_fd), CNF(oc_listen_cnt), insert_anon_peer);
    return NULL;
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onioncat.git



More information about the Pkg-privacy-commits mailing list