OSDN Git Service

Report the right error code from PropertyServiceConnection()
authorTom Cherry <tomcherry@google.com>
Fri, 14 Apr 2017 20:45:20 +0000 (13:45 -0700)
committerTom Cherry <tomcherry@google.com>
Fri, 14 Apr 2017 21:41:10 +0000 (14:41 -0700)
We're currently reporting errno from the clean up call to close(),
which is much less interesting than the failing connect() call that
precedes it.  This change reports errno from the connect() call
instead.

Bug: 36249702
Test: Boot bullhead, bionic unit tests
Test: Fake bad end point and see relevant error returned
Change-Id: Icadec463f50cd0a2a2faa08f049a7996cd32786f

libc/bionic/system_properties.cpp

index 2a42390..e5947c8 100644 (file)
@@ -501,9 +501,9 @@ class PropertyServiceConnection {
     socklen_t alen = namelen + offsetof(sockaddr_un, sun_path) + 1;
 
     if (TEMP_FAILURE_RETRY(connect(socket_, reinterpret_cast<sockaddr*>(&addr), alen)) == -1) {
+      last_error_ = errno;
       close(socket_);
       socket_ = -1;
-      last_error_ = errno;
     }
   }