Merge "Use the getopt function in compliance with the standard."
diff --git a/include/sysutils/SocketListener.h b/include/sysutils/SocketListener.h
index c204a0f..bc93b86 100644
--- a/include/sysutils/SocketListener.h
+++ b/include/sysutils/SocketListener.h
@@ -38,6 +38,7 @@
 
     virtual ~SocketListener();
     int startListener();
+    int startListener(int backlog);
     int stopListener();
 
     void sendBroadcast(int code, const char *msg, bool addErrno);
diff --git a/libpixelflinger/scanline.cpp b/libpixelflinger/scanline.cpp
index cd78713..cb2b811 100644
--- a/libpixelflinger/scanline.cpp
+++ b/libpixelflinger/scanline.cpp
@@ -408,10 +408,10 @@
         GGLAssembler assembler( new ArmToArm64Assembler(a) );
 #endif
         // generate the scanline code for the given needs
-        int err = assembler.scanline(c->state.needs, c);
+        bool err = assembler.scanline(c->state.needs, c) != 0;
         if (ggl_likely(!err)) {
             // finally, cache this assembly
-            err = gCodeCache.cache(a->key(), a);
+            err = gCodeCache.cache(a->key(), a) < 0;
         }
         if (ggl_unlikely(err)) {
             ALOGE("error generating or caching assembly. Reverting to NOP.");
diff --git a/libsysutils/src/SocketListener.cpp b/libsysutils/src/SocketListener.cpp
index 5c75206..527a6a0 100644
--- a/libsysutils/src/SocketListener.cpp
+++ b/libsysutils/src/SocketListener.cpp
@@ -70,6 +70,10 @@
 }
 
 int SocketListener::startListener() {
+    return startListener(4);
+}
+
+int SocketListener::startListener(int backlog) {
 
     if (!mSocketName && mSock == -1) {
         SLOGE("Failed to start unbound listener");
@@ -84,7 +88,7 @@
         SLOGV("got mSock = %d for %s", mSock, mSocketName);
     }
 
-    if (mListen && listen(mSock, 4) < 0) {
+    if (mListen && listen(mSock, backlog) < 0) {
         SLOGE("Unable to listen on socket (%s)", strerror(errno));
         return -1;
     } else if (!mListen)
diff --git a/logd/main.cpp b/logd/main.cpp
index 1891206..6216b95 100644
--- a/logd/main.cpp
+++ b/logd/main.cpp
@@ -105,7 +105,8 @@
     // and LogReader is notified to send updates to connected clients.
 
     LogListener *swl = new LogListener(logBuf, reader);
-    if (swl->startListener()) {
+    // Backlog and /proc/sys/net/unix/max_dgram_qlen set to large value
+    if (swl->startListener(300)) {
         exit(1);
     }
 
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 9975368..ffbc9fa 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -100,6 +100,7 @@
     write /proc/sys/kernel/dmesg_restrict 1
     write /proc/sys/vm/mmap_min_addr 32768
     write /proc/sys/net/ipv4/ping_group_range "0 2147483647"
+    write /proc/sys/net/unix/max_dgram_qlen 300
     write /proc/sys/kernel/sched_rt_runtime_us 950000
     write /proc/sys/kernel/sched_rt_period_us 1000000
 
diff --git a/toolbox/lsof.c b/toolbox/lsof.c
index 113c120..af321af 100644
--- a/toolbox/lsof.c
+++ b/toolbox/lsof.c
@@ -113,7 +113,7 @@
     if (!maps)
         goto out;
 
-    while (fscanf(maps, "%*x-%*x %*s %zx %5s %ld %s\n", &offset, device, &inode,
+    while (fscanf(maps, "%*x-%*x %*s %zx %s %ld %s\n", &offset, device, &inode,
             file) == 4) {
         // We don't care about non-file maps
         if (inode == 0 || !strcmp(device, "00:00"))