gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r6404 - GNUnet/src/applications/chat


From: gnunet
Subject: [GNUnet-SVN] r6404 - GNUnet/src/applications/chat
Date: Thu, 21 Feb 2008 09:20:35 -0700 (MST)

Author: grothoff
Date: 2008-02-21 09:20:35 -0700 (Thu, 21 Feb 2008)
New Revision: 6404

Modified:
   GNUnet/src/applications/chat/chat.c
   GNUnet/src/applications/chat/clientapi.c
Log:
must not have these

Modified: GNUnet/src/applications/chat/chat.c
===================================================================
--- GNUnet/src/applications/chat/chat.c 2008-02-21 16:05:30 UTC (rev 6403)
+++ GNUnet/src/applications/chat/chat.c 2008-02-21 16:20:35 UTC (rev 6404)
@@ -37,13 +37,18 @@
 
 #define MAX_LAST_MESSAGES 12
 
+/* P2P */
 static unsigned int clientCount;
 static struct GNUNET_HashCode **lastMsgs;
 static int ringIndex;
+
 static struct GNUNET_Mutex *chatMutex;
+
 static struct GNUNET_GE_Context *ectx;
+
 static struct GNUNET_GC_Configuration *cfg;
 
+/* P2P-ish */
 struct GNUNET_Server_Chat_Room
 {
 
@@ -62,8 +67,10 @@
 
 };
 
+ /* YUCK - USE PTR! */
 static struct GNUNET_CS_chat_client client_list;
 
+/* P2P */
 static void
 markSeen (GNUNET_HashCode * hc)
 {
@@ -79,12 +86,14 @@
   unsigned int delay;
 } BCC;
 
+/* P2P */
 static void
 bccHelper (const GNUNET_PeerIdentity * peer, BCC * bcc)
 {
   coreAPI->unicast (peer, bcc->message, bcc->prio, bcc->delay);
 }
 
+/* P2P */
 static void
 broadcastToConnected (const GNUNET_MessageHeader * message,
                       unsigned int prio, unsigned int delay)
@@ -121,6 +130,7 @@
 
   if (ntohs (cmsg->header.size) < sizeof (CS_chat_MESSAGE))
     {
+      /* TOO VERBOSE */
       GNUNET_GE_LOG (ectx,
                      GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
                      _("Message received from client is invalid\n"));
@@ -138,6 +148,7 @@
   message_content = GNUNET_malloc (msg_len + 1);
   room_name = GNUNET_malloc (room_name_len + 1);
 
+  /* BUFFER OVERFLOWS! */
   memcpy (nick, &cmsg->nick[0], nick_len);
   memcpy (message_content, &cmsg->nick[nick_len], msg_len);
   memcpy (room_name, &cmsg->nick[nick_len + msg_len], room_name_len);
@@ -150,7 +161,7 @@
 
   GNUNET_GE_LOG (ectx,
                  GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
-                 "Received chat message from client.\n Message is %s\n from 
%s\n intended for room %s\n",
+                 "Received chat message from client.\n Message is `%s'\n from 
`%s'\n intended for room `%s'\n",
                  message_content, nick, room_name);
 
   GNUNET_hash (cmsg, header_size, &hc);
@@ -178,6 +189,7 @@
     }
 
 
+  /* THIS IS P2P STUFF -- MAYBE DEFINE AN INTERNAL P2P API (for bonii)? */
   markSeen (&hc);
   broadcastToConnected (message, 5, 1);
 
@@ -191,6 +203,7 @@
   return GNUNET_OK;
 }
 
+/* FUNCTION NAME! */
 static int
 csHandleChatRequest (struct GNUNET_ClientHandle *client,
                      const GNUNET_MessageHeader * message)
