Merge "conman:  Don't interrupt provisioning."
diff --git a/conman/interface.py b/conman/interface.py
index 51647ee..e71a322 100755
--- a/conman/interface.py
+++ b/conman/interface.py
@@ -470,7 +470,7 @@
       self._wpa_control = self.get_wpa_control(socket)
       self._wpa_control.attach()
       logging.debug('%s successfully attached', self.name)
-    except wpactrl.error as e:
+    except (wpactrl.error, OSError) as e:
       logging.error('Error attaching to wpa_supplicant: %s', e)
       return False
 
@@ -497,7 +497,7 @@
       lines = []
       try:
         lines = self._wpa_control.request('STATUS').splitlines()
-      except wpactrl.error as e:
+      except (wpactrl.error, OSError) as e:
         logging.error('wpa_control STATUS request failed %s args %s',
                       e.message, e.args)
         lines = self.wpa_cli_status().splitlines()
@@ -516,7 +516,7 @@
     if self.attached():
       try:
         self._wpa_control.detach()
-      except wpactrl.error:
+      except (wpactrl.error, OSError):
         logging.error('Failed to detach from wpa_supplicant interface. This '
                       'may mean something else killed wpa_supplicant.')
         self._wpa_control = None
diff --git a/ledpattern/ledpatterns b/ledpattern/ledpatterns
index 0b86fb7..e704a2c 100644
--- a/ledpattern/ledpatterns
+++ b/ledpattern/ledpatterns
@@ -14,6 +14,7 @@
 SET_LASER_FAILED_13,P,B,B,R,B
 SET_LASER_FAILED_14,P,B,B,B,R
 SET_LASER_FAILED_15,P,B,B,B,B
+SET_LASER_FAILED_16,P,B,B,B,P
 GPON_INITIAL,P,P,R,R
 GPON_STANDBY,P,P,R,B
 GPON_SERIAL,P,P,B,R
@@ -25,4 +26,3 @@
 WAIT_ACS,P,B,B
 ALL_OK,P,B
 UNKNOWN_ERROR,P,R
-
diff --git a/logupload/client/log_uploader_main.c b/logupload/client/log_uploader_main.c
index e160dd1..e9146fa 100644
--- a/logupload/client/log_uploader_main.c
+++ b/logupload/client/log_uploader_main.c
@@ -42,7 +42,10 @@
 // conserve.
 #define ZLIB_COMPRESS_LEVEL 1
 
-static const char *interfaces_to_check[] = { "br0", "eth0", "man", "pon0" };
+static const char *interfaces_to_check[] = {
+  "br0", "br1", "eth0", "man", "pon0", "wcli0", "wcli1",
+  "wlan0_portal", "wlan1_portal"
+};
 static int num_interfaces = sizeof(interfaces_to_check) /
   sizeof(interfaces_to_check[0]);
 
diff --git a/rcu_audio/gfrm-voice-demo.cc b/rcu_audio/gfrm-voice-demo.cc
index c097252..cda1db0 100644
--- a/rcu_audio/gfrm-voice-demo.cc
+++ b/rcu_audio/gfrm-voice-demo.cc
@@ -15,6 +15,7 @@
  */
 
 #define _BSD_SOURCE
+#include <arpa/inet.h>
 #include <endian.h>
 #include <fcntl.h>
 #include <stdint.h>
@@ -25,7 +26,6 @@
 #include <sys/socket.h>
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <sys/un.h>
 #include <unistd.h>
 
 #include "rcu-audio.h"
@@ -64,7 +64,7 @@
 {
   mode_t mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP;
   int fd;
-  struct sockaddr_un sun;
+  struct sockaddr_in sin;
   const char *outfile = "/tmp/audio.wav";
   int outfd;
   uint8_t buf[8192];
@@ -88,15 +88,17 @@
     }
   }
 
