diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-10-25 10:36:17 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-10-25 10:36:17 +0000 |
commit | 2959827fcacd160a0e9624d868f419e1530daee3 (patch) | |
tree | cfcc31ee280e6f0dcaad138bd15f2c5ce0ae2b12 /src/namestore | |
parent | 8828320c6ad8daea272d5c03915ce7b6c4957aa3 (diff) | |
download | gnunet-2959827fcacd160a0e9624d868f419e1530daee3.tar.gz gnunet-2959827fcacd160a0e9624d868f419e1530daee3.zip |
-fixing testcase cleanup on error
Diffstat (limited to 'src/namestore')
-rw-r--r-- | src/namestore/test_namestore_api.c | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/src/namestore/test_namestore_api.c b/src/namestore/test_namestore_api.c index 23c87d4f0..52887fc81 100644 --- a/src/namestore/test_namestore_api.c +++ b/src/namestore/test_namestore_api.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2009 Christian Grothoff (and other contributing authors) | 3 | (C) 2012 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -47,6 +47,7 @@ static struct GNUNET_CRYPTO_ShortHashCode zone; | |||
47 | 47 | ||
48 | static int res; | 48 | static int res; |
49 | 49 | ||
50 | static struct GNUNET_NAMESTORE_QueueEntry *nsqe; | ||
50 | 51 | ||
51 | /** | 52 | /** |
52 | * Re-establish the connection to the service. | 53 | * Re-establish the connection to the service. |
@@ -57,13 +58,21 @@ static int res; | |||
57 | static void | 58 | static void |
58 | endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 59 | endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
59 | { | 60 | { |
61 | if (NULL != nsqe) | ||
62 | { | ||
63 | GNUNET_NAMESTORE_cancel (nsqe); | ||
64 | nsqe = NULL; | ||
65 | } | ||
60 | if (nsh != NULL) | 66 | if (nsh != NULL) |
67 | { | ||
61 | GNUNET_NAMESTORE_disconnect (nsh); | 68 | GNUNET_NAMESTORE_disconnect (nsh); |
62 | nsh = NULL; | 69 | nsh = NULL; |
63 | 70 | } | |
64 | if (privkey != NULL) | 71 | if (privkey != NULL) |
72 | { | ||
65 | GNUNET_CRYPTO_rsa_key_free (privkey); | 73 | GNUNET_CRYPTO_rsa_key_free (privkey); |
66 | privkey = NULL; | 74 | privkey = NULL; |
75 | } | ||
67 | GNUNET_SCHEDULER_shutdown (); | 76 | GNUNET_SCHEDULER_shutdown (); |
68 | res = 1; | 77 | res = 1; |
69 | } | 78 | } |
@@ -77,11 +86,11 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
77 | GNUNET_SCHEDULER_cancel (endbadly_task); | 86 | GNUNET_SCHEDULER_cancel (endbadly_task); |
78 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; | 87 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; |
79 | } | 88 | } |
80 | |||
81 | if (privkey != NULL) | 89 | if (privkey != NULL) |
90 | { | ||
82 | GNUNET_CRYPTO_rsa_key_free (privkey); | 91 | GNUNET_CRYPTO_rsa_key_free (privkey); |
83 | privkey = NULL; | 92 | privkey = NULL; |
84 | 93 | } | |
85 | if (nsh != NULL) | 94 | if (nsh != NULL) |
86 | { | 95 | { |
87 | GNUNET_NAMESTORE_disconnect (nsh); | 96 | GNUNET_NAMESTORE_disconnect (nsh); |
@@ -100,6 +109,7 @@ name_lookup_proc (void *cls, | |||
100 | const struct GNUNET_NAMESTORE_RecordData *rd, | 109 | const struct GNUNET_NAMESTORE_RecordData *rd, |
101 | const struct GNUNET_CRYPTO_RsaSignature *signature) | 110 | const struct GNUNET_CRYPTO_RsaSignature *signature) |
102 | { | 111 | { |
112 | nsqe = NULL; | ||
103 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 113 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
104 | "Namestore lookup result %p `%s' %i %p %p\n", | 114 | "Namestore lookup result %p `%s' %i %p %p\n", |
105 | zone_key, name, rd_count, rd, signature); | 115 | zone_key, name, rd_count, rd, signature); |
@@ -116,7 +126,7 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
116 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 126 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
117 | "Name store added record for `%s': %s\n", name, (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); | 127 | "Name store added record for `%s': %s\n", name, (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); |
118 | 128 | ||
119 | GNUNET_NAMESTORE_lookup_record (nsh, &zone, name, 0, &name_lookup_proc, NULL); | 129 | nsqe = GNUNET_NAMESTORE_lookup_record (nsh, &zone, name, 0, &name_lookup_proc, NULL); |
120 | } | 130 | } |
121 | 131 | ||
122 | 132 | ||
@@ -130,8 +140,8 @@ run (void *cls, | |||
130 | char *hostkey_file; | 140 | char *hostkey_file; |
131 | const char * name = "dummy.dummy.gnunet"; | 141 | const char * name = "dummy.dummy.gnunet"; |
132 | 142 | ||
133 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL); | 143 | endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
134 | 144 | &endbadly, NULL); | |
135 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, | 145 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, |
136 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); | 146 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); |
137 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); | 147 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); |
@@ -148,9 +158,9 @@ run (void *cls, | |||
148 | memset ((char *) rd.data, 'a', TEST_RECORD_DATALEN); | 158 | memset ((char *) rd.data, 'a', TEST_RECORD_DATALEN); |
149 | nsh = GNUNET_NAMESTORE_connect (cfg); | 159 | nsh = GNUNET_NAMESTORE_connect (cfg); |
150 | GNUNET_break (NULL != nsh); | 160 | GNUNET_break (NULL != nsh); |
151 | GNUNET_NAMESTORE_record_put (nsh, &pubkey, name, | 161 | nseq = GNUNET_NAMESTORE_record_put (nsh, &pubkey, name, |
152 | GNUNET_TIME_UNIT_FOREVER_ABS, | 162 | GNUNET_TIME_UNIT_FOREVER_ABS, |
153 | 1, &rd, &signature, &put_cont, (void*) name); | 163 | 1, &rd, &signature, &put_cont, (void*) name); |
154 | GNUNET_free ((void *)rd.data); | 164 | GNUNET_free ((void *)rd.data); |
155 | } | 165 | } |
156 | 166 | ||