gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r3199 - in GNUnet: . src/applications/traffic src/include


From: grothoff
Subject: [GNUnet-SVN] r3199 - in GNUnet: . src/applications/traffic src/include
Date: Sun, 30 Jul 2006 21:19:58 -0700 (PDT)

Author: grothoff
Date: 2006-07-30 21:19:56 -0700 (Sun, 30 Jul 2006)
New Revision: 3199

Modified:
   GNUnet/src/applications/traffic/clientapi.c
   GNUnet/src/applications/traffic/traffic.c
   GNUnet/src/applications/traffic/traffic.h
   GNUnet/src/include/gnunet_traffic_lib.h
   GNUnet/todo
Log:
traffic compiles

Modified: GNUnet/src/applications/traffic/clientapi.c
===================================================================
--- GNUnet/src/applications/traffic/clientapi.c 2006-07-31 04:07:31 UTC (rev 
3198)
+++ GNUnet/src/applications/traffic/clientapi.c 2006-07-31 04:19:56 UTC (rev 
3199)
@@ -43,7 +43,7 @@
  * @param peers set to number of peers involved
  * @return OK on success, SYSERR on error
  */
-int pollSocket(GNUNET_TCP_SOCKET * sock,
+int pollSocket(struct ClientServerConnection * sock,
               unsigned int timeframe,
               unsigned short type,
               unsigned short direction,
@@ -61,24 +61,18 @@
     = htons(CS_PROTO_traffic_QUERY);
   req.timePeriod
     = htonl(timeframe);
-  if (SYSERR == writeToSocket(sock,
-                             &req.header)) {
-    GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
-       _("Failed to query gnunetd about traffic conditions.\n"));
-    return SYSERR;
-  }
+  if (SYSERR == connection_write(sock,
+                                &req.header)) 
+    return SYSERR;  
   info = NULL;
-  if (SYSERR == readFromSocket(sock,
-                              (CS_MESSAGE_HEADER**)&info)) {
-    GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
-       _("Did not receive reply from gnunetd about traffic conditions.\n"));
-    return SYSERR;
-  }
+  if (SYSERR == connection_read(sock,
+                               (MESSAGE_HEADER**)&info)) 
+    return SYSERR;  
   if ( (ntohs(info->header.type) !=
        CS_PROTO_traffic_INFO) ||
        (ntohs(info->header.size) !=
        sizeof(CS_traffic_info_MESSAGE) + 
ntohl(info->count)*sizeof(TRAFFIC_COUNTER)) ) {
-    GE_BREAK(ectx, 0);
+    GE_BREAK(NULL, 0);
     return SYSERR;
   }
 

Modified: GNUnet/src/applications/traffic/traffic.c
===================================================================
--- GNUnet/src/applications/traffic/traffic.c   2006-07-31 04:07:31 UTC (rev 
3198)
+++ GNUnet/src/applications/traffic/traffic.c   2006-07-31 04:19:56 UTC (rev 
3199)
@@ -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, 2006 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
@@ -150,7 +150,7 @@
 /**
  * Lock to synchronize access.
  */
-static Mutex lock;
+static struct MUTEX * lock;
 
 /**
  * Highest message type seen so far.
@@ -183,7 +183,7 @@
   unsigned int i;
   unsigned int slot;
 
-  cronTime(&now);
+  now = get_time();
   unitNow = now / TRAFFIC_TIME_UNIT;
   delta = now - dtc->lastUpdate;
   dtc->lastUpdate = now;
@@ -255,7 +255,7 @@
   unsigned long long totalMsgSize;
 
   updateUse(dtc, 0, 0, YES); /* expire old entries */
