OSDN Git Service

Create logging sockets with SOCK_NONBLOCK...
authorElliott Hughes <enh@google.com>
Sun, 28 Feb 2016 03:18:41 +0000 (19:18 -0800)
committerElliott Hughes <enh@google.com>
Sun, 28 Feb 2016 03:18:41 +0000 (19:18 -0800)
...rather than calling fcntl on them directly after creation.

Bug: https://code.google.com/p/android/issues/detail?id=201440
Change-Id: Ia3941b7645455d69620b1a361902df009b5da2c5

libc/bionic/libc_logging.cpp

index c6e1c20..6802944 100644 (file)
@@ -459,13 +459,8 @@ static int __libc_open_log_socket() {
   // found that all logd crashes thus far have had no problem stuffing
   // the UNIX domain socket and moving on so not critical *today*.
 
-  int log_fd = TEMP_FAILURE_RETRY(socket(PF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0));
-  if (log_fd < 0) {
-    return -1;
-  }
-
-  if (fcntl(log_fd, F_SETFL, O_NONBLOCK) == -1) {
-    close(log_fd);
+  int log_fd = TEMP_FAILURE_RETRY(socket(PF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0));
+  if (log_fd == -1) {
     return -1;
   }