aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWeston Carvalho <westoncarvalho@google.com>2024-02-22 20:22:15 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2024-02-22 20:22:15 +0000
commit033583c20503e486f6900f25259db2a6ef85640a (patch)
tree76717123279ac0172f64d11d1ba6004363d56368
parente326496fa7c566b521d1ff7288aae72e1f52bb1c (diff)
parent815e02ec35c06148525c9c8d8bd4b3ca5a998215 (diff)
downloadstorage-033583c20503e486f6900f25259db2a6ef85640a.tar.gz
Separate session init and destroy am: 815e02ec35
Original change: https://android-review.googlesource.com/c/trusty/app/storage/+/2806249 Change-Id: I9b18839a9d0ecd39df2a46ea6de19c665fc354af Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--client_tipc.c49
-rw-r--r--main.c2
-rw-r--r--storage_limits.h (renamed from tipc_limits.h)0
3 files changed, 30 insertions, 21 deletions
diff --git a/client_tipc.c b/client_tipc.c
index 6564c15..48b3d75 100644
--- a/client_tipc.c
+++ b/client_tipc.c
@@ -37,7 +37,7 @@
#include "file.h"
#include "ipc.h"
#include "session.h"
-#include "tipc_limits.h"
+#include "storage_limits.h"
/* macros to help manage debug output */
#define SS_ERR(args...) fprintf(stderr, "ss: " args)
@@ -331,6 +331,29 @@ static enum storage_err ensure_active_transaction(
return STORAGE_NO_ERROR;
}
+static void storage_client_session_init(struct storage_client_session* session,
+ struct fs* fs,
+ const uuid_t* peer) {
+ session->magic = STORAGE_CLIENT_SESSION_MAGIC;
+ session->files = NULL;
+ session->files_count = 0;
+
+ transaction_init(&session->tr, fs, false);
+
+ /* cache identity information */
+ memcpy(&session->uuid, peer, sizeof(*peer));
+}
+
+static void storage_client_session_destroy(
+ struct storage_client_session* session) {
+ if (list_in_list(&session->tr.allocated.node) && !session->tr.failed) {
+ /* discard partial transaction */
+ transaction_fail(&session->tr);
+ }
+ session_close_all_files(session);
+ transaction_free(&session->tr);
+}
+
/* abort transaction and clear sticky transaction error */
static enum storage_err storage_transaction_end(
struct storage_client_session* session,
@@ -1392,32 +1415,18 @@ static struct ipc_channel_context* client_connect(
struct storage_client_session* client_session =
&client_tipc_session->session;
- client_session->magic = STORAGE_CLIENT_SESSION_MAGIC;
- client_session->files = NULL;
- client_session->files_count = 0;
-
- transaction_init(&client_session->tr, client_port_context->tr_state, false);
-
- /* cache identity information */
- memcpy(&client_session->uuid, peer_uuid, sizeof(*peer_uuid));
+ storage_client_session_init(client_session, client_port_context->tr_state,
+ peer_uuid);
client_channel_ops_init(&client_tipc_session->chan_ctx.ops);
return &client_tipc_session->chan_ctx;
}
static void client_disconnect(struct ipc_channel_context* context) {
- struct storage_tipc_client_session* tipc_session;
- struct storage_client_session* session;
-
- tipc_session = chan_context_to_client_session(context);
- session = &tipc_session->session;
-
- if (list_in_list(&session->tr.allocated.node) && !session->tr.failed) {
- transaction_fail(&session->tr); /* discard partial transaction */
- }
- session_close_all_files(session);
- transaction_free(&session->tr);
+ struct storage_tipc_client_session* tipc_session =
+ chan_context_to_client_session(context);
+ storage_client_session_destroy(&tipc_session->session);
OPENSSL_cleanse(tipc_session, sizeof(struct storage_tipc_client_session));
free(tipc_session);
}
diff --git a/main.c b/main.c
index 077df39..872c870 100644
--- a/main.c
+++ b/main.c
@@ -27,7 +27,7 @@
#include "crypt.h"
#include "ipc.h"
#include "proxy.h"
-#include "tipc_limits.h"
+#include "storage_limits.h"
#define SS_ERR(args...) fprintf(stderr, "ss: " args)
diff --git a/tipc_limits.h b/storage_limits.h
index 3c5f55f..3c5f55f 100644
--- a/tipc_limits.h
+++ b/storage_limits.h