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

Commit 7dfac44c authored by Andreas Huber's avatar Andreas Huber
Browse files

Use a pipe rather than a socketpair to collect debug information from

Treble HALs.

Bug: 79656374
Test: manually
Change-Id: I2c7a67c67bc8f99aff8efa9570acf82f474a8dc3
parent 98ad260f
Loading
Loading
Loading
Loading
+2 −10
Original line number Original line Diff line number Diff line
@@ -16,7 +16,6 @@


#include "PipeRelay.h"
#include "PipeRelay.h"


#include <sys/socket.h>
#include <utils/Thread.h>
#include <utils/Thread.h>


namespace android {
namespace android {
@@ -58,7 +57,7 @@ bool PipeRelay::RelayThread::threadLoop() {


PipeRelay::PipeRelay(std::ostream &os)
PipeRelay::PipeRelay(std::ostream &os)
    : mInitCheck(NO_INIT) {
    : mInitCheck(NO_INIT) {
    int res = socketpair(AF_UNIX, SOCK_STREAM, 0 /* protocol */, mFds);
    int res = pipe(mFds);


    if (res < 0) {
    if (res < 0) {
        mInitCheck = -errno;
        mInitCheck = -errno;
@@ -77,20 +76,13 @@ void PipeRelay::CloseFd(int *fd) {
}
}


PipeRelay::~PipeRelay() {
PipeRelay::~PipeRelay() {
    if (mFds[1] >= 0) {
    CloseFd(&mFds[1]);
        shutdown(mFds[1], SHUT_WR);
    }

    if (mFds[0] >= 0) {
        shutdown(mFds[0], SHUT_RD);
    }


    if (mThread != NULL) {
    if (mThread != NULL) {
        mThread->join();
        mThread->join();
        mThread.clear();
        mThread.clear();
    }
    }


    CloseFd(&mFds[1]);
    CloseFd(&mFds[0]);
    CloseFd(&mFds[0]);
}
}