gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r5319 - in GNUnet/src: applications/advertising application


From: gnunet
Subject: [GNUnet-SVN] r5319 - in GNUnet/src: applications/advertising applications/fs/ecrs applications/pingpong applications/session applications/transport include server transports
Date: Tue, 17 Jul 2007 10:32:54 -0600 (MDT)

Author: grothoff
Date: 2007-07-17 10:32:54 -0600 (Tue, 17 Jul 2007)
New Revision: 5319

Modified:
   GNUnet/src/applications/advertising/advertising.c
   GNUnet/src/applications/fs/ecrs/downloadtest.c
   GNUnet/src/applications/pingpong/pingpong.c
   GNUnet/src/applications/session/connect.c
   GNUnet/src/applications/transport/transport.c
   GNUnet/src/include/gnunet_core.h
   GNUnet/src/include/gnunet_transport_service.h
   GNUnet/src/server/connection.c
   GNUnet/src/server/gnunet-transport-check.c
   GNUnet/src/server/handler.c
   GNUnet/src/transports/http.c
   GNUnet/src/transports/tcp_helper.c
   GNUnet/src/transports/udp_helper.c
Log:
more debug code for tcp disconnect problems

Modified: GNUnet/src/applications/advertising/advertising.c
===================================================================
--- GNUnet/src/applications/advertising/advertising.c   2007-07-17 05:31:52 UTC 
(rev 5318)
+++ GNUnet/src/applications/advertising/advertising.c   2007-07-17 16:32:54 UTC 
(rev 5319)
@@ -342,7 +342,7 @@
 
 
   /* Establish session as advertised in the hello */
-  tsession = transport->connect (msg);
+  tsession = transport->connect (msg, __FILE__);
   if (tsession == NULL)
     {
       if (stats != NULL)
@@ -372,7 +372,7 @@
       GE_LOG (ectx,
               GE_INFO | GE_REQUEST | GE_USER,
               _("Could not send HELLO+PING, ping buffer full.\n"));
-      transport->disconnect (tsession);
+      transport->disconnect (tsession, __FILE__);
       if (stats != NULL)
         stats->change (stat_hello_ping_busy, 1);
       return SYSERR;
@@ -397,7 +397,7 @@
       FREE (buffer);
       if (stats != NULL)
         stats->change (stat_hello_noselfad, 1);
-      transport->disconnect (tsession);
+      transport->disconnect (tsession, __FILE__);
       return SYSERR;
     }
   res = OK;
@@ -420,7 +420,7 @@
         stats->change (stat_plaintextPingSent, 1);
     }
   FREE (buffer);
-  if (SYSERR == transport->disconnect (tsession))
+  if (SYSERR == transport->disconnect (tsession, __FILE__))
     res = SYSERR;
   return res;
 }
@@ -493,7 +493,7 @@
 #endif
       return OK;
     }
-  tsession = transport->connect (hello);
+  tsession = transport->connect (hello, __FILE__);
   FREE (hello);
   if (tsession == NULL)
     {
@@ -510,7 +510,7 @@
   coreAPI->sendPlaintext (tsession,
                           (char *) &sd->m->header,
                           P2P_hello_MESSAGE_size (sd->m));
-  transport->disconnect (tsession);
+  transport->disconnect (tsession, __FILE__);
 #if DEBUG_ADVERTISING
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER, "Exit from %s.\n", __FUNCTION__);

Modified: GNUnet/src/applications/fs/ecrs/downloadtest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/downloadtest.c      2007-07-17 05:31:52 UTC 
(rev 5318)
+++ GNUnet/src/applications/fs/ecrs/downloadtest.c      2007-07-17 16:32:54 UTC 
(rev 5319)
@@ -49,13 +49,12 @@
    unsigned long long completedBytes,
    cron_t eta,
    unsigned long long lastBlockOffset,
