From 3f251efb9bb22fe45ef5392b8ed9d6f9148415e7 Mon Sep 17 00:00:00 2001
From: Paul Sokolovsky <pfalcon@users.sourceforge.net>
Date: Thu, 20 Oct 2016 16:49:45 +0300
Subject: [PATCH] esp8266/modules/webrepl: Enforce only one concurrent WebREPL
 connection.

Concurrent WebREPL connections were never supported, now actually check
for this.
---
 esp8266/modules/webrepl.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/esp8266/modules/webrepl.py b/esp8266/modules/webrepl.py
index da3e70c59..b200f4fc8 100644
--- a/esp8266/modules/webrepl.py
+++ b/esp8266/modules/webrepl.py
@@ -31,6 +31,10 @@ def setup_conn(port, accept_handler):
 def accept_conn(listen_sock):
     global client_s
     cl, remote_addr = listen_sock.accept()
+    if uos.dupterm():
+        print("\nConcurrent WebREPL connection from", remote_addr, "rejected")
+        cl.close()
+        return
     print("\nWebREPL connection from:", remote_addr)
     client_s = cl
     websocket_helper.server_handshake(cl)
-- 
GitLab