-  cronTime(&now);
+  now = get_time();
   unitNow = now / TRAFFIC_TIME_UNIT;
 
   /* count number of peers that we interacted with in
@@ -292,7 +292,7 @@
   unsigned int count;
   unsigned int i;
 
-  MUTEX_LOCK(&lock);
+  MUTEX_LOCK(lock);
   count = 0;
   for (i=0;i<max_message_type;i++)
     if (counters[i] != NULL) {
@@ -324,12 +324,12 @@
                     i);
     }
 
-  MUTEX_UNLOCK(&lock);
+  MUTEX_UNLOCK(lock);
   return reply;
 }
 
-static int trafficQueryHandler(ClientHandle sock,
-                              const CS_MESSAGE_HEADER * message) {
+static int trafficQueryHandler(struct ClientHandle * sock,
+                              const MESSAGE_HEADER * message) {
   CS_traffic_request_MESSAGE * msg;
   CS_traffic_info_MESSAGE * reply;
   int ret;
@@ -373,14 +373,14 @@
 
   if (timePeriod > HISTORY_SIZE)
     timePeriod = HISTORY_SIZE;
-  MUTEX_LOCK(&lock);
+  MUTEX_LOCK(lock);
   if ( (messageType >= max_message_type) ||
        (counters[messageType] == NULL) ) {
     *avgMessageSize = 0;
     *messageCount = 0;
     *peerCount = 0;
     *timeDistribution = 0;
-    MUTEX_UNLOCK(&lock);
+    MUTEX_UNLOCK(lock);
     return OK;
   }
 
@@ -409,7 +409,7 @@
   else
     *avgMessageSize = 0;
   *timeDistribution = dtc->slots;
-  MUTEX_UNLOCK(&lock);
+  MUTEX_UNLOCK(lock);
   return OK;
 }
 
@@ -482,19 +482,19 @@
  * @param sender the identity of the sender
  */
 static int trafficReceive(const PeerIdentity * sender,
-                         const P2P_MESSAGE_HEADER * header) {
+                         const MESSAGE_HEADER * header) {
   unsigned short port;
 
   port = ntohs(header->type);
   updateTrafficReceiveCounter(port,
                              ntohs(header->size));
-  MUTEX_LOCK(&lock);
+  MUTEX_LOCK(lock);
   checkPort(port);
   updateUse(&counters[port]->receive,
            ntohs(header->size),
            sender->hashPubKey.bits[0],
            NO);
-  MUTEX_UNLOCK(&lock);
+  MUTEX_UNLOCK(lock);
   return OK;
 }
 
@@ -505,19 +505,19 @@
  * @param receiver the identity of the receiver
  */
 static int trafficSend(const PeerIdentity * receiver,
-                      const P2P_MESSAGE_HEADER * header) {
+                      const MESSAGE_HEADER * header) {
   unsigned short port;
 
   port = ntohs(header->type);
   updateTrafficSendCounter(port,
                           ntohs(header->size));
-  MUTEX_LOCK(&lock);
+  MUTEX_LOCK(lock);
   checkPort(port);
   updateUse(&counters[port]->send,
            ntohs(header->size),
            receiver->hashPubKey.bits[0],
            NO);
-  MUTEX_UNLOCK(&lock);
+  MUTEX_UNLOCK(lock);
   return OK;
 }
 
@@ -546,8 +546,8 @@
   }
 #endif
 
-  GE_ASSERT(ectx, counters == NULL);
-  MUTEX_CREATE(&lock);
+  GE_ASSERT(coreAPI->ectx, counters == NULL);
+  lock = MUTEX_CREATE(NO);
 #if KEEP_RECEIVE_STATS || KEEP_TRANSMITTED_STATS
   stats = capi->requestService("stats");
 #endif
@@ -577,7 +577,8 @@
   GROW(counters,
        max_message_type,
        0);
-  MUTEX_DESTROY(&lock);
+  MUTEX_DESTROY(lock);
+  lock = NULL;
   coreAPI = NULL;
 }
 
