diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-07-05 07:57:40 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-07-05 07:57:40 +0000 |
commit | 60327189b5bcededb1c800415c1972d66d81366f (patch) | |
tree | 09b696fd0421a052cd388d88c42d7daac3f0b75d /src/namestore | |
parent | 0d80a601f7f0ff273fc1743f3914b6251e8c916d (diff) | |
download | gnunet-60327189b5bcededb1c800415c1972d66d81366f.tar.gz gnunet-60327189b5bcededb1c800415c1972d66d81366f.zip |
LRN: More logging for namespace comparison:
Changes GNUNET_NAMESTORE_records_cmp from a simple if statement to a
chain of if statements, each of which will log the reason comparison
failed before returning FALSE, making it obvious why comparison failed.
Diffstat (limited to 'src/namestore')
-rw-r--r-- | src/namestore/namestore_common.c | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/src/namestore/namestore_common.c b/src/namestore/namestore_common.c index eead6e492..d67628767 100644 --- a/src/namestore/namestore_common.c +++ b/src/namestore/namestore_common.c | |||
@@ -170,14 +170,44 @@ int | |||
170 | GNUNET_NAMESTORE_records_cmp (const struct GNUNET_NAMESTORE_RecordData *a, | 170 | GNUNET_NAMESTORE_records_cmp (const struct GNUNET_NAMESTORE_RecordData *a, |
171 | const struct GNUNET_NAMESTORE_RecordData *b) | 171 | const struct GNUNET_NAMESTORE_RecordData *b) |
172 | { | 172 | { |
173 | if ((a->record_type == b->record_type) && | 173 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
174 | (a->expiration_time == b->expiration_time) && | 174 | "Comparing records\n"); |
175 | ((a->flags & GNUNET_NAMESTORE_RF_RCMP_FLAGS) | 175 | if (a->record_type != b->record_type) |
176 | == (b->flags & GNUNET_NAMESTORE_RF_RCMP_FLAGS) ) && | 176 | { |
177 | (a->data_size == b->data_size) && | 177 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
178 | (0 == memcmp (a->data, b->data, a->data_size))) | 178 | "Record type %lu != %lu\n", a->record_type, b->record_type); |
179 | return GNUNET_YES; | 179 | return GNUNET_NO; |
180 | return GNUNET_NO; | 180 | } |
181 | if (a->expiration_time != b->expiration_time) | ||
182 | { | ||
183 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
184 | "Expiration time %llu != %llu\n", a->expiration_time, b->expiration_time); | ||
185 | return GNUNET_NO; | ||
186 | } | ||
187 | if ((a->flags & GNUNET_NAMESTORE_RF_RCMP_FLAGS) | ||
188 | != (b->flags & GNUNET_NAMESTORE_RF_RCMP_FLAGS)) | ||
189 | { | ||
190 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
191 | "Flags %lu (%lu) != %lu (%lu)\n", a->flags, | ||
192 | a->flags & GNUNET_NAMESTORE_RF_RCMP_FLAGS, b->flags, | ||
193 | b->flags & GNUNET_NAMESTORE_RF_RCMP_FLAGS); | ||
194 | return GNUNET_NO; | ||
195 | } | ||
196 | if (a->data_size != b->data_size) | ||
197 | { | ||
198 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
199 | "Data size %lu != %lu\n", a->data_size, b->data_size); | ||
200 | return GNUNET_NO; | ||
201 | } | ||
202 | if (0 != memcmp (a->data, b->data, a->data_size)) | ||
203 | { | ||
204 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
205 | "Data contents do not match\n"); | ||
206 | return GNUNET_NO; | ||
207 | } | ||
208 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
209 | "Records are equal\n"); | ||
210 | return GNUNET_YES; | ||
181 | } | 211 | } |
182 | 212 | ||
183 | 213 | ||