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

Commit 323343aa authored by Kansho Nishida's avatar Kansho Nishida
Browse files

dumpstate: close socket after accepting



Close socket just after accept(), to make sure that connect() by client
will get error when the socket is used by the other services.

Bug: 135575100
Test: execute bugreport in parallel

Change-Id: I4e8a46e41519fa97cf41dde8955cf37361c6fa99
Signed-off-by: default avatarKansho Nishida <kansho@google.com>
parent 8475fc34
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -733,6 +733,11 @@ int open_socket(const char *service) {
    struct sockaddr addr;
    struct sockaddr addr;
    socklen_t alen = sizeof(addr);
    socklen_t alen = sizeof(addr);
    int fd = accept(s, &addr, &alen);
    int fd = accept(s, &addr, &alen);

    // Close socket just after accept(), to make sure that connect() by client will get error
    // when the socket is used by the other services.
    close(s);

    if (fd < 0) {
    if (fd < 0) {
        MYLOGE("accept(control socket): %s\n", strerror(errno));
        MYLOGE("accept(control socket): %s\n", strerror(errno));
        return -1;
        return -1;