@@ -590,19 +591,22 @@
  * Initialize the traffic module.
  */
 int initialize_module_traffic(CoreAPIForApplication * capi) {
-  GE_ASSERT(ectx, myCoreAPI == NULL);
+  GE_ASSERT(capi->ectx, myCoreAPI == NULL);
   myCoreAPI = capi;
   myApi = capi->requestService("traffic");
   if (myApi == NULL) {
-    GE_BREAK(ectx, 0);
+    GE_BREAK(capi->ectx, 0);
     myCoreAPI = NULL;
     return SYSERR;
   }
   capi->registerClientHandler(CS_PROTO_traffic_QUERY,
                              &trafficQueryHandler);
-  setConfigurationString("ABOUT",
-                        "traffic",
-                        gettext_noop("tracks bandwidth utilization by 
gnunetd"));
+  GE_ASSERT(capi->ectx,
+           0 == GC_set_configuration_value_string(capi->cfg,
+                                                  capi->ectx,
+                                                  "ABOUT",
+                                                  "traffic",
+                                                  gettext_noop("tracks 
bandwidth utilization by gnunetd")));
   return OK;                           
 }
 
@@ -610,9 +614,10 @@
  * Shutdown the traffic module.
  */
 void done_module_traffic() {
-  GE_ASSERT(ectx, myCoreAPI != NULL);
-  GE_ASSERT(ectx, SYSERR != 
myCoreAPI->unregisterClientHandler(CS_PROTO_traffic_QUERY,
-                                                            
&trafficQueryHandler));
+  GE_ASSERT(NULL, myCoreAPI != NULL);
+  GE_ASSERT(myCoreAPI->ectx,
+           SYSERR != myCoreAPI->unregisterClientHandler(CS_PROTO_traffic_QUERY,
+                                                        &trafficQueryHandler));
   myCoreAPI->releaseService(myApi);
   myApi = NULL;
   myCoreAPI = NULL;

Modified: GNUnet/src/applications/traffic/traffic.h
===================================================================
--- GNUnet/src/applications/traffic/traffic.h   2006-07-31 04:07:31 UTC (rev 
3198)
+++ GNUnet/src/applications/traffic/traffic.h   2006-07-31 04:19:56 UTC (rev 
3199)
@@ -70,7 +70,7 @@
  * if it sends a CS_TRAFFIC_QUERY to gnunetd.
  */
 typedef struct {
-  CS_MESSAGE_HEADER header;
+  MESSAGE_HEADER header;
 
   /**
    * The number of different message types we have seen
@@ -98,7 +98,7 @@
  * Request for CS_traffic_info_MESSAGE.
  */
 typedef struct {
-  CS_MESSAGE_HEADER header;
+  MESSAGE_HEADER header;
 
   /**
    * How many time units back should the statistics returned contain?

Modified: GNUnet/src/include/gnunet_traffic_lib.h
===================================================================
--- GNUnet/src/include/gnunet_traffic_lib.h     2006-07-31 04:07:31 UTC (rev 
3198)
+++ GNUnet/src/include/gnunet_traffic_lib.h     2006-07-31 04:19:56 UTC (rev 
3199)
@@ -28,6 +28,7 @@
 #define GNUNET_TRAFFIC_LIB_H
 
 #include "gnunet_util.h"
+#include "gnunet_util_network_client.h"
 #include "gnunet_traffic_service.h"
 
 #ifdef __cplusplus
@@ -52,7 +53,7 @@
  *        highest bit is current time-unit, bit 1 is 32 time-units ago (set)
  * @return OK on success, SYSERR on error
  */
-int pollSocket(GNUNET_TCP_SOCKET * sock,
+int pollSocket(struct ClientServerConnection * sock,
               unsigned int timeframe,
               unsigned short type,
               unsigned short direction,

Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2006-07-31 04:07:31 UTC (rev 3198)
+++ GNUnet/todo 2006-07-31 04:19:56 UTC (rev 3199)
@@ -27,9 +27,9 @@
     + needs testing, also likely to be missing features
   * applications:
     + fragmentation, identity,  pingpong, session, transport,
-      stats, topology_default, state, getoption, advertising compile
+      stats, topology_default, state, getoption, advertising,
+      traffic compile
     + bootstrap_http: maybe switch to libwww?
-    + for basics: traffic (720)
     + for fs: datastore (787), fs (18500), gap (2800), sqstore_sqlite (1375)
     + rest: sqstore_mysql, dht, chat, kvstore_sqlite, 
             sqstore_mysql, rpc, tbench, template, testbed, 





reply via email to

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