Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e71fb7d2 authored by Corey Tabaka's avatar Corey Tabaka
Browse files

Quick fix to correctly handle empty file/channel handles.

Empty file/channel handles (value < 0) should result in a negative
FileReference/ChannelReference value. The original code incorrectly
interpreted the negative reference value as an error, causing errno
to be returned. In most cases errno is 0, leading to confusion
across the wire when the deserialization logic attempts to lookup an
invalid, but non-empty reference.

Bug: None
Test: bufferhub_tests passes
Change-Id: I664daf3cdc178fe2c4ca0c44eef35a8bb9c7310d
parent e15bb2b1
Loading
Loading
Loading
Loading
+6 −6
Original line number Original line Diff line number Diff line
@@ -129,7 +129,7 @@ FileReference Message::PushFileHandle(const LocalHandle& handle) {
  PDX_TRACE_NAME("Message::PushFileHandle");
  PDX_TRACE_NAME("Message::PushFileHandle");
  if (auto svc = service_.lock()) {
  if (auto svc = service_.lock()) {
    ErrnoGuard errno_guard;
    ErrnoGuard errno_guard;
    return ReturnCodeOrError(svc->endpoint()->PushFileHandle(this, handle));
    return svc->endpoint()->PushFileHandle(this, handle);
  } else {
  } else {
    return -ESHUTDOWN;
    return -ESHUTDOWN;
  }
  }
@@ -139,7 +139,7 @@ FileReference Message::PushFileHandle(const BorrowedHandle& handle) {
  PDX_TRACE_NAME("Message::PushFileHandle");
  PDX_TRACE_NAME("Message::PushFileHandle");
  if (auto svc = service_.lock()) {
  if (auto svc = service_.lock()) {
    ErrnoGuard errno_guard;
    ErrnoGuard errno_guard;
    return ReturnCodeOrError(svc->endpoint()->PushFileHandle(this, handle));
    return svc->endpoint()->PushFileHandle(this, handle);
  } else {
  } else {
    return -ESHUTDOWN;
    return -ESHUTDOWN;
  }
  }
@@ -149,7 +149,7 @@ FileReference Message::PushFileHandle(const RemoteHandle& handle) {
  PDX_TRACE_NAME("Message::PushFileHandle");
  PDX_TRACE_NAME("Message::PushFileHandle");
  if (auto svc = service_.lock()) {
  if (auto svc = service_.lock()) {
    ErrnoGuard errno_guard;
    ErrnoGuard errno_guard;
    return ReturnCodeOrError(svc->endpoint()->PushFileHandle(this, handle));
    return svc->endpoint()->PushFileHandle(this, handle);
  } else {
  } else {
    return -ESHUTDOWN;
    return -ESHUTDOWN;
  }
  }
@@ -159,7 +159,7 @@ ChannelReference Message::PushChannelHandle(const LocalChannelHandle& handle) {
  PDX_TRACE_NAME("Message::PushChannelHandle");
  PDX_TRACE_NAME("Message::PushChannelHandle");
  if (auto svc = service_.lock()) {
  if (auto svc = service_.lock()) {
    ErrnoGuard errno_guard;
    ErrnoGuard errno_guard;
    return ReturnCodeOrError(svc->endpoint()->PushChannelHandle(this, handle));
    return svc->endpoint()->PushChannelHandle(this, handle);
  } else {
  } else {
    return -ESHUTDOWN;
    return -ESHUTDOWN;
  }
  }
@@ -170,7 +170,7 @@ ChannelReference Message::PushChannelHandle(
  PDX_TRACE_NAME("Message::PushChannelHandle");
  PDX_TRACE_NAME("Message::PushChannelHandle");
  if (auto svc = service_.lock()) {
  if (auto svc = service_.lock()) {
    ErrnoGuard errno_guard;
    ErrnoGuard errno_guard;
    return ReturnCodeOrError(svc->endpoint()->PushChannelHandle(this, handle));
    return svc->endpoint()->PushChannelHandle(this, handle);
  } else {
  } else {
    return -ESHUTDOWN;
    return -ESHUTDOWN;
  }
  }
@@ -180,7 +180,7 @@ ChannelReference Message::PushChannelHandle(const RemoteChannelHandle& handle) {
  PDX_TRACE_NAME("Message::PushChannelHandle");
  PDX_TRACE_NAME("Message::PushChannelHandle");
  if (auto svc = service_.lock()) {
  if (auto svc = service_.lock()) {
    ErrnoGuard errno_guard;
    ErrnoGuard errno_guard;
    return ReturnCodeOrError(svc->endpoint()->PushChannelHandle(this, handle));
    return svc->endpoint()->PushChannelHandle(this, handle);
  } else {
  } else {
    return -ESHUTDOWN;
    return -ESHUTDOWN;
  }
  }