@@ -216,6 +229,7 @@
 
   if (ntohs (cmsg->header.size) < sizeof (CS_chat_JOIN_MESSAGE))
     {
+      /* TOO VERBOSE */
       GNUNET_GE_LOG (ectx,
                      GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
                      _
@@ -235,13 +249,14 @@
   client_key = GNUNET_malloc (sizeof (GNUNET_RSA_PublicKey));
   room_name = GNUNET_malloc (room_name_len + 1);
 
+  /* BUFFER OVERFLOWS */
   memcpy (nick, &cmsg->nick[0], nick_len);
   memcpy (client_key, &cmsg->nick[nick_len], pubkey_len);
   memcpy (room_name, &cmsg->nick[nick_len + pubkey_len], room_name_len);
 
   GNUNET_GE_LOG (ectx,
                  GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_DEVELOPER,
-                 "Received join chat room message from client.\n From %s\n for 
room %s\n",
+                 "Received join chat room message from client.\n From `%s'\n 
for room `%s'\n",
                  nick, room_name);
 
   nick[nick_len] = '\0';
@@ -312,6 +327,7 @@
   return GNUNET_OK;
 }
 
+/* WHY HAVE A LEAVE REQUEST AT ALL? => CLIENT EXIT HANDLER */
 static int
 csHandleChatLeaveRequest (struct GNUNET_ClientHandle *client,
                           const GNUNET_MessageHeader * message)
@@ -333,10 +349,11 @@
   GNUNET_mutex_lock (chatMutex);
 
   /*TODO: delete client context on the server */
-
+  /* YUCK */
   tempClient = &client_list;
   while ((tempClient->next != NULL) && (tempClient->client != NULL))
     {
+      /* YUCK YUCK! */
       if (memcmp (tempClient->client, client, sizeof (client)) == 0)
         {
           fprintf (stderr, "Client handle matches, remove it!\n");

Modified: GNUnet/src/applications/chat/clientapi.c
===================================================================
--- GNUnet/src/applications/chat/clientapi.c    2008-02-21 16:05:30 UTC (rev 
6403)
+++ GNUnet/src/applications/chat/clientapi.c    2008-02-21 16:20:35 UTC (rev 
6404)
@@ -32,6 +32,7 @@
 #include "chat.h"
 
 #define MAX_RETRIES 5
+
 /**
  * Handle for a (joined) chat room.
  */
@@ -65,13 +66,6 @@
 
 };
 
-static void *
-thread_main (void *rcls)
-{
-  struct GNUNET_CHAT_Room *room = rcls;
-  return NULL;
-}
-
 /**
  * Listen for incoming messages on this chat room.  When received, call the 
client callback.
  * Also, support servers going away/coming back (i.e. rejoin chat room to keep 
server state up to date)... 
@@ -79,27 +73,27 @@
 static void *
 poll_thread (void *rcls)
 {
-  int ret = GNUNET_OK;
-  struct GNUNET_CHAT_Room *room = (struct GNUNET_CHAT_Room *) rcls;
+  struct GNUNET_CHAT_Room *room = rcls;
+  int ret;
   GNUNET_MessageHeader *reply;
-
   CS_chat_MESSAGE *received_msg;
-
   unsigned int size;
   unsigned int nick_len;
   unsigned int msg_len;
   unsigned int room_name_len;
   unsigned int retries;
-
   char *nick;
   char *message_content;
   char *room_name;
 
+  ret = GNUNET_OK;
+  /* CHECK FOR SHUTDOWN! */
   while (ret == GNUNET_OK)
     {
       if (GNUNET_client_connection_test_connected (room->sock) == GNUNET_NO)
         {
-          retries = 0;
+         /* FIXME - why limit retries? */
+          retries = 0;   
           while ((GNUNET_client_connection_test_connected (room->sock) ==
                   GNUNET_NO) && (retries < MAX_RETRIES))
             {
@@ -111,7 +105,7 @@
 
       if (GNUNET_OK != GNUNET_client_connection_read (room->sock, &reply))
         {
-
+         /* NO BREAK! */
           break;
         }
 
@@ -126,12 +120,14 @@
 
       nick_len = ntohl (received_msg->nick_len);
       msg_len = ntohl (received_msg->msg_len);
+      /* NO NEED TO SEND ROOM! */
       room_name_len = ntohl (received_msg->room_name_len);
 
       nick = GNUNET_malloc (nick_len + 1);
       message_content = GNUNET_malloc (msg_len + 1);
       room_name = GNUNET_malloc (room_name_len + 1);
 
+      /* BUFFER OVERFLOWS! */
       memcpy (nick, &received_msg->nick[0], nick_len);
       memcpy (message_content, &received_msg->nick[nick_len], msg_len);
       memcpy (room_name, &received_msg->nick[nick_len + msg_len],
@@ -149,7 +145,7 @@
         }
 
     }
-
+  /* RETURN NULL? (void*) ret is TERRIBLE!!! */
   return (void *) ret;
 }
 
@@ -236,8 +232,10 @@
   if (GNUNET_SYSERR ==
       GNUNET_client_connection_write (sock, &join_msg->header))
     {
+      /* ALREADY LOGGED */
       fprintf (stderr, _("Error writing to socket.\n"));
       ret = GNUNET_SYSERR;
+      /* WHY CONTINUE HERE? => CREATES BAD THREAD! */
     }
 
   GNUNET_free (join_msg);
@@ -286,7 +284,8 @@
   csHdr.size = htons (sizeof (csHdr));
 
   /*If this fails we don't care, this means the socket is already gone and the 
server should know how to deal with that! */
-  /*We may not even need this message at all, just let the server handle a 
dead socket */
+  /*We may not even need this message at all, just let the server handle a 
dead socket */ 
+  /* RIGHT, SO WHY HAVE IT? */
   GNUNET_GE_ASSERT (NULL,
                     GNUNET_client_connection_write (chat_room->sock,
                                                     &csHdr) == GNUNET_OK);





reply via email to

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