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

Commit 8c208f5d authored by Hansong Zhang's avatar Hansong Zhang
Browse files

Rootcanal catch SIGPIPE

In case the client socket is closed, and rootcanal doesn't detect it due
to TimerTick not fired, writing to the socket causes a SIGPIPE and we
need to catch it to prevent rootcanal from crash.

Bug: 138259663
Test: run_cert.sh with empty test case
Change-Id: I3b9753cfc1cf09fcd7ea123d79048a9b8bacdd87
parent 1bfb779d
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@
#include <fcntl.h>
#include <fcntl.h>
#include <netdb.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/in.h>
#include <signal.h>
#include <string.h>
#include <string.h>
#include <unistd.h>
#include <unistd.h>


@@ -48,6 +49,11 @@ void TestEnvironment::initialize(std::promise<void> barrier) {
  SetUpHciServer([this](int fd) { test_model_.IncomingHciConnection(fd); });
  SetUpHciServer([this](int fd) { test_model_.IncomingHciConnection(fd); });
  SetUpLinkLayerServer([this](int fd) { test_model_.IncomingLinkLayerConnection(fd); });
  SetUpLinkLayerServer([this](int fd) { test_model_.IncomingLinkLayerConnection(fd); });


  // In case the client socket is closed, and rootcanal doesn't detect it due to
  // TimerTick not fired, writing to the socket causes a SIGPIPE and we need to
  // catch it to prevent rootcanal from crash
  signal(SIGPIPE, SIG_IGN);

  LOG_INFO("%s: Finished", __func__);
  LOG_INFO("%s: Finished", __func__);
}
}


+3 −0
Original line number Original line Diff line number Diff line
@@ -105,6 +105,9 @@ void H4Packetizer::OnDataReady(int fd) {
      if (errno == EAGAIN) {
      if (errno == EAGAIN) {
        // No data, try again later.
        // No data, try again later.
        return;
        return;
      } else if (errno == ECONNRESET) {
        // They probably rejected our packet
        return;
      } else {
      } else {
        LOG_ALWAYS_FATAL("%s: Read packet type error: %s", __func__, strerror(errno));
        LOG_ALWAYS_FATAL("%s: Read packet type error: %s", __func__, strerror(errno));
      }
      }