summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2022-03-15 23:41:43 +0100
committerTheJackiMonster <thejackimonster@gmail.com>2022-03-15 23:41:43 +0100
commitb89df2053b1b0f9e33d676606546ac091a142e04 (patch)
tree77bdfa18e1f9900219c65dcb157b34d59bc7ae90
parentcfd3db44a82330272752ab3da08f1823c9867652 (diff)
-fix crash when member left messenger room
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r--src/messenger/gnunet-service-messenger.c4
-rw-r--r--src/messenger/gnunet-service-messenger_member_session.c8
-rw-r--r--src/messenger/gnunet-service-messenger_room.c28
-rw-r--r--src/messenger/gnunet-service-messenger_room.h15
-rw-r--r--src/messenger/gnunet-service-messenger_service.c8
5 files changed, 49 insertions, 14 deletions
diff --git a/src/messenger/gnunet-service-messenger.c b/src/messenger/gnunet-service-messenger.c
index 546f4c0d2..31bffec18 100644
--- a/src/messenger/gnunet-service-messenger.c
+++ b/src/messenger/gnunet-service-messenger.c
@@ -170,9 +170,7 @@ handle_room_close (void *cls,
if (GNUNET_YES == close_handle_room (msg_client->handle, &(msg->key)))
{
- const struct GNUNET_ShortHashCode *member_id = get_handle_member_id (msg_client->handle, &(msg->key));
-
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Closing room with member id: %s\n", GNUNET_sh2s (member_id));
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Closing room succeeded: %s\n", GNUNET_h2s (&(msg->key)));
struct GNUNET_MESSENGER_RoomMessage *response;
struct GNUNET_MQ_Envelope *env;
diff --git a/src/messenger/gnunet-service-messenger_member_session.c b/src/messenger/gnunet-service-messenger_member_session.c
index 846dbbe2b..6bd1d24b8 100644
--- a/src/messenger/gnunet-service-messenger_member_session.c
+++ b/src/messenger/gnunet-service-messenger_member_session.c
@@ -84,6 +84,9 @@ check_member_session_completion (struct GNUNET_MESSENGER_MemberSession *session)
{
GNUNET_assert (session);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Check session history (%s) for completion.\n",
+ GNUNET_sh2s(get_member_session_id(session)));
+
if (!session->messages.tail)
{
session->completed = GNUNET_YES;
@@ -142,7 +145,10 @@ check_member_session_completion (struct GNUNET_MESSENGER_MemberSession *session)
completion:
if (GNUNET_YES == is_member_session_completed(session))
{
- GNUNET_CONTAINER_multihashmap_destroy (session->history);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Completed session history (%s)\n",
+ GNUNET_sh2s(get_member_session_id(session)));
+
+ GNUNET_CONTAINER_multihashmap_clear (session->history);
struct GNUNET_MESSENGER_ContactStore *store = get_member_contact_store(session->member->store);
diff --git a/src/messenger/gnunet-service-messenger_room.c b/src/messenger/gnunet-service-messenger_room.c
index 7f2fd0ca6..7a20d2191 100644
--- a/src/messenger/gnunet-service-messenger_room.c
+++ b/src/messenger/gnunet-service-messenger_room.c
@@ -92,14 +92,14 @@ static void
handle_room_messages (struct GNUNET_MESSENGER_SrvRoom *room);
void
-destroy_room (struct GNUNET_MESSENGER_SrvRoom *room)
+destroy_room (struct GNUNET_MESSENGER_SrvRoom *room,
+ int deletion)
{
GNUNET_assert(room);
if (room->idle)
{
GNUNET_SCHEDULER_cancel (room->idle);
-
room->idle = NULL;
}
@@ -107,18 +107,22 @@ destroy_room (struct GNUNET_MESSENGER_SrvRoom *room)
GNUNET_CADET_close_port (room->port);
GNUNET_CONTAINER_multipeermap_iterate (room->tunnels, iterate_destroy_tunnels, NULL);
-
handle_room_messages (room);
- if (room->service->dir)
+ if (!(room->service->dir))
+ goto skip_saving;
+
+ if (GNUNET_YES == deletion)
+ remove_room (room);
+ else
save_room (room);
+skip_saving:
clear_member_store (get_room_member_store(room));
clear_message_store (get_room_message_store(room));
clear_operation_store(get_room_operation_store(room));
GNUNET_CONTAINER_multipeermap_destroy (room->tunnels);
-
clear_list_tunnels (&(room->basement));
clear_message_state(&(room->state));
@@ -1221,6 +1225,20 @@ save_room (struct GNUNET_MESSENGER_SrvRoom *room)
GNUNET_free(room_dir);
}
+void
+remove_room (struct GNUNET_MESSENGER_SrvRoom *room)
+{
+ GNUNET_assert(room);
+
+ char *room_dir;
+ get_room_data_subdir (room, &room_dir);
+
+ if (GNUNET_YES == GNUNET_DISK_directory_test (room_dir, GNUNET_YES))
+ GNUNET_DISK_directory_remove(room_dir);
+
+ GNUNET_free(room_dir);
+}
+
static void
remove_room_member_session (struct GNUNET_MESSENGER_SrvRoom *room,
struct GNUNET_MESSENGER_MemberSession *session)
diff --git a/src/messenger/gnunet-service-messenger_room.h b/src/messenger/gnunet-service-messenger_room.h
index 4b3811104..58edc4121 100644
--- a/src/messenger/gnunet-service-messenger_room.h
+++ b/src/messenger/gnunet-service-messenger_room.h
@@ -95,10 +95,15 @@ create_room (struct GNUNET_MESSENGER_SrvHandle *handle,
/**
* Destroys a room and frees its memory fully.
*
+ * The <i>deletion</i> flag should only be set to #GNUNET_YES if the
+ * room gets dropped by the service, otherwise #GNUNET_NO.
+ *
* @param[in/out] room Room
+ * @param[in] deletion Flag to indicate context of destruction
*/
void
-destroy_room (struct GNUNET_MESSENGER_SrvRoom *room);
+destroy_room (struct GNUNET_MESSENGER_SrvRoom *room,
+ int deletion);
/**
* Returns the used member store of a given <i>room</i>.
@@ -364,4 +369,12 @@ load_room (struct GNUNET_MESSENGER_SrvRoom *room);
void
save_room (struct GNUNET_MESSENGER_SrvRoom *room);
+/**
+ * Removes the configuration for a given <i>room</i> of a service.
+ *
+ * @param[in] room Room
+ */
+void
+remove_room (struct GNUNET_MESSENGER_SrvRoom *room);
+
#endif //GNUNET_SERVICE_MESSENGER_ROOM_H
diff --git a/src/messenger/gnunet-service-messenger_service.c b/src/messenger/gnunet-service-messenger_service.c
index b53b72af8..83d7632d8 100644
--- a/src/messenger/gnunet-service-messenger_service.c
+++ b/src/messenger/gnunet-service-messenger_service.c
@@ -94,7 +94,7 @@ iterate_destroy_rooms (void *cls,
void *value)
{
struct GNUNET_MESSENGER_SrvRoom *room = value;
- destroy_room (room);
+ destroy_room (room, GNUNET_NO);
return GNUNET_YES;
}
@@ -220,7 +220,7 @@ open_service_room (struct GNUNET_MESSENGER_Service *service,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)))
return GNUNET_YES;
- destroy_room (room);
+ destroy_room (room, GNUNET_YES);
return GNUNET_NO;
}
@@ -253,7 +253,7 @@ entry_service_room (struct GNUNET_MESSENGER_Service *service,
}
else
{
- destroy_room (room);
+ destroy_room (room, GNUNET_YES);
return GNUNET_NO;
}
@@ -287,7 +287,7 @@ close_service_room (struct GNUNET_MESSENGER_Service *service,
{
if (GNUNET_OK == GNUNET_CONTAINER_multihashmap_remove (service->rooms, key, room))
{
- destroy_room (room);
+ destroy_room (room, GNUNET_YES);
return GNUNET_YES;
}
else