diff options
Diffstat (limited to 'ipc/gatekeeper_ipc.cpp')
-rw-r--r-- | ipc/gatekeeper_ipc.cpp | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/ipc/gatekeeper_ipc.cpp b/ipc/gatekeeper_ipc.cpp index 9994697..fd88770 100644 --- a/ipc/gatekeeper_ipc.cpp +++ b/ipc/gatekeeper_ipc.cpp @@ -33,20 +33,6 @@ public: ~SessionManager() { device->CloseSession(); } }; -class MessageDeleter { -public: - explicit MessageDeleter(handle_t chan, int id) { - chan_ = chan; - id_ = id; - } - - ~MessageDeleter() { put_msg(chan_, id_); } - -private: - handle_t chan_; - int id_; -}; - static gatekeeper_error_t tipc_err_to_gatekeeper_err(long tipc_err) { switch (tipc_err) { case NO_ERROR: @@ -187,8 +173,9 @@ static gatekeeper_error_t handle_msg(handle_t chan) { return tipc_err_to_gatekeeper_err(rc); } - MessageDeleter md(chan, msg_inf.id); - + /* TODO: handle heap allocation failure + * and retire the message on failure too + */ UniquePtr<uint8_t[]> msg_buf(new uint8_t[msg_inf.len]); /* read msg content */ @@ -197,6 +184,9 @@ static gatekeeper_error_t handle_msg(handle_t chan) { rc = read_msg(chan, msg_inf.id, 0, &msg); + // retire the message (note msg_inf.id becomes invalid after put_msg) + put_msg(chan, msg_inf.id); + if (rc < 0) { TLOGE("failed to read msg (%ld) for chan (%d)\n", rc, chan); return tipc_err_to_gatekeeper_err(rc); |