Tun/tap flags fix.

This commit is contained in:
Adam Ierymenko 2020-11-16 19:08:09 -05:00
parent dc806dd718
commit 5282e06fd4
No known key found for this signature in database
GPG Key ID: C8877CF2D7A5D7F3

View File

@ -174,7 +174,6 @@ LinuxEthernetTap::LinuxEthernetTap(
::ioctl(_fd,TUNSETPERSIST,0); // valgrind may generate a false alarm here ::ioctl(_fd,TUNSETPERSIST,0); // valgrind may generate a false alarm here
_dev = ifr.ifr_name; _dev = ifr.ifr_name;
::fcntl(_fd,F_SETFD,fcntl(_fd,F_GETFD) | FD_CLOEXEC); ::fcntl(_fd,F_SETFD,fcntl(_fd,F_GETFD) | FD_CLOEXEC);
::fcntl(_fd,F_SETFL,O_NONBLOCK);
(void)::pipe(_shutdownSignalPipe); (void)::pipe(_shutdownSignalPipe);
@ -450,7 +449,7 @@ void LinuxEthernetTap::threadMain()
return; return;
} }
if (fcntl(_fd,F_SETFL,fcntl(_fd,F_GETFL) & ~O_NONBLOCK) == -1) { if (fcntl(_fd,F_SETFL,O_NONBLOCK) == -1) {
::close(sock); ::close(sock);
printf("WARNING: ioctl() failed setting up Linux tap device (set non-blocking)\n"); printf("WARNING: ioctl() failed setting up Linux tap device (set non-blocking)\n");
return; return;