[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r8850 - GNUnet/src/applications/testing
From: |
gnunet |
Subject: |
[GNUnet-SVN] r8850 - GNUnet/src/applications/testing |
Date: |
Tue, 25 Aug 2009 12:52:37 -0600 |
Author: nevans
Date: 2009-08-25 12:52:37 -0600 (Tue, 25 Aug 2009)
New Revision: 8850
Modified:
GNUnet/src/applications/testing/remote.c
GNUnet/src/applications/testing/remotetopologies.c
Log:
code cleanup, leak fixes (oops) and new small world topology fixes
Modified: GNUnet/src/applications/testing/remote.c
===================================================================
--- GNUnet/src/applications/testing/remote.c 2009-08-25 18:51:24 UTC (rev
8849)
+++ GNUnet/src/applications/testing/remote.c 2009-08-25 18:52:37 UTC (rev
8850)
@@ -239,7 +239,7 @@
static int
get_pid (struct GNUNET_REMOTE_TESTING_DaemonContext *daemon)
{
- char *cmd;
+ char *tempcmd;
int length;
unsigned int is_local = 0;
FILE *output;
@@ -253,26 +253,25 @@
if (is_local)
{
length = snprintf (NULL, 0, "cat %s", daemon->pid);
- cmd = GNUNET_malloc (length + 1);
- snprintf (cmd, length + 1, "cat %s", daemon->pid);
+ tempcmd = GNUNET_malloc (length + 1);
+ snprintf (tempcmd, length + 1, "cat %s", daemon->pid);
}
else
{
length =
snprintf (NULL, 0, "ssh address@hidden cat %s", daemon->username,
daemon->hostname, daemon->pid);
- cmd = GNUNET_malloc (length + 1);
- snprintf (cmd, length + 1, "ssh address@hidden cat %s", daemon->username,
+ tempcmd = GNUNET_malloc (length + 1);
+ snprintf (tempcmd, length + 1, "ssh address@hidden cat %s",
daemon->username,
daemon->hostname, daemon->pid);
}
#if VERBOSE
- fprintf (stderr, _("exec command is : %s \n"), cmd);
+ fprintf (stderr, _("exec command is : %s \n"), tempcmd);
#endif
-
- if ((cmd != NULL) && (strcmp (cmd, "") != 0))
+ pid = -1;
+ if ((tempcmd != NULL) && (strcmp (tempcmd, "") != 0))
{
- output = popen (cmd, "r");
- GNUNET_free (cmd);
+ output = popen (tempcmd, "r");
if ((output != NULL) && (fscanf (output, "%d", &pid) == 1))
{
#if VERBOSE
@@ -284,7 +283,10 @@
pid = -1;
}
}
-
+ if (output != NULL)
+ fclose(output);
+ if (tempcmd != NULL)
+ GNUNET_free(tempcmd);
return pid;
}
@@ -1082,6 +1084,14 @@
GNUNET_free (hostnames);
GNUNET_free (remote_config_path);
GNUNET_free (remote_gnunetd_path);
+ GNUNET_free(mysql_user);
+ GNUNET_free(mysql_db);
+ GNUNET_free(mysql_password);
+ GNUNET_free(mysql_server);
+ GNUNET_free(logNModifier_string);
+ if (temp_pid_file != NULL)
+ GNUNET_free(temp_pid_file);
+
*ret_peers = new_ret_peers;
return ret;
}
Modified: GNUnet/src/applications/testing/remotetopologies.c
===================================================================
--- GNUnet/src/applications/testing/remotetopologies.c 2009-08-25 18:51:24 UTC
(rev 8849)
+++ GNUnet/src/applications/testing/remotetopologies.c 2009-08-25 18:52:37 UTC
(rev 8850)
@@ -429,9 +429,10 @@
int
GNUNET_REMOTE_connect_small_world_ring (unsigned int number_of_daemons,
- struct GNUNET_REMOTE_host_list
- **list_as_array, FILE * dotOutFile,
- double percentage, double logNModifier)
+ struct GNUNET_REMOTE_host_list
+ **list_as_array, FILE * dotOutFile,
+ double percentage,
+ double logNModifier)
{
unsigned int i, j;
int nodeToConnect;
@@ -440,9 +441,8 @@
double random;
unsigned int totalConnections, smallWorldConnections;
int connsPerPeer;
- int distance;
natLog = log (number_of_daemons);
- connsPerPeer = ceil(natLog * logNModifier);
+ connsPerPeer = ceil (natLog * logNModifier);
int max;
int min;
unsigned int useAnd;
@@ -450,70 +450,86 @@
if (connsPerPeer % 2 == 1)
connsPerPeer += 1;
- srand((unsigned int)GNUNET_get_time());
+ srand ((unsigned int) GNUNET_get_time ());
smallWorldConnections = 0;
totalConnections = 0;
for (i = 0; i < number_of_daemons; i++)
- {
- useAnd = 0;
- max = i + connsPerPeer/2;
- min = i - connsPerPeer/2;
-
- if (max > number_of_daemons - 1)
{
- max = max - number_of_daemons;
- useAnd = 1;
- }
+ useAnd = 0;
+ max = i + connsPerPeer / 2;
+ min = i - connsPerPeer / 2;
- if (min < 0)
- {
- min = number_of_daemons - 1 + min;
- useAnd = 1;
- }
+ if (max > number_of_daemons - 1)
+ {
+ max = max - number_of_daemons;
+ useAnd = 1;
+ }
+
+ if (min < 0)
+ {
+ min = number_of_daemons - 1 + min;
+ useAnd = 1;
+ }
#if VERBOSE
- fprintf (stderr, _("For peer %d, number must be less than %d or
greater than %d (%d)\n"), i, min, max, useAnd);
+ fprintf (stderr,
+ _
+ ("For peer %d, number must be less than %d or greater than %d
(%d)\n"),
+ i, min, max, useAnd);
#endif
- for (j = 0; j < connsPerPeer/2; j++)
- {
- random = ((double) rand() / RAND_MAX);
- if (random < percentage)
- {
- /* Connect to uniformly selected random peer */
- randomPeer = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK,
number_of_daemons);
- while ((((randomPeer < max) && (randomPeer > min)) && (useAnd == 0))
|| (((randomPeer > min) || (randomPeer < max)) && (useAnd == 1)))
+ for (j = 0; j < connsPerPeer / 2; j++)
{
+ random = ((double) rand () / RAND_MAX);
+ if (random < percentage)
+ {
+ /* Connect to uniformly selected random peer */
+ randomPeer =
+ GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK,
+ number_of_daemons);
+ while ((((randomPeer < max) && (randomPeer > min))
+ && (useAnd == 0)) || (((randomPeer > min)
+ || (randomPeer < max))
+ && (useAnd == 1)))
+ {
#if VERBOSE
- fprintf (stderr, _("NOT connecting node %u to %u (already existing
connection!)\n"), i, randomPeer);
+ fprintf (stderr,
+ _
+ ("NOT connecting node %u to %u (already existing
connection!)\n"),
+ i, randomPeer);
#endif
- randomPeer = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK,
number_of_daemons);
- }
+ randomPeer =
+ GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK,
+ number_of_daemons);
+ }
#if VERBOSE
- fprintf (stderr, _("connecting node (rewire) %u to %u\n"), i,
randomPeer);
+ fprintf (stderr, _("connecting node (rewire) %u to %u\n"), i,
+ randomPeer);
#endif
- smallWorldConnections += addNodeRefs(list_as_array[i],
list_as_array[randomPeer]);
- }
- else
- {
- nodeToConnect = i + j + 1;
- if (nodeToConnect > number_of_daemons - 1)
- {
- nodeToConnect = nodeToConnect - number_of_daemons;
- }
+ smallWorldConnections +=
+ addNodeRefs (list_as_array[i], list_as_array[randomPeer]);
+ }
+ else
+ {
+ nodeToConnect = i + j + 1;
+ if (nodeToConnect > number_of_daemons - 1)
+ {
+ nodeToConnect = nodeToConnect - number_of_daemons;
+ }
#if VERBOSE
- fprintf (stderr, _("connecting node %u to %u\n"), i, nodeToConnect);
+ fprintf (stderr, _("connecting node %u to %u\n"), i,
+ nodeToConnect);
#endif
- totalConnections += addNodeRefs(list_as_array[i],
list_as_array[nodeToConnect]);
- }
+ totalConnections +=
+ addNodeRefs (list_as_array[i], list_as_array[nodeToConnect]);
+ }
+ }
+
}
- }
-
totalConnections += smallWorldConnections;
#if VERBOSE
fprintf (stderr, _("Total connections added for small world: %d!\n"),
smallWorldConnections);
- fprintf (stderr, _("Total connections: %d!\n"),
- totalConnections);
+ fprintf (stderr, _("Total connections: %d!\n"), totalConnections);
#endif
return GNUNET_OK;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r8850 - GNUnet/src/applications/testing,
gnunet <=