-   const char *lastBlock, unsigned int lastBlockSize, void *closure) {
+   const char *lastBlock, unsigned int lastBlockSize, void *closure)
+{
 #if 0
-  printf("Completed: %llu - Now: at %llu got %u bytes\n",
-        completedBytes,
-        lastBlockOffset,
-        lastBlockSize);
-#endif  
+  printf ("Completed: %llu - Now: at %llu got %u bytes\n",
+          completedBytes, lastBlockOffset, lastBlockSize);
+#endif
 }
 
 
@@ -123,35 +122,36 @@
   FREE (tmp);
   tmpName = makeName (0);
   ret = SYSERR;
-  for (j=SIZE-16*1024;j>=0;j-=16 * 1024) {
-    if (OK == ECRS_downloadPartialFile (NULL,
-                                       cfg,
-                                       uri,
-                                       tmpName, 
-                                       j,
-                                       16 * 1024,
-                                       0,
-                                       NO,
-                                       &progress_check, 
-                                       NULL, 
-                                       &testTerminate, 
-                                       NULL)) {      
-      fd = disk_file_open (NULL, tmpName, O_RDONLY);
-      buf = MALLOC (size);
-      in = MALLOC (size);
-      memset (buf, size + size / 253, size);
-      for (i = 0; i < (int) (size - 42 - sizeof (HashCode512));
-           i += sizeof (HashCode512))
-        hash (&buf[i], 42, (HashCode512 *) & buf[i + sizeof (HashCode512)]);
-      if (size != READ (fd, in, size))
-        ret = SYSERR;
-      else if (0 == memcmp (&buf[j], &in[j], 16 * 1024))
-        ret = OK;
-      FREE (buf);
-      FREE (in);
-      CLOSE (fd);
+  for (j = SIZE - 16 * 1024; j >= 0; j -= 16 * 1024)
+    {
+      if (OK == ECRS_downloadPartialFile (NULL,
+                                          cfg,
+                                          uri,
+                                          tmpName,
+                                          j,
+                                          16 * 1024,
+                                          0,
+                                          NO,
+                                          &progress_check,
+                                          NULL, &testTerminate, NULL))
+        {
+          fd = disk_file_open (NULL, tmpName, O_RDONLY);
+          buf = MALLOC (size);
+          in = MALLOC (size);
+          memset (buf, size + size / 253, size);
+          for (i = 0; i < (int) (size - 42 - sizeof (HashCode512));
+               i += sizeof (HashCode512))
+            hash (&buf[i], 42,
+                  (HashCode512 *) & buf[i + sizeof (HashCode512)]);
+          if (size != READ (fd, in, size))
+            ret = SYSERR;
+          else if (0 == memcmp (&buf[j], &in[j], 16 * 1024))
+            ret = OK;
+          FREE (buf);
+          FREE (in);
+          CLOSE (fd);
+        }
     }
-  }
   UNLINK (tmpName);
   FREE (tmpName);
   return ret;
@@ -202,8 +202,8 @@
   ECRS_freeUri (uri);
   CHECK (OK == unindexFile (SIZE));
   fprintf (stderr, " Ok.\n");
-    
 
+
   /* END OF TEST CODE */
 FAILURE:
   if (sock != NULL)

Modified: GNUnet/src/applications/pingpong/pingpong.c
===================================================================
--- GNUnet/src/applications/pingpong/pingpong.c 2007-07-17 05:31:52 UTC (rev 
5318)
+++ GNUnet/src/applications/pingpong/pingpong.c 2007-07-17 16:32:54 UTC (rev 
5319)
@@ -168,12 +168,12 @@
   TSession *mytsession;
   int ret;
 
-  mytsession = transport->connectFreely (peer, YES);
+  mytsession = transport->connectFreely (peer, YES, __FILE__);
   if (mytsession == NULL)
     return SYSERR;
   ret = coreAPI->sendPlaintext (mytsession,
                                 (char *) msg, sizeof (P2P_pingpong_MESSAGE));
-  transport->disconnect (mytsession);
+  transport->disconnect (mytsession, __FILE__);
   return ret;
 }
 

