summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2021-03-06 19:03:05 +0100
committerTheJackiMonster <thejackimonster@gmail.com>2021-03-06 19:03:05 +0100
commit9ae422a2a86c3a8199b3fcb4a64ab475274b3450 (patch)
tree46eea216b0ed284f5c058213f2a2733b366af4b3
parent2925310d67483aca6e055e1ce0593c6463cd6c72 (diff)
-fix for messengers session-chain
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r--src/messenger/gnunet-service-messenger_member_session.c16
-rw-r--r--src/messenger/gnunet-service-messenger_member_session.h1
-rw-r--r--src/messenger/gnunet-service-messenger_room.c37
3 files changed, 53 insertions, 1 deletions
diff --git a/src/messenger/gnunet-service-messenger_member_session.c b/src/messenger/gnunet-service-messenger_member_session.c
index 636285d93..2e6eae59e 100644
--- a/src/messenger/gnunet-service-messenger_member_session.c
+++ b/src/messenger/gnunet-service-messenger_member_session.c
@@ -68,6 +68,7 @@ create_member_session (struct GNUNET_MESSENGER_Member *member,
init_list_messages(&(session->messages));
+ session->prev = NULL;
session->next = NULL;
session->closed = GNUNET_NO;
@@ -222,6 +223,7 @@ switch_member_session (struct GNUNET_MESSENGER_MemberSession *session,
copy_list_messages(&(next->messages), &(session->messages));
session->next = next;
+ next->prev = session;
next->next = NULL;
session->closed = GNUNET_YES;
@@ -516,6 +518,14 @@ load_member_session (struct GNUNET_MESSENGER_Member *member, const char *directo
goto destroy_config;
session = create_member_session(member, &key);
+
+ unsigned long long numeric_value;
+
+ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number(cfg, "session", "closed", &numeric_value))
+ session->closed = (GNUNET_YES == numeric_value? GNUNET_YES : GNUNET_NO);
+
+ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number(cfg, "session", "completed", &numeric_value))
+ session->completed = (GNUNET_YES == numeric_value? GNUNET_YES : GNUNET_NO);
}
destroy_config:
@@ -599,6 +609,9 @@ load_member_session_next (struct GNUNET_MESSENGER_MemberSession *session, const
session->next = get_cycle_safe_next_session(
session, member? get_member_session (member, &next_key) : NULL
);
+
+ if (session->next)
+ session->next->prev = session;
}
destroy_config:
@@ -688,6 +701,9 @@ save_member_session (struct GNUNET_MESSENGER_MemberSession *session, const char
}
}
+ GNUNET_CONFIGURATION_set_value_number (cfg, "session", "closed", session->closed);
+ GNUNET_CONFIGURATION_set_value_number (cfg, "session", "completed", session->completed);
+
GNUNET_CONFIGURATION_write (cfg, config_file);
GNUNET_CONFIGURATION_destroy (cfg);
diff --git a/src/messenger/gnunet-service-messenger_member_session.h b/src/messenger/gnunet-service-messenger_member_session.h
index dd753be2a..cf4a6bb07 100644
--- a/src/messenger/gnunet-service-messenger_member_session.h
+++ b/src/messenger/gnunet-service-messenger_member_session.h
@@ -46,6 +46,7 @@ struct GNUNET_MESSENGER_MemberSession {
struct GNUNET_CONTAINER_MultiHashMap *history;
struct GNUNET_MESSENGER_ListMessages messages;
+ struct GNUNET_MESSENGER_MemberSession* prev;
struct GNUNET_MESSENGER_MemberSession* next;
int closed;
diff --git a/src/messenger/gnunet-service-messenger_room.c b/src/messenger/gnunet-service-messenger_room.c
index e0bec7991..027df682c 100644
--- a/src/messenger/gnunet-service-messenger_room.c
+++ b/src/messenger/gnunet-service-messenger_room.c
@@ -939,6 +939,9 @@ iterate_update_member_sessions (void *cls, const struct GNUNET_IDENTITY_PublicKe
return GNUNET_YES;
}
+static void
+remove_room_member_session (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session);
+
void
callback_room_handle_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle,
const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
@@ -975,7 +978,7 @@ callback_room_handle_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUN
{
struct GNUNET_MESSENGER_MemberSessionCompletion *element = update.head;
- remove_member_session (element->session->member, element->session);
+ remove_room_member_session (room, element->session);
GNUNET_CONTAINER_DLL_remove(update.head, update.tail, element);
GNUNET_free (element);
@@ -1087,3 +1090,35 @@ save_room (struct GNUNET_MESSENGER_SrvRoom *room)
GNUNET_free(room_dir);
}
+
+static void
+remove_room_member_session (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session)
+{
+ GNUNET_assert ((room) && (session));
+
+ remove_member_session (session->member, session);
+
+ const struct GNUNET_IDENTITY_PublicKey *public_key = get_member_session_public_key(session);
+
+ struct GNUNET_HashCode hash;
+ GNUNET_CRYPTO_hash(public_key, sizeof(*public_key), &hash);
+
+ char *room_dir;
+ get_room_data_subdir (room, &room_dir);
+
+ char* session_dir;
+ GNUNET_asprintf (
+ &session_dir, "%s%s%c%s%c%s%c%s%c", room_dir,
+ "members", DIR_SEPARATOR,
+ GNUNET_sh2s(get_member_session_id(session)), DIR_SEPARATOR,
+ "sessions", DIR_SEPARATOR,
+ GNUNET_h2s(&hash), DIR_SEPARATOR
+ );
+
+ GNUNET_free (room_dir);
+
+ GNUNET_DISK_directory_remove(session_dir);
+ GNUNET_free (session_dir);
+
+ destroy_member_session(session);
+}