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

Commit 4d4faf9e authored by Chia-chi Yeh's avatar Chia-chi Yeh Committed by Android (Google) Code Review
Browse files

Merge "VPN: make the file descriptor non-blocking by default."

parents 452eec33 84bf7390
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ static int create_interface(int mtu, char *name, int *index)
{
    int tun = open("/dev/tun", O_RDWR);
    int inet4 = socket(AF_INET, SOCK_DGRAM, 0);
    int flags;

    ifreq ifr4;
    memset(&ifr4, 0, sizeof(ifr4));
@@ -86,6 +87,13 @@ static int create_interface(int mtu, char *name, int *index)
        goto error;
    }

    // Make it non-blocking.
    flags = fcntl(tun, F_GETFL, 0);
    if (flags == -1 || fcntl(tun, F_SETFL, flags | O_NONBLOCK)) {
        LOGE("Cannot set non-blocking on %s: %s", ifr4.ifr_name, strerror(errno));
        goto error;
    }

    strcpy(name, ifr4.ifr_name);
    *index = ifr4.ifr_ifindex;
    close(inet4);