Modified: GNUnet/src/applications/session/connect.c
===================================================================
--- GNUnet/src/applications/session/connect.c   2007-07-17 05:31:52 UTC (rev 
5318)
+++ GNUnet/src/applications/session/connect.c   2007-07-17 16:32:54 UTC (rev 
5319)
@@ -435,8 +435,9 @@
     return SYSERR;
   hash2enc (&receiver->hashPubKey, &enc);
   /* then try to connect on the transport level */
-  if ((tsession == NULL) || (transport->associate (tsession) == SYSERR))
-    tsession = transport->connectFreely (receiver, YES);
+  if ((tsession == NULL)
+      || (transport->associate (tsession, __FILE__) == SYSERR))
+    tsession = transport->connectFreely (receiver, YES, __FILE__);
   if (tsession == NULL)
     {
 #if DEBUG_SESSION
@@ -454,7 +455,7 @@
   if (ping == NULL)
     {
       FREE (sndr);
-      transport->disconnect (tsession);
+      transport->disconnect (tsession, __FILE__);
       return SYSERR;
     }
 
@@ -476,7 +477,7 @@
   FREE (ping);
   if (skey == NULL)
     {
-      transport->disconnect (tsession);
+      transport->disconnect (tsession, __FILE__);
       return SYSERR;
     }
 
@@ -516,12 +517,12 @@
   if (0 != memcmp (receiver, &tsession->peer, sizeof (PeerIdentity)))
     {
       GE_BREAK (NULL, 0);
-      transport->disconnect (tsession);
     }
   else
     {
       coreAPI->offerTSessionFor (receiver, tsession);
     }
+  transport->disconnect (tsession, __FILE__);
   coreAPI->assignSessionKey (&sk, receiver, age, YES);
   return OK;
 }

Modified: GNUnet/src/applications/transport/transport.c
===================================================================
--- GNUnet/src/applications/transport/transport.c       2007-07-17 05:31:52 UTC 
(rev 5318)
+++ GNUnet/src/applications/transport/transport.c       2007-07-17 16:32:54 UTC 
(rev 5319)
@@ -53,6 +53,8 @@
 
 static struct MUTEX *tapis_lock;
 
+static struct MUTEX *lock;
+
 static struct GE_Context *ectx;
 
 #define HELLO_RECREATE_FREQ (5 * cronMINUTES)
@@ -186,7 +188,7 @@
  * @return session on success, NULL on error
  */
 static TSession *
-transportConnect (const P2P_hello_MESSAGE * hello)
+transportConnect (const P2P_hello_MESSAGE * hello, const char *token)
 {
   unsigned short prot;
   TSession *tsession;
@@ -205,11 +207,16 @@
   if (OK != tapis[prot]->connect (hello, &tsession))
     return NULL;
   tsession->ttype = prot;
+  MUTEX_LOCK (lock);
+  APPEND (tsession->tokens, tsession->token_count, token);
+  MUTEX_UNLOCK (lock);
+
   return tsession;
 }
 
 static TSession *
