                     cb      : (err, output) =>
                         #winston.debug("result: #{err}, #{misc.to_json(output)}")
                         cb(err)
+                # MUST be here, since _restart_lock prevents _exec_on_local_hub!
                 @_restart_lock = true
         ], (err) =>
             winston.debug("local_hub restart: #{err}")

            else if socket?
                @_sockets[opts.session_uuid] = socket
                socket.history = undefined
            opts.cb(err, socket)
        )

    # Connect the client with a console session, possibly creating a session in the process.

    opts = defaults opts,
        port         : required
        secret_token : required
        timeout      : 10
        cb           : required

    socket = misc_node.connect_to_locked_socket
        port  : opts.port
        token : opts.secret_token
        timeout : opts.timeout
        cb    : (err) =>
            if err
                opts.cb(err)
