OSDN Git Service

netd: NetlinkManager: don't fail if NETLINK_NFLOG socket is not there.
authorJP Abgrall <jpa@google.com>
Tue, 26 Jul 2011 22:36:40 +0000 (15:36 -0700)
committerJP Abgrall <jpa@google.com>
Tue, 26 Jul 2011 22:36:40 +0000 (15:36 -0700)
Some kernels used with ICS do not have the needed modules (quota2
with NFLOG support).
For those, we just don't allow NFLOG which will cripple quota alerts.
This is a temp workaround until kernels are prebuilts.

Change-Id: I403ba894aefb67996d791bd06055b8fec97d1407
Signed-off-by: JP Abgrall <jpa@google.com>
NetlinkManager.cpp

index 9af43b5..196945b 100644 (file)
@@ -109,7 +109,7 @@ int NetlinkManager::start() {
     if ((mQuotaHandler = setupSocket(&mQuotaSock, NETLINK_NFLOG,
         NFLOG_QUOTA_GROUP, NetlinkListener::NETLINK_FORMAT_BINARY)) == NULL) {
         LOGE("Unable to open quota2 logging socket");
-        return -1;
+        // TODO: return -1 once the emulator gets a new kernel.
     }
     return 0;
 }
@@ -139,16 +139,17 @@ int NetlinkManager::stop() {
     close(mRouteSock);
     mRouteSock = -1;
 
-    if (mQuotaHandler->stop()) {
-        LOGE("Unable to stop quota NetlinkHandler: %s", strerror(errno));
-        status = -1;
-    }
+    if (mQuotaHandler) {
+        if (mQuotaHandler->stop()) {
+            LOGE("Unable to stop quota NetlinkHandler: %s", strerror(errno));
+            status = -1;
+        }
 
-    delete mQuotaHandler;
-    mQuotaHandler = NULL;
-
-    close(mQuotaSock);
-    mQuotaSock = -1;
+        delete mQuotaHandler;
+        mQuotaHandler = NULL;
 
+        close(mQuotaSock);
+        mQuotaSock = -1;
+    }
     return status;
 }