-transportConnectFreely (const PeerIdentity * peer, int useTempList)
+transportConnectFreely (const PeerIdentity * peer, int useTempList,
+                        const char *token)
 {
   int i;
   P2P_hello_MESSAGE *hello;
@@ -231,7 +238,7 @@
       if (hello == NULL)
         continue;
       hc++;
-      ret = transportConnect (hello);
+      ret = transportConnect (hello, token);
       FREE (hello);
       if (ret != NULL)
         {
@@ -266,12 +273,21 @@
  *         SYSERR if not.
  */
 static int
-transportAssociate (TSession * tsession)
+transportAssociate (TSession * tsession, const char *token)
 {
+  int ret;
+
   if ((tsession == NULL) ||
       (tsession->ttype >= tapis_count) || (tapis[tsession->ttype] == NULL))
     return SYSERR;
-  return tapis[tsession->ttype]->associate (tsession);
+  ret = tapis[tsession->ttype]->associate (tsession);
+  if (ret == OK)
+    {
+      MUTEX_LOCK (lock);
+      APPEND (tsession->tokens, tsession->token_count, token);
+      MUTEX_UNLOCK (lock);
+    }
+  return ret;
 }
 
 /**
@@ -322,8 +338,10 @@
  * @return OK on success, SYSERR on error
  */
 static int
-transportDisconnect (TSession * tsession)
+transportDisconnect (TSession * tsession, const char *token)
 {
+  int i;
+
   if (tsession == NULL)
     {
       GE_BREAK (ectx, 0);
@@ -334,6 +352,29 @@
       GE_BREAK (ectx, 0);
       return SYSERR;
     }
+  MUTEX_LOCK (lock);
+  for (i = 0; i < tsession->token_count; i++)
+    {
+      if (0 == strcmp (tsession->tokens[i], token))
+        {
+          tsession->tokens[i] = tsession->tokens[tsession->token_count - 1];
+          GROW (tsession->tokens,
+                tsession->token_count, tsession->token_count - 1);
+          i = -1;
+          break;
+        }
+    }
+  if (i != -1)
+    {
+      GE_BREAK (ectx, 0);
+      GE_LOG (ectx,
+              GE_ERROR | GE_DEVELOPER | GE_USER | GE_IMMEDIATE,
+              "Illegal call to `%s', do not have token `%s'\n",
+              __FUNCTION__, token);
+      MUTEX_UNLOCK (lock);
+      return SYSERR;
+    }
+  MUTEX_UNLOCK (lock);
   return tapis[tsession->ttype]->disconnect (tsession);
 }
 
@@ -648,6 +689,7 @@
   GROW (tapis, tapis_count, UDP_PROTOCOL_NUMBER + 1);
 
   tapis_lock = MUTEX_CREATE (YES);
+  lock = MUTEX_CREATE (NO);
 
   /* now load transports */
   dso = NULL;
@@ -765,6 +807,7 @@
     if (tapis[i] != NULL)
       unloadTransport (i);
   MUTEX_DESTROY (tapis_lock);
+  MUTEX_DESTROY (lock);
   tapis_lock = NULL;
   GROW (tapis, tapis_count, 0);
 

Modified: GNUnet/src/include/gnunet_core.h
===================================================================
--- GNUnet/src/include/gnunet_core.h    2007-07-17 05:31:52 UTC (rev 5318)
+++ GNUnet/src/include/gnunet_core.h    2007-07-17 16:32:54 UTC (rev 5319)
@@ -79,8 +79,12 @@
 {
   void *internal;
 
+  const char **tokens;
+
   PeerIdentity peer;
 
+  unsigned int token_count;
+
   unsigned short ttype;
 } TSession;
 

Modified: GNUnet/src/include/gnunet_transport_service.h
===================================================================
--- GNUnet/src/include/gnunet_transport_service.h       2007-07-17 05:31:52 UTC 
(rev 5318)
+++ GNUnet/src/include/gnunet_transport_service.h       2007-07-17 16:32:54 UTC 
(rev 5319)
@@ -84,9 +84,11 @@
    * not available.
    *
    * @param hello the hello of the target node
+   * @param token string identifying who is holding the reference
+   *              (must match when disconnect is called)
    * @return session handle on success, NULL on error
    */
-  TSession *(*connect) (const P2P_hello_MESSAGE * hello);
+  TSession *(*connect) (const P2P_hello_MESSAGE * hello, const char *token);
 
   /**
    * Connect to another peer, picking any transport that
@@ -95,9 +97,12 @@
    * @param peer which peer to connect to
    * @param allowTempLists may we even select hellos that have
    *        not yet been confirmed?
+   * @param token string identifying who is holding the reference
+   *              (must match when disconnect is called)
    * @return session handle on success, NULL on error
    */
-  TSession *(*connectFreely) (const PeerIdentity * peer, int allowTempList);
+  TSession *(*connectFreely) (const PeerIdentity * peer, int allowTempList,
+                              const char *token);
 
   /**
    * A (core) Session is to be associated with a transport session. The
@@ -109,10 +114,12 @@
    * @param tsession the session handle passed along
    *   from the call to receive that was made by the transport
    *   layer
+   * @param token string identifying who is holding the reference
+   *              (must match when disconnect is called)
    * @return OK if the session could be associated,
    *         SYSERR if not.
    */
-  int (*associate) (TSession * tsession);
+  int (*associate) (TSession * tsession, const char *token);
 
   /**
    * Get the cost of a message in for the given transport mechanism.
@@ -135,10 +142,12 @@
   /**
    * Close the session with the remote node. May only be called on
    * either connected or associated sessions.
+   * @param token string identifying who is holding the reference
+   *              (must match when connect/assciate call)
    *
    * @return OK on success, SYSERR on error
    */
-  int (*disconnect) (TSession * session);
+  int (*disconnect) (TSession * session, const char *token);
 
   /**
    * Verify that a hello is ok. Call a method

Modified: GNUnet/src/server/connection.c
===================================================================
--- GNUnet/src/server/connection.c      2007-07-17 05:31:52 UTC (rev 5318)
+++ GNUnet/src/server/connection.c      2007-07-17 16:32:54 UTC (rev 5319)
@@ -1498,7 +1498,8 @@
 {
   if (be->session.tsession != NULL)
     return OK;
-  be->session.tsession = transport->connectFreely (&be->session.sender, YES);
+  be->session.tsession =
+    transport->connectFreely (&be->session.sender, YES, __FILE__);
   if (be->session.tsession == NULL)
     return NO;
   be->session.mtu = transport->getMTU (be->session.tsession->ttype);
@@ -1580,7 +1581,7 @@
       /* transport session is gone! re-establish! */
       tsession = be->session.tsession;
       be->session.tsession = NULL;
-      transport->disconnect (tsession);
+      transport->disconnect (tsession, __FILE__);
       ensureTransportConnected (be);
       /* This may have changed the MTU => need to re-do
          everything.  Since we don't want to possibly
@@ -1751,7 +1752,7 @@
     {
       tsession = be->session.tsession;
       be->session.tsession = NULL;
-      transport->disconnect (tsession);
+      transport->disconnect (tsession, __FILE__);
     }
 
   FREE (encryptedMsg);
@@ -2050,7 +2051,7 @@
     {
       tsession = be->session.tsession;
       be->session.tsession = NULL;
-      transport->disconnect (tsession);
+      transport->disconnect (tsession, __FILE__);
     }
   for (i = 0; i < be->sendBufferSize; i++)
     {
@@ -3083,8 +3084,7 @@
  * on that TCP connection instead of keeping SMTP going.<p>
  *
  * Taking the transport over only makes sense if the cost is lower.
- * This method checks this.  If not, the transport session is
- * disconnected.
+ * This method checks this. 
  *
  * @param tsession the transport session that is for grabs
  * @param sender the identity of the other node
@@ -3109,7 +3109,6 @@
   if (be == NULL)
     {
       MUTEX_UNLOCK (lock);
-      transport->disconnect (tsession);
       return;
     }
   cost = -1;
@@ -3127,19 +3126,18 @@
      data on throughput. - CG
    */
   if ((transport->getCost (tsession->ttype) < cost) &&
-      (transport->associate (tsession) == OK))
+      (transport->associate (tsession, __FILE__) == OK))
     {
       ts = be->session.tsession;
       if (ts != NULL)
         {
           be->session.tsession = NULL;
-          transport->disconnect (ts);
+          transport->disconnect (ts, __FILE__);
         }
       be->session.tsession = tsession;
       be->session.mtu = transport->getMTU (tsession->ttype);
       fragmentIfNecessary (be);
     }
-  transport->disconnect (tsession);
   MUTEX_UNLOCK (lock);
 }
 

