diff options
Diffstat (limited to 'src/messenger')
-rw-r--r-- | src/messenger/Makefile.am | 39 | ||||
-rwxr-xr-x[-rw-r--r--] | src/messenger/gnunet-messenger.c | 14 | ||||
-rwxr-xr-x[-rw-r--r--] | src/messenger/gnunet-service-messenger.c | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | src/messenger/gnunet-service-messenger_member.c | 10 | ||||
-rwxr-xr-x[-rw-r--r--] | src/messenger/gnunet-service-messenger_message_store.c | 10 | ||||
-rwxr-xr-x[-rw-r--r--] | src/messenger/gnunet-service-messenger_operation_store.c | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | src/messenger/messenger_api_contact_store.c | 9 | ||||
-rwxr-xr-x[-rw-r--r--] | src/messenger/messenger_api_message.c | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | src/messenger/messenger_api_room.c | 16 | ||||
-rwxr-xr-x[-rw-r--r--] | src/messenger/messenger_api_room.h | 6 |
10 files changed, 53 insertions, 61 deletions
diff --git a/src/messenger/Makefile.am b/src/messenger/Makefile.am index 1ebfbe5ed..2bb9ad922 100644 --- a/src/messenger/Makefile.am +++ b/src/messenger/Makefile.am | |||
@@ -25,35 +25,23 @@ bin_PROGRAMS = \ | |||
25 | gnunet-messenger | 25 | gnunet-messenger |
26 | 26 | ||
27 | lib_LTLIBRARIES = \ | 27 | lib_LTLIBRARIES = \ |
28 | libgnunetmessenger_common.la \ | ||
29 | libgnunetmessenger.la \ | 28 | libgnunetmessenger.la \ |
30 | $(EXP_LIB) | 29 | $(EXP_LIB) |
31 | 30 | ||
32 | libgnunetmessenger_common_la_SOURCES = \ | 31 | libgnunetmessenger_la_SOURCES = \ |
32 | messenger_api.c \ | ||
33 | messenger_api_ego.h \ | 33 | messenger_api_ego.h \ |
34 | messenger_api_contact.c messenger_api_contact.h \ | 34 | messenger_api_contact.c messenger_api_contact.h \ |
35 | messenger_api_contact_store.c messenger_api_contact_store.h \ | 35 | messenger_api_contact_store.c messenger_api_contact_store.h \ |
36 | messenger_api_message.c messenger_api_message.h \ | 36 | messenger_api_message.c messenger_api_message.h \ |
37 | messenger_api_list_tunnels.c messenger_api_list_tunnels.h \ | 37 | messenger_api_list_tunnels.c messenger_api_list_tunnels.h \ |
38 | messenger_api_util.c messenger_api_util.h | 38 | messenger_api_util.c messenger_api_util.h \ |
39 | libgnunetmessenger_common_la_LIBADD = \ | ||
40 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
41 | $(top_builddir)/src/cadet/libgnunetcadet.la \ | ||
42 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
43 | $(XLIB) \ | ||
44 | $(LTLIBINTL) | ||
45 | libgnunetmessenger_common_la_LDFLAGS = \ | ||
46 | $(GN_LIB_LDFLAGS) \ | ||
47 | -version-info 0:0:0 | ||
48 | |||
49 | libgnunetmessenger_la_SOURCES = \ | ||
50 | messenger_api.c \ | ||
51 | messenger_api_handle.c messenger_api_handle.h \ | 39 | messenger_api_handle.c messenger_api_handle.h \ |
52 | messenger_api_room.c messenger_api_room.h | 40 | messenger_api_room.c messenger_api_room.h |
53 | libgnunetmessenger_la_LIBADD = \ | 41 | libgnunetmessenger_la_LIBADD = \ |
54 | $(top_builddir)/src/util/libgnunetutil.la \ | 42 | $(top_builddir)/src/util/libgnunetutil.la \ |
43 | $(top_builddir)/src/cadet/libgnunetcadet.la \ | ||
55 | $(top_builddir)/src/identity/libgnunetidentity.la \ | 44 | $(top_builddir)/src/identity/libgnunetidentity.la \ |
56 | libgnunetmessenger_common.la \ | ||
57 | $(XLIB) \ | 45 | $(XLIB) \ |
58 | $(LTLIBINTL) | 46 | $(LTLIBINTL) |
59 | libgnunetmessenger_la_LDFLAGS = \ | 47 | libgnunetmessenger_la_LDFLAGS = \ |
@@ -63,10 +51,8 @@ libgnunetmessenger_la_LDFLAGS = \ | |||
63 | gnunet_messenger_SOURCES = \ | 51 | gnunet_messenger_SOURCES = \ |
64 | gnunet-messenger.c | 52 | gnunet-messenger.c |
65 | gnunet_messenger_LDADD = \ | 53 | gnunet_messenger_LDADD = \ |
66 | libgnunetmessenger_common.la \ | ||
67 | libgnunetmessenger.la \ | 54 | libgnunetmessenger.la \ |
68 | $(top_builddir)/src/util/libgnunetutil.la \ | 55 | $(top_builddir)/src/util/libgnunetutil.la |
69 | $(top_builddir)/src/identity/libgnunetidentity.la | ||
70 | gnunet_messenger_LDFLAGS = \ | 56 | gnunet_messenger_LDFLAGS = \ |
71 | $(GN_LIBINTL) | 57 | $(GN_LIBINTL) |
72 | 58 | ||
@@ -91,11 +77,10 @@ gnunet_service_messenger_SOURCES = \ | |||
91 | gnunet-service-messenger_room.c gnunet-service-messenger_room.h \ | 77 | gnunet-service-messenger_room.c gnunet-service-messenger_room.h \ |
92 | gnunet-service-messenger_tunnel.c gnunet-service-messenger_tunnel.h | 78 | gnunet-service-messenger_tunnel.c gnunet-service-messenger_tunnel.h |
93 | gnunet_service_messenger_LDADD = \ | 79 | gnunet_service_messenger_LDADD = \ |
80 | libgnunetmessenger.la \ | ||
94 | $(top_builddir)/src/util/libgnunetutil.la \ | 81 | $(top_builddir)/src/util/libgnunetutil.la \ |
95 | $(top_builddir)/src/cadet/libgnunetcadet.la \ | 82 | $(top_builddir)/src/cadet/libgnunetcadet.la \ |
96 | $(top_builddir)/src/identity/libgnunetidentity.la \ | 83 | $(top_builddir)/src/identity/libgnunetidentity.la \ |
97 | libgnunetmessenger_common.la \ | ||
98 | libgnunetmessenger.la \ | ||
99 | $(GN_LIBINTL) | 84 | $(GN_LIBINTL) |
100 | 85 | ||
101 | check_PROGRAMS = \ | 86 | check_PROGRAMS = \ |
@@ -121,7 +106,6 @@ endif | |||
121 | test_messenger_api_SOURCES = \ | 106 | test_messenger_api_SOURCES = \ |
122 | test_messenger.c | 107 | test_messenger.c |
123 | test_messenger_api_LDADD = \ | 108 | test_messenger_api_LDADD = \ |
124 | libgnunetmessenger_common.la \ | ||
125 | libgnunetmessenger.la \ | 109 | libgnunetmessenger.la \ |
126 | $(top_builddir)/src/testing/libgnunettesting.la \ | 110 | $(top_builddir)/src/testing/libgnunettesting.la \ |
127 | $(top_builddir)/src/util/libgnunetutil.la | 111 | $(top_builddir)/src/util/libgnunetutil.la |
@@ -129,7 +113,6 @@ test_messenger_api_LDADD = \ | |||
129 | test_messenger_anonymous_SOURCES = \ | 113 | test_messenger_anonymous_SOURCES = \ |
130 | test_messenger_anonymous.c | 114 | test_messenger_anonymous.c |
131 | test_messenger_anonymous_LDADD = \ | 115 | test_messenger_anonymous_LDADD = \ |
132 | libgnunetmessenger_common.la \ | ||
133 | libgnunetmessenger.la \ | 116 | libgnunetmessenger.la \ |
134 | $(top_builddir)/src/testing/libgnunettesting.la \ | 117 | $(top_builddir)/src/testing/libgnunettesting.la \ |
135 | $(top_builddir)/src/util/libgnunetutil.la | 118 | $(top_builddir)/src/util/libgnunetutil.la |
@@ -139,7 +122,6 @@ test_messenger_sync_client_SOURCES = \ | |||
139 | testing_messenger_barrier.c testing_messenger_barrier.h \ | 122 | testing_messenger_barrier.c testing_messenger_barrier.h \ |
140 | testing_messenger_setup.c testing_messenger_setup.h | 123 | testing_messenger_setup.c testing_messenger_setup.h |
141 | test_messenger_sync_client_LDADD = \ | 124 | test_messenger_sync_client_LDADD = \ |
142 | libgnunetmessenger_common.la \ | ||
143 | libgnunetmessenger.la \ | 125 | libgnunetmessenger.la \ |
144 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | 126 | $(top_builddir)/src/testbed/libgnunettestbed.la \ |
145 | $(top_builddir)/src/testing/libgnunettesting.la \ | 127 | $(top_builddir)/src/testing/libgnunettesting.la \ |
@@ -150,7 +132,6 @@ test_messenger_async_client_SOURCES = \ | |||
150 | testing_messenger_barrier.c testing_messenger_barrier.h \ | 132 | testing_messenger_barrier.c testing_messenger_barrier.h \ |
151 | testing_messenger_setup.c testing_messenger_setup.h | 133 | testing_messenger_setup.c testing_messenger_setup.h |
152 | test_messenger_async_client_LDADD = \ | 134 | test_messenger_async_client_LDADD = \ |
153 | libgnunetmessenger_common.la \ | ||
154 | libgnunetmessenger.la \ | 135 | libgnunetmessenger.la \ |
155 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | 136 | $(top_builddir)/src/testbed/libgnunettestbed.la \ |
156 | $(top_builddir)/src/testing/libgnunettesting.la \ | 137 | $(top_builddir)/src/testing/libgnunettesting.la \ |
@@ -161,7 +142,6 @@ test_messenger_worst_client_SOURCES = \ | |||
161 | testing_messenger_barrier.c testing_messenger_barrier.h \ | 142 | testing_messenger_barrier.c testing_messenger_barrier.h \ |
162 | testing_messenger_setup.c testing_messenger_setup.h | 143 | testing_messenger_setup.c testing_messenger_setup.h |
163 | test_messenger_worst_client_LDADD = \ | 144 | test_messenger_worst_client_LDADD = \ |
164 | libgnunetmessenger_common.la \ | ||
165 | libgnunetmessenger.la \ | 145 | libgnunetmessenger.la \ |
166 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | 146 | $(top_builddir)/src/testbed/libgnunettestbed.la \ |
167 | $(top_builddir)/src/testing/libgnunettesting.la \ | 147 | $(top_builddir)/src/testing/libgnunettesting.la \ |
@@ -172,7 +152,6 @@ test_messenger_sync_p2p_SOURCES = \ | |||
172 | testing_messenger_barrier.c testing_messenger_barrier.h \ | 152 | testing_messenger_barrier.c testing_messenger_barrier.h \ |
173 | testing_messenger_setup.c testing_messenger_setup.h | 153 | testing_messenger_setup.c testing_messenger_setup.h |
174 | test_messenger_sync_p2p_LDADD = \ | 154 | test_messenger_sync_p2p_LDADD = \ |
175 | libgnunetmessenger_common.la \ | ||
176 | libgnunetmessenger.la \ | 155 | libgnunetmessenger.la \ |
177 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | 156 | $(top_builddir)/src/testbed/libgnunettestbed.la \ |
178 | $(top_builddir)/src/testing/libgnunettesting.la \ | 157 | $(top_builddir)/src/testing/libgnunettesting.la \ |
@@ -183,7 +162,6 @@ test_messenger_async_p2p_SOURCES = \ | |||
183 | testing_messenger_barrier.c testing_messenger_barrier.h \ | 162 | testing_messenger_barrier.c testing_messenger_barrier.h \ |
184 | testing_messenger_setup.c testing_messenger_setup.h | 163 | testing_messenger_setup.c testing_messenger_setup.h |
185 | test_messenger_async_p2p_LDADD = \ | 164 | test_messenger_async_p2p_LDADD = \ |
186 | libgnunetmessenger_common.la \ | ||
187 | libgnunetmessenger.la \ | 165 | libgnunetmessenger.la \ |
188 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | 166 | $(top_builddir)/src/testbed/libgnunettestbed.la \ |
189 | $(top_builddir)/src/testing/libgnunettesting.la \ | 167 | $(top_builddir)/src/testing/libgnunettesting.la \ |
@@ -194,7 +172,6 @@ test_messenger_worst_p2p_SOURCES = \ | |||
194 | testing_messenger_barrier.c testing_messenger_barrier.h \ | 172 | testing_messenger_barrier.c testing_messenger_barrier.h \ |
195 | testing_messenger_setup.c testing_messenger_setup.h | 173 | testing_messenger_setup.c testing_messenger_setup.h |
196 | test_messenger_worst_p2p_LDADD = \ | 174 | test_messenger_worst_p2p_LDADD = \ |
197 | libgnunetmessenger_common.la \ | ||
198 | libgnunetmessenger.la \ | 175 | libgnunetmessenger.la \ |
199 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | 176 | $(top_builddir)/src/testbed/libgnunettestbed.la \ |
200 | $(top_builddir)/src/testing/libgnunettesting.la \ | 177 | $(top_builddir)/src/testing/libgnunettesting.la \ |
@@ -205,7 +182,6 @@ test_messenger_server_SOURCES = \ | |||
205 | testing_messenger_barrier.c testing_messenger_barrier.h \ | 182 | testing_messenger_barrier.c testing_messenger_barrier.h \ |
206 | testing_messenger_setup.c testing_messenger_setup.h | 183 | testing_messenger_setup.c testing_messenger_setup.h |
207 | test_messenger_server_LDADD = \ | 184 | test_messenger_server_LDADD = \ |
208 | libgnunetmessenger_common.la \ | ||
209 | libgnunetmessenger.la \ | 185 | libgnunetmessenger.la \ |
210 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | 186 | $(top_builddir)/src/testbed/libgnunettestbed.la \ |
211 | $(top_builddir)/src/testing/libgnunettesting.la \ | 187 | $(top_builddir)/src/testing/libgnunettesting.la \ |
@@ -216,7 +192,6 @@ test_messenger_growth_SOURCES = \ | |||
216 | testing_messenger_barrier.c testing_messenger_barrier.h \ | 192 | testing_messenger_barrier.c testing_messenger_barrier.h \ |
217 | testing_messenger_setup.c testing_messenger_setup.h | 193 | testing_messenger_setup.c testing_messenger_setup.h |
218 | test_messenger_growth_LDADD = \ | 194 | test_messenger_growth_LDADD = \ |
219 | libgnunetmessenger_common.la \ | ||
220 | libgnunetmessenger.la \ | 195 | libgnunetmessenger.la \ |
221 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | 196 | $(top_builddir)/src/testbed/libgnunettestbed.la \ |
222 | $(top_builddir)/src/testing/libgnunettesting.la \ | 197 | $(top_builddir)/src/testing/libgnunettesting.la \ |
@@ -227,7 +202,6 @@ test_messenger_ring_SOURCES = \ | |||
227 | testing_messenger_barrier.c testing_messenger_barrier.h \ | 202 | testing_messenger_barrier.c testing_messenger_barrier.h \ |
228 | testing_messenger_setup.c testing_messenger_setup.h | 203 | testing_messenger_setup.c testing_messenger_setup.h |
229 | test_messenger_ring_LDADD = \ | 204 | test_messenger_ring_LDADD = \ |
230 | libgnunetmessenger_common.la \ | ||
231 | libgnunetmessenger.la \ | 205 | libgnunetmessenger.la \ |
232 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | 206 | $(top_builddir)/src/testbed/libgnunettestbed.la \ |
233 | $(top_builddir)/src/testing/libgnunettesting.la \ | 207 | $(top_builddir)/src/testing/libgnunettesting.la \ |
@@ -238,7 +212,6 @@ test_messenger_adapt_SOURCES = \ | |||
238 | testing_messenger_barrier.c testing_messenger_barrier.h \ | 212 | testing_messenger_barrier.c testing_messenger_barrier.h \ |
239 | testing_messenger_setup.c testing_messenger_setup.h | 213 | testing_messenger_setup.c testing_messenger_setup.h |
240 | test_messenger_adapt_LDADD = \ | 214 | test_messenger_adapt_LDADD = \ |
241 | libgnunetmessenger_common.la \ | ||
242 | libgnunetmessenger.la \ | 215 | libgnunetmessenger.la \ |
243 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | 216 | $(top_builddir)/src/testbed/libgnunettestbed.la \ |
244 | $(top_builddir)/src/testing/libgnunettesting.la \ | 217 | $(top_builddir)/src/testing/libgnunettesting.la \ |
diff --git a/src/messenger/gnunet-messenger.c b/src/messenger/gnunet-messenger.c index 737bb83c8..094ae398d 100644..100755 --- a/src/messenger/gnunet-messenger.c +++ b/src/messenger/gnunet-messenger.c | |||
@@ -229,18 +229,12 @@ on_identity (void *cls, struct GNUNET_MESSENGER_Handle *handle) | |||
229 | if (room_key) | 229 | if (room_key) |
230 | GNUNET_CRYPTO_hash (room_key, strlen (room_key), &key); | 230 | GNUNET_CRYPTO_hash (room_key, strlen (room_key), &key); |
231 | 231 | ||
232 | struct GNUNET_PeerIdentity door_peer; | ||
232 | struct GNUNET_PeerIdentity *door = NULL; | 233 | struct GNUNET_PeerIdentity *door = NULL; |
233 | 234 | ||
234 | if (door_id) | 235 | if ((door_id) && |
235 | { | 236 | (GNUNET_OK == GNUNET_CRYPTO_eddsa_public_key_from_string (door_id, strlen (door_id), &(door_peer.public_key)))) |
236 | door = GNUNET_new(struct GNUNET_PeerIdentity); | 237 | door = &door_peer; |
237 | |||
238 | if (GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string (door_id, strlen (door_id), &(door->public_key))) | ||
239 | { | ||
240 | GNUNET_free(door); | ||
241 | door = NULL; | ||
242 | } | ||
243 | } | ||
244 | 238 | ||
245 | const char *name = GNUNET_MESSENGER_get_name (handle); | 239 | const char *name = GNUNET_MESSENGER_get_name (handle); |
246 | 240 | ||
diff --git a/src/messenger/gnunet-service-messenger.c b/src/messenger/gnunet-service-messenger.c index 187b65ed5..76fb31d95 100644..100755 --- a/src/messenger/gnunet-service-messenger.c +++ b/src/messenger/gnunet-service-messenger.c | |||
@@ -191,7 +191,7 @@ check_send_message (void *cls, const struct GNUNET_MESSENGER_SendMessage *msg) | |||
191 | const uint16_t length = full_length - sizeof(*msg); | 191 | const uint16_t length = full_length - sizeof(*msg); |
192 | const char *buffer = ((const char*) msg) + sizeof(*msg); | 192 | const char *buffer = ((const char*) msg) + sizeof(*msg); |
193 | 193 | ||
194 | uint16_t key_length = 0; | 194 | ssize_t key_length = 0; |
195 | 195 | ||
196 | if (!(flags & GNUNET_MESSENGER_FLAG_PRIVATE)) | 196 | if (!(flags & GNUNET_MESSENGER_FLAG_PRIVATE)) |
197 | goto check_for_message; | 197 | goto check_for_message; |
@@ -231,7 +231,7 @@ handle_send_message (void *cls, const struct GNUNET_MESSENGER_SendMessage *msg) | |||
231 | const char *buffer = ((const char*) msg) + sizeof(*msg); | 231 | const char *buffer = ((const char*) msg) + sizeof(*msg); |
232 | 232 | ||
233 | const uint16_t length = ntohs (msg->header.size) - sizeof(*msg); | 233 | const uint16_t length = ntohs (msg->header.size) - sizeof(*msg); |
234 | uint16_t key_length = 0; | 234 | ssize_t key_length = 0; |
235 | 235 | ||
236 | struct GNUNET_IDENTITY_PublicKey public_key; | 236 | struct GNUNET_IDENTITY_PublicKey public_key; |
237 | 237 | ||
diff --git a/src/messenger/gnunet-service-messenger_member.c b/src/messenger/gnunet-service-messenger_member.c index 6e39cec13..7f00e8438 100644..100755 --- a/src/messenger/gnunet-service-messenger_member.c +++ b/src/messenger/gnunet-service-messenger_member.c | |||
@@ -335,7 +335,11 @@ add_member_session (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSEN | |||
335 | struct GNUNET_HashCode hash; | 335 | struct GNUNET_HashCode hash; |
336 | GNUNET_CRYPTO_hash(public_key, sizeof(*public_key), &hash); | 336 | GNUNET_CRYPTO_hash(public_key, sizeof(*public_key), &hash); |
337 | 337 | ||
338 | GNUNET_CONTAINER_multihashmap_put(member->sessions, &hash, session, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 338 | if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put( |
339 | member->sessions, &hash, session, | ||
340 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) | ||
341 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Adding a member session failed: %s\n", | ||
342 | GNUNET_h2s(&hash)); | ||
339 | } | 343 | } |
340 | 344 | ||
341 | void | 345 | void |
@@ -348,7 +352,9 @@ remove_member_session (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MES | |||
348 | struct GNUNET_HashCode hash; | 352 | struct GNUNET_HashCode hash; |
349 | GNUNET_CRYPTO_hash(public_key, sizeof(*public_key), &hash); | 353 | GNUNET_CRYPTO_hash(public_key, sizeof(*public_key), &hash); |
350 | 354 | ||
351 | GNUNET_CONTAINER_multihashmap_remove(member->sessions, &hash, session); | 355 | if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_remove(member->sessions, &hash, session)) |
356 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Removing a member session failed: %s\n", | ||
357 | GNUNET_h2s(&hash)); | ||
352 | } | 358 | } |
353 | 359 | ||
354 | struct GNUNET_MESSENGER_ClosureIterateSessions { | 360 | struct GNUNET_MESSENGER_ClosureIterateSessions { |
diff --git a/src/messenger/gnunet-service-messenger_message_store.c b/src/messenger/gnunet-service-messenger_message_store.c index 1f3d262ac..b143c6c98 100644..100755 --- a/src/messenger/gnunet-service-messenger_message_store.c +++ b/src/messenger/gnunet-service-messenger_message_store.c | |||
@@ -158,6 +158,8 @@ load_message_store_links (struct GNUNET_MESSENGER_MessageStore *store, const cha | |||
158 | struct GNUNET_MESSENGER_MessageLinkStorage storage; | 158 | struct GNUNET_MESSENGER_MessageLinkStorage storage; |
159 | struct GNUNET_MESSENGER_MessageLink *link = NULL; | 159 | struct GNUNET_MESSENGER_MessageLink *link = NULL; |
160 | 160 | ||
161 | memset(&storage, 0, sizeof(storage)); | ||
162 | |||
161 | do | 163 | do |
162 | { | 164 | { |
163 | if ((sizeof(storage.hash) != GNUNET_DISK_file_read (entries, &(storage.hash), sizeof(storage.hash))) || | 165 | if ((sizeof(storage.hash) != GNUNET_DISK_file_read (entries, &(storage.hash), sizeof(storage.hash))) || |
@@ -311,6 +313,8 @@ save_message_store (struct GNUNET_MESSENGER_MessageStore *store, const char *dir | |||
311 | save.store = store; | 313 | save.store = store; |
312 | save.storage = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, permission); | 314 | save.storage = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, permission); |
313 | 315 | ||
316 | GNUNET_free(filename); | ||
317 | |||
314 | if (!save.storage) | 318 | if (!save.storage) |
315 | goto save_entries; | 319 | goto save_entries; |
316 | 320 | ||
@@ -324,7 +328,6 @@ close_links: | |||
324 | GNUNET_DISK_file_close (save.storage); | 328 | GNUNET_DISK_file_close (save.storage); |
325 | 329 | ||
326 | save_entries: | 330 | save_entries: |
327 | GNUNET_free(filename); | ||
328 | GNUNET_asprintf (&filename, "%s%s", directory, "entries.store"); | 331 | GNUNET_asprintf (&filename, "%s%s", directory, "entries.store"); |
329 | 332 | ||
330 | save.store = store; | 333 | save.store = store; |
@@ -417,7 +420,10 @@ get_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNU | |||
417 | 420 | ||
418 | if ((GNUNET_YES != decoding) || (GNUNET_CRYPTO_hash_cmp (hash, &check) != 0)) | 421 | if ((GNUNET_YES != decoding) || (GNUNET_CRYPTO_hash_cmp (hash, &check) != 0)) |
419 | { | 422 | { |
420 | GNUNET_CONTAINER_multihashmap_remove (store->entries, hash, entry); | 423 | if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_remove (store->entries, hash, entry)) |
424 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Corrupted entry could not be removed from store: %s\n", | ||
425 | GNUNET_h2s(hash)); | ||
426 | |||
421 | store->rewrite_entries = GNUNET_YES; | 427 | store->rewrite_entries = GNUNET_YES; |
422 | 428 | ||
423 | goto free_message; | 429 | goto free_message; |
diff --git a/src/messenger/gnunet-service-messenger_operation_store.c b/src/messenger/gnunet-service-messenger_operation_store.c index 05985ef84..a32fbad2c 100644..100755 --- a/src/messenger/gnunet-service-messenger_operation_store.c +++ b/src/messenger/gnunet-service-messenger_operation_store.c | |||
@@ -184,7 +184,9 @@ cancel_store_operation (struct GNUNET_MESSENGER_OperationStore *store, | |||
184 | 184 | ||
185 | stop_operation(op); | 185 | stop_operation(op); |
186 | 186 | ||
187 | GNUNET_CONTAINER_multihashmap_remove(store->operations, hash, op); | 187 | if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_remove(store->operations, hash, op)) |
188 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Canceled operation could not be removed: %s\n", | ||
189 | GNUNET_h2s(hash)); | ||
188 | 190 | ||
189 | destroy_operation(op); | 191 | destroy_operation(op); |
190 | } | 192 | } |
diff --git a/src/messenger/messenger_api_contact_store.c b/src/messenger/messenger_api_contact_store.c index 5238b2c58..6a517c2e0 100644..100755 --- a/src/messenger/messenger_api_contact_store.c +++ b/src/messenger/messenger_api_contact_store.c | |||
@@ -155,8 +155,10 @@ update_store_contact (struct GNUNET_MESSENGER_ContactStore *store, struct GNUNET | |||
155 | store, next_context, &hash | 155 | store, next_context, &hash |
156 | ); | 156 | ); |
157 | 157 | ||
158 | GNUNET_CONTAINER_multihashmap_put (map, &hash, contact, | 158 | if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (map, &hash, contact, |
159 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 159 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) |
160 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Updating a contact failed: %s\n", | ||
161 | GNUNET_h2s(&hash)); | ||
160 | } | 162 | } |
161 | } | 163 | } |
162 | 164 | ||
@@ -176,7 +178,8 @@ remove_store_contact (struct GNUNET_MESSENGER_ContactStore *store, struct GNUNET | |||
176 | ); | 178 | ); |
177 | 179 | ||
178 | if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_remove (map, &hash, contact)) | 180 | if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_remove (map, &hash, contact)) |
179 | return; | 181 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Removing a contact failed: %s\n", |
182 | GNUNET_h2s(&hash)); | ||
180 | 183 | ||
181 | destroy_contact (contact); | 184 | destroy_contact (contact); |
182 | } | 185 | } |
diff --git a/src/messenger/messenger_api_message.c b/src/messenger/messenger_api_message.c index d88859186..0d885f9ee 100644..100755 --- a/src/messenger/messenger_api_message.c +++ b/src/messenger/messenger_api_message.c | |||
@@ -590,7 +590,7 @@ int | |||
590 | decode_message (struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, | 590 | decode_message (struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, |
591 | int include_signature, uint16_t *padding) | 591 | int include_signature, uint16_t *padding) |
592 | { | 592 | { |
593 | GNUNET_assert((message) && (buffer)); | 593 | GNUNET_assert((message) && (buffer) && (length >= sizeof(message->header))); |
594 | 594 | ||
595 | uint16_t offset = 0; | 595 | uint16_t offset = 0; |
596 | 596 | ||
diff --git a/src/messenger/messenger_api_room.c b/src/messenger/messenger_api_room.c index df141ca12..5b7edee60 100644..100755 --- a/src/messenger/messenger_api_room.c +++ b/src/messenger/messenger_api_room.c | |||
@@ -106,7 +106,7 @@ get_room_sender (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_H | |||
106 | return (entry? entry->sender : NULL); | 106 | return (entry? entry->sender : NULL); |
107 | } | 107 | } |
108 | 108 | ||
109 | static void | 109 | static struct GNUNET_MESSENGER_Contact* |
110 | handle_join_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, | 110 | handle_join_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, |
111 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 111 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) |
112 | { | 112 | { |
@@ -124,6 +124,8 @@ handle_join_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER | |||
124 | (GNUNET_OK == GNUNET_CONTAINER_multishortmap_put(room->members, &(message->header.sender_id), sender, | 124 | (GNUNET_OK == GNUNET_CONTAINER_multishortmap_put(room->members, &(message->header.sender_id), sender, |
125 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE))) | 125 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE))) |
126 | increase_contact_rc(sender); | 126 | increase_contact_rc(sender); |
127 | |||
128 | return sender; | ||
127 | } | 129 | } |
128 | 130 | ||
129 | static void | 131 | static void |
@@ -140,7 +142,7 @@ handle_leave_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGE | |||
140 | struct GNUNET_MESSENGER_ContactStore *store = get_handle_contact_store(room->handle); | 142 | struct GNUNET_MESSENGER_ContactStore *store = get_handle_contact_store(room->handle); |
141 | 143 | ||
142 | if (GNUNET_YES == decrease_contact_rc(sender)) | 144 | if (GNUNET_YES == decrease_contact_rc(sender)) |
143 | remove_store_contact(store, sender, &context); | 145 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "A contact does not share any room with you anymore!\n"); |
144 | } | 146 | } |
145 | 147 | ||
146 | static void | 148 | static void |
@@ -216,17 +218,17 @@ handle_delete_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENG | |||
216 | } | 218 | } |
217 | } | 219 | } |
218 | 220 | ||
219 | void | 221 | struct GNUNET_MESSENGER_Contact* |
220 | handle_room_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, | 222 | handle_room_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, |
221 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 223 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) |
222 | { | 224 | { |
223 | if (GNUNET_NO != GNUNET_CONTAINER_multihashmap_contains (room->messages, hash)) | 225 | if (GNUNET_NO != GNUNET_CONTAINER_multihashmap_contains (room->messages, hash)) |
224 | return; | 226 | return sender; |
225 | 227 | ||
226 | switch (message->header.kind) | 228 | switch (message->header.kind) |
227 | { | 229 | { |
228 | case GNUNET_MESSENGER_KIND_JOIN: | 230 | case GNUNET_MESSENGER_KIND_JOIN: |
229 | handle_join_message (room, sender, message, hash); | 231 | sender = handle_join_message (room, sender, message, hash); |
230 | break; | 232 | break; |
231 | case GNUNET_MESSENGER_KIND_LEAVE: | 233 | case GNUNET_MESSENGER_KIND_LEAVE: |
232 | handle_leave_message (room, sender, message, hash); | 234 | handle_leave_message (room, sender, message, hash); |
@@ -253,7 +255,7 @@ handle_room_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER | |||
253 | struct GNUNET_MESSENGER_RoomMessageEntry *entry = GNUNET_new(struct GNUNET_MESSENGER_RoomMessageEntry); | 255 | struct GNUNET_MESSENGER_RoomMessageEntry *entry = GNUNET_new(struct GNUNET_MESSENGER_RoomMessageEntry); |
254 | 256 | ||
255 | if (!entry) | 257 | if (!entry) |
256 | return; | 258 | return sender; |
257 | 259 | ||
258 | entry->sender = sender; | 260 | entry->sender = sender; |
259 | entry->message = copy_message (message); | 261 | entry->message = copy_message (message); |
@@ -264,6 +266,8 @@ handle_room_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER | |||
264 | destroy_message (entry->message); | 266 | destroy_message (entry->message); |
265 | GNUNET_free(entry); | 267 | GNUNET_free(entry); |
266 | } | 268 | } |
269 | |||
270 | return sender; | ||
267 | } | 271 | } |
268 | 272 | ||
269 | struct GNUNET_MESSENGER_MemberCall | 273 | struct GNUNET_MESSENGER_MemberCall |
diff --git a/src/messenger/messenger_api_room.h b/src/messenger/messenger_api_room.h index 9455fd43b..eb41cf740 100644..100755 --- a/src/messenger/messenger_api_room.h +++ b/src/messenger/messenger_api_room.h | |||
@@ -100,12 +100,16 @@ get_room_sender (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_H | |||
100 | * Handles a <i>message</i> with a given <i>hash</i> in a <i>room</i> for the client API to update | 100 | * Handles a <i>message</i> with a given <i>hash</i> in a <i>room</i> for the client API to update |
101 | * members and its information. The function also stores the message in map locally for access afterwards. | 101 | * members and its information. The function also stores the message in map locally for access afterwards. |
102 | * | 102 | * |
103 | * The contact of the message's sender could be updated or even created. It may not be freed or destroyed though! | ||
104 | * (The contact may still be in use for old messages...) | ||
105 | * | ||
103 | * @param[in/out] room Room | 106 | * @param[in/out] room Room |
104 | * @param[in/out] sender Contact of sender | 107 | * @param[in/out] sender Contact of sender |
105 | * @param[in] message Message | 108 | * @param[in] message Message |
106 | * @param[in] hash Hash of message | 109 | * @param[in] hash Hash of message |
110 | * @return Contact of sender | ||
107 | */ | 111 | */ |
108 | void | 112 | struct GNUNET_MESSENGER_Contact* |
109 | handle_room_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, | 113 | handle_room_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, |
110 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | 114 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); |
111 | 115 | ||