gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r6621 - GNUnet/src/applications/chat
Date: Tue, 25 Mar 2008 14:16:11 -0600 (MDT)

Author: nevans
Date: 2008-03-25 14:16:10 -0600 (Tue, 25 Mar 2008)
New Revision: 6621

Modified:
   GNUnet/src/applications/chat/clientapi.c
Log:


Modified: GNUnet/src/applications/chat/clientapi.c
===================================================================
--- GNUnet/src/applications/chat/clientapi.c    2008-03-25 19:51:05 UTC (rev 
6620)
+++ GNUnet/src/applications/chat/clientapi.c    2008-03-25 20:16:10 UTC (rev 
6621)
@@ -31,6 +31,8 @@
 #include "gnunet_chat_lib.h"
 #include "chat.h"
 
+static struct GNUNET_Mutex *chatMutex;
+
 /**
  * Listen for incoming messages on this chat room.  When received,
  * call the proper client callback.  Also, support servers going away/coming
@@ -56,6 +58,7 @@
   ret = GNUNET_OK;
   while ((ret == GNUNET_OK) && (room->shutdown_flag != GNUNET_YES))
     {
+       
       if (disconnected)
         {
           GNUNET_thread_sleep (15 * GNUNET_CRON_SECONDS);
@@ -70,13 +73,14 @@
           else
             break;
         }
+      
       reply = NULL;
       if (GNUNET_OK != GNUNET_client_connection_read (room->sock, &reply))
         {
           disconnected = GNUNET_YES;
           continue;
         }
-
+                       
       if (((reply->size < ntohs (sizeof (CS_chat_MESSAGE)))
            || (reply->type != ntohs (GNUNET_CS_PROTO_CHAT_MSG)))
           && ((reply->size < ntohs (sizeof (CS_chat_ROOM_MEMBER_MESSAGE)))
@@ -195,6 +199,7 @@
   struct GNUNET_CHAT_Room *chat_room;
   struct GNUNET_ClientServerConnection *sock;
   int size_of_join;
+  chatMutex = GNUNET_mutex_create (GNUNET_NO);
 
   sock = GNUNET_client_connection_create (ectx, cfg);
   if (sock == NULL)
@@ -296,6 +301,7 @@
 void
 GNUNET_CHAT_leave_room (struct GNUNET_CHAT_Room *chat_room)
 {
+       GNUNET_mutex_lock(chatMutex);
   void *unused;
   chat_room->shutdown_flag = GNUNET_YES;
   GNUNET_client_connection_close_forever (chat_room->sock);
@@ -306,6 +312,7 @@
   GNUNET_free (chat_room->memberInfo);
   GNUNET_client_connection_destroy (chat_room->sock);
   GNUNET_free (chat_room);
+  GNUNET_mutex_unlock(chatMutex);
 }
 
 /**





reply via email to

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