Modified: GNUnet/src/server/gnunet-transport-check.c
===================================================================
--- GNUnet/src/server/gnunet-transport-check.c  2007-07-17 05:31:52 UTC (rev 
5318)
+++ GNUnet/src/server/gnunet-transport-check.c  2007-07-17 16:32:54 UTC (rev 
5319)
@@ -269,7 +269,7 @@
     fprintf (stderr, ".");
   tsession = NULL;
   peer = hello->senderIdentity;
-  tsession = transport->connect (hello);
+  tsession = transport->connect (hello, __FILE__);
   FREE (hello);
   if (tsession == NULL)
     {
@@ -299,7 +299,7 @@
     {
       fprintf (stderr, "Send failed.\n");
       FREE (msg);
-      transport->disconnect (tsession);
+      transport->disconnect (tsession, __FILE__);
       return;
     }
   FREE (msg);
@@ -325,7 +325,7 @@
   cron_resume_jobs (cron, NO);
   SEMAPHORE_DESTROY (sem);
   sem = NULL;
-  transport->disconnect (tsession);
+  transport->disconnect (tsession, __FILE__);
   if (ok == YES)
     stats[2]++;
 }

Modified: GNUnet/src/server/handler.c
===================================================================
--- GNUnet/src/server/handler.c 2007-07-17 05:31:52 UTC (rev 5318)
+++ GNUnet/src/server/handler.c 2007-07-17 16:32:54 UTC (rev 5319)
@@ -47,6 +47,12 @@
  */
 #define MEASURE_TIME NO
 
