[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r35745 - gnunet/src/rps
From: |
gnunet |
Subject: |
[GNUnet-SVN] r35745 - gnunet/src/rps |
Date: |
Wed, 20 May 2015 00:41:15 +0200 |
Author: ch3
Date: 2015-05-20 00:41:15 +0200 (Wed, 20 May 2015)
New Revision: 35745
Modified:
gnunet/src/rps/gnunet-service-rps_sampler.c
Log:
-cont write internals to file
Modified: gnunet/src/rps/gnunet-service-rps_sampler.c
===================================================================
--- gnunet/src/rps/gnunet-service-rps_sampler.c 2015-05-19 22:41:12 UTC (rev
35744)
+++ gnunet/src/rps/gnunet-service-rps_sampler.c 2015-05-19 22:41:15 UTC (rev
35745)
@@ -102,6 +102,13 @@
* How many times this sampler changed the peer_id.
*/
uint32_t num_change;
+
+ /**
+ * The file name this sampler element should log to
+ */
+ #ifdef TO_FILE
+ char *file_name;
+ #endif /* TO_FILE */
};
@@ -362,6 +369,42 @@
&(sampler_el->auth_key.key),
GNUNET_CRYPTO_HASH_LENGTH);
+ #ifdef TO_FILE
+ /* Create a file(-name) to store internals to */
+ int size;
+ char *end;
+ char *buf;
+ char name_buf[512];
+ size_t keylen = (sizeof (struct GNUNET_CRYPTO_AuthKey)) * 8;
+
+ if (keylen % 5 > 0)
+ keylen += 5 - keylen % 5;
+ keylen /= 5;
+ buf = GNUNET_malloc (keylen + 1);
+
+ end = GNUNET_STRINGS_data_to_string (&(sampler_el->auth_key.key),
+ sizeof (struct GNUNET_CRYPTO_AuthKey),
+ buf,
+ keylen);
+
+ if (NULL == end)
+ {
+ GNUNET_free (buf);
+ GNUNET_break (0);
+ }
+ else
+ {
+ *end = '\0';
+ }
+
+ size = GNUNET_snprintf (name_buf, sizeof (name_buf), "sampler_el-%s-", buf);
+ if (0 > size)
+ LOG (GNUNET_ERROR_TYPE_WARNING, "Failed to create name_buf\n");
+
+ if (NULL == (sampler_el->file_name = GNUNET_DISK_mktemp (name_buf)))
+ LOG (GNUNET_ERROR_TYPE_WARNING, "Could not create file\n");
+ #endif /* TO_FILE */
+
sampler_el->last_client_request = GNUNET_TIME_UNIT_FOREVER_ABS;
sampler_el->birth = GNUNET_TIME_absolute_get ();
@@ -406,6 +449,12 @@
s_elem->num_peers++;
+ #ifdef TO_FILE
+ to_file (s_elem->file_name,
+ "Got id %s",
+ GNUNET_i2s_full (other));
+ #endif /* TO_FILE */
+
if (0 == GNUNET_CRYPTO_cmp_peer_identity (other, &(s_elem->peer_id)))
{
LOG (GNUNET_ERROR_TYPE_DEBUG, " Got PeerID %s\n",
@@ -450,6 +499,11 @@
}
}
s_elem->is_empty = NOT_EMPTY;
+ #ifdef TO_FILE
+ to_file (s_elem->file_name,
+ "Now holding %s",
+ GNUNET_i2s_full (&s_elem->peer_id));
+ #endif /* TO_FILE */
}
@@ -492,9 +546,17 @@
new_size);
#ifdef TO_FILE
to_file (sampler->file_name,
- "Shrinking sampler %d -> %d\n",
+ "Shrinking sampler %d -> %d",
old_size,
new_size);
+
+ for (i = new_size ; i < old_size ; i++)
+ {
+ to_file (sampler->file_name,
+ "-%" PRIu32 ": %s",
+ i,
+ sampler->sampler_elements[i]->file_name);
+ }
#endif /* TO_FILE */
GNUNET_array_grow (sampler->sampler_elements,
sampler->sampler_size,
@@ -512,7 +574,7 @@
new_size);
#ifdef TO_FILE
to_file (sampler->file_name,
- "Growing sampler %d -> %d\n",
+ "Growing sampler %d -> %d",
old_size,
new_size);
#endif /* TO_FILE */
@@ -525,10 +587,9 @@
sampler->sampler_elements[i] = RPS_sampler_elem_create ();
#ifdef TO_FILE
to_file (sampler->file_name,
- "%" PRIu32 ": Initialised empty sampler element\n",
- i);
- //"New sampler with key %s\n",
- //GNUNET_h2s_full (sampler->sampler_elements[i]->auth_key));
+ "+%" PRIu32 ": %s",
+ i,
+ sampler->sampler_elements[i]->file_name);
#endif /* TO_FILE */
}
}
@@ -626,17 +687,17 @@
{
uint32_t i;
+ #ifdef TO_FILE
+ to_file (sampler->file_name,
+ "Got %s",
+ GNUNET_i2s_full (id));
+ #endif /* TO_FILE */
+
for (i = 0 ; i < sampler->sampler_size ; i++)
{
RPS_sampler_elem_next (sampler->sampler_elements[i],
sampler,
id);
- #ifdef TO_FILE
- to_file (sampler->file_name,
- "%" PRIu32 ": Now contains %s\n",
- i,
- GNUNET_i2s_full (&sampler->sampler_elements[i]->peer_id));
- #endif /* TO_FILE */
}
}
@@ -849,8 +910,19 @@
if (GNUNET_NO == for_client)
{
to_file (sampler->file_name,
- "This sampler is probably for Brahms itself\n");
+ "This sampler is probably for Brahms itself");
}
+ else if (GNUNET_YES == for_client)
+ {
+ to_file (sampler->file_name,
+ "This sampler is probably for the client");
+ }
+ else
+ {
+ to_file (sampler->file_name,
+ "This shouldn't happen: for_client is %i",
+ for_client);
+ }
#endif /* TO_FILE */
LOG (GNUNET_ERROR_TYPE_DEBUG,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r35745 - gnunet/src/rps,
gnunet <=