gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r1193 - in GNUnet/src: applications/identity applications/s


From: grothoff
Subject: [GNUnet-SVN] r1193 - in GNUnet/src: applications/identity applications/session server
Date: Fri, 1 Jul 2005 11:29:06 -0700 (PDT)

Author: grothoff
Date: 2005-07-01 11:29:01 -0700 (Fri, 01 Jul 2005)
New Revision: 1193

Modified:
   GNUnet/src/applications/identity/identity.c
   GNUnet/src/applications/session/connect.c
   GNUnet/src/server/connection.c
Log:
hangup fixes, more stats

Modified: GNUnet/src/applications/identity/identity.c
===================================================================
--- GNUnet/src/applications/identity/identity.c 2005-07-01 18:17:09 UTC (rev 
1192)
+++ GNUnet/src/applications/identity/identity.c 2005-07-01 18:29:01 UTC (rev 
1193)
@@ -43,6 +43,7 @@
 #define MAX_TEMP_HOSTS 32
 
 #define TRUSTDIR "data/credit/"
+#define HOST_DIR "data/hosts/"
 
 /**
  * Masks to keep track when the trust has changed and
@@ -933,6 +934,7 @@
 provide_module_identity(CoreAPIForApplication * capi) {
   static Identity_ServiceAPI id;
   char * gnHome;
+  char * tmp;
   int i;
 
   id.getPublicPrivateKey = &getPublicPrivateKey;
@@ -961,21 +963,31 @@
                  &myIdentity);
 
   MUTEX_CREATE_RECURSIVE(&lock_);
-  networkIdDirectory
-    = getFileName("GNUNETD",
-                 "HOSTS",
-                 _("Configuration file must specify directory for "
-                   "network identities in section %s under %s.\n"));
-  mkdirp(networkIdDirectory);
   gnHome = getFileName("GNUNETD",
                       "GNUNETD_HOME",
                       _("Configuration file must specify a "
                         "directory for GNUnet to store "
                         "per-peer data under %s%s\n"));
+  networkIdDirectory
+    = getConfigurationString("GNUNETD",
+                            "HOSTS");
+  if (networkIdDirectory == NULL) {
+    networkIdDirectory 
+      = MALLOC(strlen(gnHome) + strlen(HOST_DIR) + 2);
+    strcpy(networkIdDirectory, gnHome);
+    strcat(networkIdDirectory, DIR_SEPARATOR_STR);
+    strcat(networkIdDirectory, HOST_DIR);
+  } else {
+    tmp = 
+      expandFileName(networkIdDirectory);
+    FREE(networkIdDirectory);
+    networkIdDirectory = tmp;
+  }
+  mkdirp(networkIdDirectory);
   trustDirectory = MALLOC(strlen(gnHome) +
                          strlen(TRUSTDIR)+2);
   strcpy(trustDirectory, gnHome);
-  strcat(trustDirectory, "/");
+  strcat(trustDirectory, DIR_SEPARATOR_STR);
   strcat(trustDirectory, TRUSTDIR);
   mkdirp(trustDirectory);
   FREE(gnHome);

Modified: GNUnet/src/applications/session/connect.c
===================================================================
--- GNUnet/src/applications/session/connect.c   2005-07-01 18:17:09 UTC (rev 
1192)
+++ GNUnet/src/applications/session/connect.c   2005-07-01 18:29:01 UTC (rev 
1193)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2001, 2002, 2003, 2004 Christian Grothoff (and other contributing 
authors)
+     (C) 2001, 2002, 2003, 2004, 2005 Christian Grothoff (and other 
contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published

Modified: GNUnet/src/server/connection.c
===================================================================
--- GNUnet/src/server/connection.c      2005-07-01 18:17:09 UTC (rev 1192)
+++ GNUnet/src/server/connection.c      2005-07-01 18:29:01 UTC (rev 1193)
@@ -501,6 +501,8 @@
 
 static int stat_sizeMessagesDropped;
 
+static int stat_hangupSent;
+
 /* ******************** CODE ********************* */
 
 /**
@@ -1535,21 +1537,37 @@
   if (be->status == STAT_UP) {
     SendEntry * se;
 
-    hangup.header.type = htons(p2p_PROTO_HANGUP);
-    hangup.header.size = htons(sizeof(HANGUP_Message));
+    hangup.header.type
+      = htons(p2p_PROTO_HANGUP);
+    hangup.header.size 
+      = htons(sizeof(HANGUP_Message));
     identity->getPeerIdentity(identity->getPublicPrivateKey(),
                              &hangup.sender);
     se = MALLOC(sizeof(SendEntry));
-    se->len = sizeof(HANGUP_Message);
-    se->flags = SE_FLAG_PLACE_TAIL;
-    se->pri = EXTREME_PRIORITY;
-    se->transmissionTime = cronTime(NULL); /* now */
-    se->callback = &copyCallback;
-    se->closure = MALLOC(sizeof(HANGUP_Message));
+    se->len 
+      = sizeof(HANGUP_Message);
+    se->flags
+      = SE_FLAG_PLACE_TAIL;
+    se->pri 
+      = EXTREME_PRIORITY;
+    se->transmissionTime
+      = cronTime(NULL); /* now */
+    se->callback
+      = &copyCallback;
+    se->closure
+      = MALLOC(sizeof(HANGUP_Message));
     memcpy(se->closure,
           &hangup,
           sizeof(HANGUP_Message));
     appendToBuffer(be, se);
+    if (stats != NULL)
+      stats->change(stat_hangupSent,
+                   1);
+    /* override send frequency and
+       really try hard to get the HANGUP
+       out! */
+    be->lastSendAttempt = 0;
+    sendBuffer(be);
   }
   be->skey_remote_created = 0;
   be->status = STAT_DOWN;
@@ -2127,8 +2145,9 @@
     } else { /* for receiving */
       if ( ((be->status & STAT_SKEY_RECEIVED) == 0) ||
           (be->skey_remote_created < age) ) {
-       if (! equalsHashCode512(key,
-                               &be->skey_remote)) {
+       if (0 != memcmp(key,
+                       &be->skey_remote,
+                       sizeof(SESSIONKEY))) {
          be->skey_remote = *key;
          be->lastSequenceNumberReceived = 0;
        }
@@ -2468,6 +2487,8 @@
       = stats->create(_("# outgoing messages dropped"));
     stat_sizeMessagesDropped
       = stats->create(_("# bytes of outgoing messages dropped"));
+    stat_hangupSent
+      = stats->create(_("# connections closed (HANGUP sent)"));
   }
   transport->start(&core_receive);
 }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]