+/**
+ * Should we validate that handlers do not
+ * modify the messages that they are given?
+ * (expensive!)
+ */
+#define VALIDATE_CLIENT YES
 
 /**
  * How many incoming packages do we have in the buffer
@@ -395,6 +401,9 @@
 #if MEASURE_TIME
   cron_t now;
 #endif
+#if VALIDATE_CLIENT
+  void *old_value;
+#endif
 
   pos = 0;
   copy = NULL;
@@ -472,6 +481,10 @@
           last = 0;
           while (NULL != (callback = handlers[ptyp][last]))
             {
+#if VALIDATE_CLIENT
+              old_value = MALLOC (plen);
+              memcpy (old_value, part, plen);
+#endif
               if (SYSERR == callback (sender, part))
                 {
 #if DEBUG_HANDLER
@@ -484,6 +497,14 @@
                   copy = NULL;
                   return;       /* handler says: do not process the rest of 
the message */
                 }
+#if VALIDATE_CLIENT
+              if (0 != memcmp (old_value, part, plen))
+                GE_LOG (ectx,
+                        GE_ERROR | GE_DEVELOPER | GE_IMMEDIATE,
+                        "Handler %d at %p violated const!\n", ptyp, callback);
+              FREE (old_value);
+#endif
+
               last++;
             }
 #if MEASURE_TIME
@@ -566,9 +587,7 @@
   ret = checkHeader (sender, (P2P_PACKET_HEADER *) msg, size);
   if (ret == SYSERR)
     return;                     /* message malformed */
-  if ((ret == YES) &&
-      (tsession != NULL) &&
-      (sender != NULL) && (OK == transport->associate (tsession)))
+  if ((ret == YES) && (tsession != NULL) && (sender != NULL))
     considerTakeover (sender, tsession);
   injectMessage (sender,
                  &msg[sizeof (P2P_PACKET_HEADER)],
@@ -603,7 +622,7 @@
       /* handle buffer - now out of sync */
       handleMessage (mp->tsession, &mp->sender, mp->msg, mp->size);
       if (mp->tsession != NULL)
-        transport->disconnect (mp->tsession);
+        transport->disconnect (mp->tsession, __FILE__);
       FREE (mp->msg);
       FREE (mp);
     }