-  if ((fd = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0) {
-    perror("socket(AF_UNIX) RCU_AUDIO_PATH");
+  if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+    perror("socket(AF_INET) RCU_AUDIO");
     exit(1);
   }
-  memset(&sun, 0, sizeof(sun));
-  sun.sun_family = AF_UNIX;
-  strncpy(&sun.sun_path[1], RCU_AUDIO_PATH, sizeof(sun.sun_path) - 2);
-  if (bind(fd, (const struct sockaddr *) &sun, sizeof(sun)) < 0) {
-    perror("bind(AF_UNIX) RCU_AUDIO_PATH");
+  memset(&sin, 0, sizeof(sin));
+  sin.sin_family = AF_INET;
+  sin.sin_port = htons(RCU_AUDIO_PORT);
+  sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+
+  if (bind(fd, (const struct sockaddr *) &sin, sizeof(sin)) < 0) {
+    perror("bind(AF_INET) RCU_AUDIO_PORT");
     exit(1);
   }
 
diff --git a/rcu_audio/gfrm100-rcu-audio.cc b/rcu_audio/gfrm100-rcu-audio.cc
index 6e55e93..31056ad 100644
--- a/rcu_audio/gfrm100-rcu-audio.cc
+++ b/rcu_audio/gfrm100-rcu-audio.cc
@@ -27,6 +27,7 @@
  * applications using hidraw.
  */
 
+#include <arpa/inet.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <linux/hidraw.h>
@@ -40,7 +41,6 @@
 #include <sys/socket.h>
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <sys/un.h>
 #include <unistd.h>
 
 #include <vector>
@@ -53,7 +53,7 @@
 {
   int in = -1, out = -1, connected = 0;
   const char *device;
-  struct sockaddr_un sun;
+  struct sockaddr_in sin;
   char name[16];
   char address[64];
 
@@ -68,9 +68,10 @@
     exit(1);
   }
 
-  memset(&sun, 0, sizeof(sun));
-  sun.sun_family = AF_UNIX;
-  strncpy(&sun.sun_path[1], RCU_AUDIO_PATH, sizeof(sun.sun_path) - 2);
+  memset(&sin, 0, sizeof(sin));
+  sin.sin_family = AF_INET;
+  sin.sin_port = htons(RCU_AUDIO_PORT);
+  sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
 
   if (ioctl(in, HIDIOCGRAWNAME(sizeof(name)), name) < 0) {
     perror("HIDIOCGRAWNAME");
@@ -96,7 +97,7 @@
 
   while (1) {
     uint8_t data[2048];
-    size_t len = read(in, data, sizeof(data));
+    ssize_t len = read(in, data, sizeof(data));
 
     if (len < 0) {
       fprintf(stderr, "GFRM100 has disconnected. Exiting.\n");
@@ -132,7 +133,7 @@
       }
 
       if (!connected) {
-        if (connect(out, (const struct sockaddr *) &sun, sizeof(sun)) == 0) {
+        if (connect(out, (const struct sockaddr *) &sin, sizeof(sin)) == 0) {
           connected = 1;
         } else {
           sleep(2);  /* rate limit how often we retry. */
diff --git a/rcu_audio/rcu-audio.h b/rcu_audio/rcu-audio.h
index 725ca10..38b06d7 100644
--- a/rcu_audio/rcu-audio.h
+++ b/rcu_audio/rcu-audio.h
@@ -17,13 +17,13 @@
 #ifndef RCU_AUDIO_H
 #define RCU_AUDIO_H
 
-#define RCU_AUDIO_PATH "rcu_audio"
+#define RCU_AUDIO_PORT  1995
 
 /* Return 1 if at least one second has passed since the
  * last successful call to pacing(). */
 extern int pacing();
 
-/* Return an AF_UNIX socket, or die trying. */
+/* Return an AF_INET socket, or die trying. */
 extern int get_socket_or_die();
 
 #endif  /* RCU_AUDIO_H */
diff --git a/rcu_audio/rcu-utils.cc b/rcu_audio/rcu-utils.cc
index 2bd1e41..ad694c8 100644
--- a/rcu_audio/rcu-utils.cc
+++ b/rcu_audio/rcu-utils.cc
@@ -53,8 +53,8 @@
 {
   int s;
 
-  if ((s = socket(AF_UNIX, SOCK_NONBLOCK | SOCK_DGRAM, 0)) < 0) {
-    perror("socket(AF_UNIX)");
+  if ((s = socket(AF_INET, SOCK_NONBLOCK | SOCK_DGRAM, 0)) < 0) {
+    perror("socket(AF_INET)");
     exit(1);
   }
 
diff --git a/rcu_audio/ti-rcu-audio.cc b/rcu_audio/ti-rcu-audio.cc
index 76f1126..67dd869 100644
--- a/rcu_audio/ti-rcu-audio.cc
+++ b/rcu_audio/ti-rcu-audio.cc
@@ -17,6 +17,7 @@
  * it exists in order to interface with the RAS_LIB.c implementation
  * provided by TI which is not licensed under Apache. */
 
+#include <arpa/inet.h>
 #include <fcntl.h>
 #include <stdint.h>
 #include <stdio.h>
@@ -39,6 +40,7 @@
 {
   int is = -1, os = -1, connected = 0;
   struct sockaddr_un sun;
+  struct sockaddr_in sin;
   uint8 prev = 0;
   int msgs = 0, missed = 0, errors = 0;
 
@@ -51,13 +53,14 @@
     exit(1);
   }
 
-  memset(&sun, 0, sizeof(sun));
-  sun.sun_family = AF_UNIX;
-  strncpy(&sun.sun_path[1], RCU_AUDIO_PATH, sizeof(sun.sun_path) - 2);
+  memset(&sin, 0, sizeof(sin));
+  sin.sin_family = AF_INET;
+  sin.sin_port = htons(RCU_AUDIO_PORT);
+  sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
 
   while (1) {
     uint8 ibuf[MAX_INPUT_BUF_SIZE + 6 + 1 + 4];
-    size_t ilen;
+    ssize_t ilen;
 
     ilen = recv(is, ibuf, sizeof(ibuf), 0);
     if (ilen < 23) {
@@ -121,7 +124,7 @@
         }
 
         if (!connected) {
-          if (connect(os, (const struct sockaddr *) &sun, sizeof(sun)) == 0) {
+          if (connect(os, (const struct sockaddr *) &sin, sizeof(sin)) == 0) {
             connected = 1;
           } else {
             sleep(2);  /* rate limit how often we try */
diff --git a/wifi/wifi.py b/wifi/wifi.py
index 142010c..4204791 100755
--- a/wifi/wifi.py
+++ b/wifi/wifi.py
@@ -1082,20 +1082,23 @@
         'stopclient': stop_client_wifi,
         'stopap': stop_ap_wifi,
         'scan': scan_wifi,
-    }[extra[0]]
+    }[command]
   except KeyError:
-    parser.fatal('Unrecognized command %s' % extra[0])
+    parser.fatal('Unrecognized command %s' % command)
 
-  if not lockfile_taken:
-    utils.lock(_LOCKFILE, int(opt.lock_timeout))
-    atexit.register(utils.unlock, _LOCKFILE)
-    lockfile_taken = True
+  read_only_commands = ('show',)
+
+  if command not in read_only_commands:
+    if not lockfile_taken:
+      utils.lock(_LOCKFILE, int(opt.lock_timeout))
+      atexit.register(utils.unlock, _LOCKFILE)
+      lockfile_taken = True
 
   success = function(opt)
 
   if success:
-    if extra[0] in ('set', 'setclient'):
-      program = 'hostapd' if extra[0] == 'set' else 'wpa_supplicant'
+    if command in ('set', 'setclient'):
+      program = 'hostapd' if command == 'set' else 'wpa_supplicant'
       if opt.persist:
         phy = iw.find_phy(opt.band, opt.channel)
         for band in iw.phy_bands(phy):