[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r3221 - in GNUnet: . src/applications/gap src/include src/u
From: |
grothoff |
Subject: |
[GNUnet-SVN] r3221 - in GNUnet: . src/applications/gap src/include src/util/string |
Date: |
Sat, 12 Aug 2006 19:15:15 -0700 (PDT) |
Author: grothoff
Date: 2006-08-12 19:15:12 -0700 (Sat, 12 Aug 2006)
New Revision: 3221
Modified:
GNUnet/src/applications/gap/gap.c
GNUnet/src/include/gnunet_util_string.h
GNUnet/src/util/string/xmalloc.c
GNUnet/todo
Log:
fixing gap
Modified: GNUnet/src/applications/gap/gap.c
===================================================================
--- GNUnet/src/applications/gap/gap.c 2006-08-13 02:02:14 UTC (rev 3220)
+++ GNUnet/src/applications/gap/gap.c 2006-08-13 02:15:12 UTC (rev 3221)
@@ -138,7 +138,7 @@
/**
* Size of the indirection table specified in gnunet.conf
*/
-static unsigned int indirectionTableSize;
+static unsigned long long indirectionTableSize;
/**
* Constant but peer-dependent value that randomizes the construction
@@ -172,12 +172,12 @@
/**
* Hard CPU limit
*/
-static int hardCPULimit;
+static unsigned long long hardCPULimit;
/**
* Hard network upload limit.
*/
-static int hardUpLimit;
+static unsigned long long hardUpLimit;
#if DO_HISTOGRAM
static int histogram[65536];
@@ -215,7 +215,8 @@
static QUERY_POLICY
evaluateQuery(const PeerIdentity * sender,
unsigned int * priority) {
- unsigned int netLoad = getNetworkLoadUp();
+ unsigned int netLoad = os_network_monitor_get_load(coreAPI->load_monitor,
+ Upload);
if ( (netLoad == (unsigned int) -1) ||
(netLoad < IDLE_LOAD_THRESHOLD) ) {
@@ -502,6 +503,19 @@
}
/**
+ * Return 1 if the current network (upstream) or CPU load is
+ * too high, 0 if the load is ok.
+ */
+static int loadTooHigh() {
+ return ( (hardCPULimit > 0) &&
+ (os_cpu_get_load(ectx,
+ coreAPI->cfg) >= hardCPULimit) ) ||
+ ( (hardUpLimit > 0) &&
+ (os_network_monitor_get_load(coreAPI->load_monitor,
+ Upload) >= hardUpLimit) );
+}
+
+/**
* A "PerNodeCallback" method that forwards the query to the selected
* nodes.
*/
@@ -519,10 +533,7 @@
return; /* never send back to source */
/* Load above hard limit? */
- if ( ( (hardCPULimit > 0) &&
- (getCPULoad() >= hardCPULimit) ) ||
- ( (hardUpLimit > 0) &&
- (getNetworkLoadUp() >= hardUpLimit) ) )
+ if (loadTooHigh())
return;
id = intern_pid(peer);
@@ -1405,10 +1416,7 @@
#endif
/* Load above hard limit? */
- if ( ( (hardCPULimit > 0) &&
- (getCPULoad() >= hardCPULimit) ) ||
- ( (hardUpLimit > 0) &&
- (getNetworkLoadUp() >= hardUpLimit) ) )
+ if (loadTooHigh())
return SYSERR;
senderID = intern_pid(sender);
@@ -1477,7 +1485,8 @@
if (cls.valueCount > 0) {
perm = permute(WEAK, cls.valueCount);
- max = getNetworkLoadDown();
+ max = os_network_monitor_get_load(coreAPI->load_monitor,
+ Download);
if (max > 100)
max = 100;
if (max == -1)
@@ -1933,10 +1942,7 @@
}
/* Load above hard limit? */
- if ( ( (hardCPULimit > 0) &&
- (getCPULoad() >= hardCPULimit) ) ||
- ( (hardUpLimit > 0) &&
- (getNetworkLoadUp() >= hardUpLimit) ) ) {
+ if (loadTooHigh()) {
#if DEBUG_GAP
if (sender != NULL) {
IF_GELOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
@@ -2079,6 +2085,29 @@
ectx = capi->ectx;
cfg = capi->cfg;
+
+ if ( (-1 == GC_get_configuration_value_number(coreAPI->cfg,
+ "LOAD",
+ "HARDCPULIMIT",
+ 0,
+ 100000, /* 1000 CPUs!? */
+ 0, /* 0 == no limit */
+ &hardCPULimit)) ||
+ (-1 == GC_get_configuration_value_number(coreAPI->cfg,
+ "LOAD",
+ "HARDUPLIMIT",
+ 0,
+ 100, /* 100% */
+ 0, /* 0 == no limit */
+ &hardUpLimit)) ||
+ (-1 == GC_get_configuration_value_number(coreAPI->cfg,
+ "GAP",
+ "TABLESIZE",
+ MIN_INDIRECTION_TABLE_SIZE,
+ MAX_MALLOC_CHECKED /
sizeof(IndirectionTableEntry),
+ MIN_INDIRECTION_TABLE_SIZE,
+ &indirectionTableSize)) )
+ return NULL;
GE_ASSERT(ectx, sizeof(P2P_gap_reply_MESSAGE) == 68);
GE_ASSERT(ectx, sizeof(P2P_gap_query_MESSAGE) == 144);
@@ -2110,10 +2139,8 @@
GROW(rewards,
rewardSize,
MAX_REWARD_TRACKS);
-
- hardCPULimit = getConfigurationInt("LOAD", "HARDCPULIMIT");
- hardUpLimit = getConfigurationInt("LOAD", "HARDUPLIMIT");
+
identity = coreAPI->requestService("identity");
GE_ASSERT(ectx, identity != NULL);
topology = coreAPI->requestService("topology");
@@ -2124,11 +2151,6 @@
_("Traffic service failed to load; gap cannot ensure cover-traffic
availability.\n"));
}
random_qsel = weak_randomi(0xFFFF);
- indirectionTableSize =
- getConfigurationInt("GAP",
- "TABLESIZE");
- if (indirectionTableSize < MIN_INDIRECTION_TABLE_SIZE)
- indirectionTableSize = MIN_INDIRECTION_TABLE_SIZE;
lookup_exclusion = MUTEX_CREATE(NO);
ROUTING_indTable_
= MALLOC(sizeof(IndirectionTableEntry)
Modified: GNUnet/src/include/gnunet_util_string.h
===================================================================
--- GNUnet/src/include/gnunet_util_string.h 2006-08-13 02:02:14 UTC (rev
3220)
+++ GNUnet/src/include/gnunet_util_string.h 2006-08-13 02:15:12 UTC (rev
3221)
@@ -50,6 +50,11 @@
#include "gnunet_util_config.h"
/**
+ * Maximum allocation with MALLOC macro.
+ */
+#define MAX_MALLOC_CHECKED (1024 * 1024 * 40)
+
+/**
* Wrapper around malloc. Allocates size bytes of memory.
*
* @param size the number of bytes to allocate, must be
Modified: GNUnet/src/util/string/xmalloc.c
===================================================================
--- GNUnet/src/util/string/xmalloc.c 2006-08-13 02:02:14 UTC (rev 3220)
+++ GNUnet/src/util/string/xmalloc.c 2006-08-13 02:15:12 UTC (rev 3221)
@@ -51,7 +51,7 @@
/* As a security precaution, we generally do not allow very large
allocations using the default 'MALLOC' macro */
GE_ASSERT_FLF(NULL,
- size <= 1024 * 1024 * 40,
+ size <= MAX_MALLOC_CHECKED,
filename,
linenumber,
function);
Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2006-08-13 02:02:14 UTC (rev 3220)
+++ GNUnet/todo 2006-08-13 02:15:12 UTC (rev 3221)
@@ -27,9 +27,9 @@
+ fragmentation, identity, pingpong, session, transport,
stats, topology_default, state, getoption, advertising,
traffic, ecrs_core, template, tbench, tracekit, fs/fslib,
- fs/module compile
+ fs/module, gap compile
+ bootstrap_http: maybe switch to libwww?
- + for fs: fs (18500), gap (2800)
+ + for fs: fs/ecrs (7000), fs/fsui (5500), fs/tools (2500)
+ rest: sqstore_mysql, dht, rpc, topology_f2f, vpn
+ low priority: chat, kvstore_sqlite, testbed
* setup:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r3221 - in GNUnet: . src/applications/gap src/include src/util/string,
grothoff <=