@@ -703,7 +722,7 @@
     }
   /* try to increment session reference count */
   if ((mp->tsession != NULL) &&
-      (SYSERR == transport->associate (mp->tsession)))
+      (SYSERR == transport->associate (mp->tsession, __FILE__)))
     mp->tsession = NULL;
 
   MUTEX_LOCK (globalLock_);

Modified: GNUnet/src/transports/http.c
===================================================================
--- GNUnet/src/transports/http.c        2007-07-17 05:31:52 UTC (rev 5318)
+++ GNUnet/src/transports/http.c        2007-07-17 16:32:54 UTC (rev 5319)
@@ -649,6 +649,7 @@
       httpSession->users = 1;   /* us only, core has not seen this tsession! */
       httpSession->lastUse = get_time ();
       tsession = MALLOC (sizeof (TSession));
+      memset (tsession, 0, sizeof (TSession));
       tsession->ttype = HTTP_PROTOCOL_NUMBER;
       tsession->internal = httpSession;
       tsession->peer = *(coreAPI->myIdentity);
@@ -901,6 +902,7 @@
   httpSession->is_client = YES;
   httpSession->cs.client.get = curl_get;
   tsession = MALLOC (sizeof (TSession));
+  memset (tsession, 0, sizeof (TSession));
   httpSession->tsession = tsession;
   tsession->ttype = HTTP_PROTOCOL_NUMBER;
   tsession->internal = httpSession;

Modified: GNUnet/src/transports/tcp_helper.c
===================================================================
--- GNUnet/src/transports/tcp_helper.c  2007-07-17 05:31:52 UTC (rev 5318)
+++ GNUnet/src/transports/tcp_helper.c  2007-07-17 16:32:54 UTC (rev 5319)
@@ -379,6 +379,7 @@
   GE_LOG (ectx, GE_DEBUG | GE_USER | GE_BULK, "Accepting TCP connection.\n");
 #endif
   tcpSession = MALLOC (sizeof (TCPSession));
+  memset (tcpSession, 0, sizeof (TCPSession));
   tcpSession->sock = sock;
   /* fill in placeholder identity to mark that we
      are waiting for the welcome message */
@@ -389,6 +390,7 @@
   tcpSession->in_select = YES;
 
   tsession = MALLOC (sizeof (TSession));
+  memset (tsession, 0, sizeof (TSession));
   tsession->ttype = TCP_PROTOCOL_NUMBER;
   tsession->internal = tcpSession;
   tcpSession->tsession = tsession;
@@ -580,10 +582,12 @@
   TCPSession *tcpSession;
 
   tcpSession = MALLOC (sizeof (TCPSession));
+  memset (tcpSession, 0, sizeof (TCPSession));
   tcpSession->addr_len = 0;
   tcpSession->accept_addr = NULL;
   tcpSession->sock = s;
   tsession = MALLOC (sizeof (TSession));
+  memset (tsession, 0, sizeof (TSession));
   tsession->internal = tcpSession;
   tsession->ttype = protocolNumber;
   tsession->peer = hello->senderIdentity;

Modified: GNUnet/src/transports/udp_helper.c
===================================================================
--- GNUnet/src/transports/udp_helper.c  2007-07-17 05:31:52 UTC (rev 5318)
+++ GNUnet/src/transports/udp_helper.c  2007-07-17 16:32:54 UTC (rev 5319)
@@ -149,6 +149,7 @@
   TSession *tsession;
 
   tsession = MALLOC (sizeof (TSession));
+  memset (tsession, 0, sizeof (TSession));
   tsession->internal = MALLOC (P2P_hello_MESSAGE_size (hello));
   memcpy (tsession->internal, hello, P2P_hello_MESSAGE_size (hello));
   tsession->ttype = udpAPI.protocolNumber;





reply via email to

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