Ticket #1022: client-listen-v2.patch
File client-listen-v2.patch, 12.7 KB (added by , 19 months ago) |
---|
-
xpra/client/client_base.py
536 536 register_SIGUSR_signals(glib.idle_add) 537 537 538 538 def run(self): 539 self._protocol.start() 539 if self._protocol: 540 self._protocol.start() 540 541 541 542 def quit(self, exit_code=0): 542 543 raise Exception("override me!") -
xpra/client/gtk_base/gtk_client_window_base.py
1982 1982 1983 1983 1984 1984 def do_unmap_event(self, event): 1985 eventslog ("do_unmap_event(%s)", event)1985 eventslog.error("do_unmap_event(%s)", event) 1986 1986 self._unfocus() 1987 1987 if not self._override_redirect: 1988 1988 self.send("unmap-window", self._id, False) -
xpra/client/mixins/network_state.py
265 265 self.send_deflate_level() 266 266 267 267 def send_deflate_level(self): 268 self._protocol.set_compression_level(self.compression_level) 269 self.send("set_deflate", self.compression_level) 268 if self._protocol: 269 self._protocol.set_compression_level(self.compression_level) 270 self.send("set_deflate", self.compression_level) 270 271 271 272 272 273 def send_bandwidth_limit(self): -
xpra/client/tray_base.py
83 83 name = basename or self.default_icon_filename 84 84 f = get_icon_filename(name, self.default_icon_extension) 85 85 if not f: 86 import traceback 87 traceback.print_stack() 86 88 log.error("Error: cannot find icon '%s'", name) 87 89 return f 88 90 -
xpra/platform/dotxpra.py
9 9 import socket 10 10 import errno 11 11 import stat 12 import time 12 13 13 from xpra.os_util import get_util_logger, osexpand, umask_context 14 from xpra.os_util import get_util_logger, osexpand, umask_context, monotonic_time 14 15 from xpra.platform.dotxpra_common import PREFIX, LIVE, DEAD, UNKNOWN, INACCESSIBLE 15 16 from xpra.platform import platform_import 16 17 … … 75 76 def get_server_state(self, sockpath, timeout=5): 76 77 if not os.path.exists(sockpath): 77 78 return DotXpra.DEAD 78 sock = socket.socket(socket.AF_UNIX) 79 sock.settimeout(timeout) 79 state = DotXpra.UNKNOWN 80 80 try: 81 sock.connect(sockpath) 82 return DotXpra.LIVE 83 except socket.error as e: 84 debug("get_server_state: connect(%s)=%s (timeout=%s)", sockpath, e, timeout) 85 err = e.args[0] 86 if err==errno.EACCES: 87 return DotXpra.INACCESSIBLE 88 if err==errno.ECONNREFUSED: 89 #could be the server is starting up 90 debug("ECONNREFUSED") 91 return DotXpra.UNKNOWN 92 if err==errno.EWOULDBLOCK: 93 debug("EWOULDBLOCK") 94 return DotXpra.DEAD 95 if err==errno.ENOENT: 96 debug("ENOENT") 97 return DotXpra.DEAD 98 return self.UNKNOWN 81 start = monotonic_time() 82 while monotonic_time()-start<timeout: 83 try: 84 sock = socket.socket(socket.AF_UNIX) 85 sock.settimeout(timeout) 86 sock.connect(sockpath) 87 return DotXpra.LIVE 88 except socket.error as e: 89 debug("get_server_state: connect(%s)=%s (timeout=%s)", sockpath, e, timeout) 90 err = e.args[0] 91 if err==errno.EACCES: 92 return DotXpra.INACCESSIBLE 93 if err==errno.ECONNREFUSED: 94 #could be the server is starting up 95 debug("ECONNREFUSED") 96 state = DotXpra.UNKNOWN 97 time.sleep(0.1) 98 continue 99 if err==errno.EWOULDBLOCK: 100 debug("EWOULDBLOCK") 101 state = DotXpra.DEAD 102 time.sleep(0.1) 103 continue 104 if err==errno.ENOENT: 105 debug("ENOENT") 106 state = DotXpra.DEAD 107 time.sleep(0.1) 108 continue 109 return self.UNKNOWN 110 return state 99 111 finally: 100 112 try: 101 113 sock.close() -
xpra/scripts/main.py
147 147 148 148 def configure_logging(options, mode): 149 149 if mode in ( 150 "showconfig", "info", "id", "attach", "l auncher", "stop", "print",150 "showconfig", "info", "id", "attach", "listen", "launcher", "stop", "print", 151 151 "control", "list", "list-mdns", "sessions", "mdns-gui", "bug-report", 152 152 "opengl", "opengl-probe", "test-connect", 153 153 ): … … 171 171 setloghandler(logging.StreamHandler(to)) 172 172 if mode in ( 173 173 "start", "start-desktop", "upgrade", "upgrade-desktop", 174 "attach", " shadow", "proxy",174 "attach", "listen", "shadow", "proxy", 175 175 "_sound_record", "_sound_play", 176 176 "stop", "print", "showconfig", 177 177 "request-start", "request-start-desktop", "request-shadow", … … 178 178 "_dialog", "_pass", 179 179 ): 180 180 if "help" in options.speaker_codec or "help" in options.microphone_codec: 181 codec_help = show_sound_codec_help(mode!="attach", options.speaker_codec, options.microphone_codec) 181 server_mode = mode not in ("attach", "listen") 182 codec_help = show_sound_codec_help(server_mode, options.speaker_codec, options.microphone_codec) 182 183 raise InitInfo("\n".join(codec_help)) 183 184 fmt = LOG_FORMAT 184 185 if mode in ("stop", "showconfig"): … … 312 313 #sound commands don't want to set the name 313 314 #(they do it later to prevent glib import conflicts) 314 315 #"attach" does it when it received the session name from the server 315 if mode not in ("attach", " start", "start-desktop", "upgrade", "upgrade-desktop", "proxy", "shadow"):316 if mode not in ("attach", "listen", "start", "start-desktop", "upgrade", "upgrade-desktop", "proxy", "shadow"): 316 317 from xpra.platform import set_name 317 318 set_name("Xpra", "Xpra %s" % mode.strip("_")) 318 319 319 320 if mode in ( 320 321 "start", "start-desktop", 321 "shadow", "attach", 322 "shadow", "attach", "listen", 322 323 "request-start", "request-start-desktop", "request-shadow", 323 324 ): 324 325 options.encodings = validated_encodings(options.encodings) … … 427 428 add_when_ready(attach_client) 428 429 return run_server(error_cb, options, mode, script_file, args, current_display) 429 430 elif mode in ( 430 "attach", " detach",431 "attach", "listen", "detach", 431 432 "screenshot", "version", "info", "id", 432 433 "control", "_monitor", "top", "print", 433 434 "connect-test", "request-start", "request-start-desktop", "request-shadow", … … 1560 1561 app.start_child_new_commands = [] 1561 1562 app.start_new_commands = [] 1562 1563 try: 1563 conn, display_desc = connect() 1564 if mode=="listen": 1565 if extra_args: 1566 raise InitException("cannot specify extra arguments with 'listen' mode") 1567 display_desc = {} 1568 from xpra.platform import get_username 1569 from xpra.net.socket_util import ( 1570 get_network_logger, setup_local_sockets, 1571 create_sockets, add_listen_socket, accept_connection, 1572 ) 1573 netlog = get_network_logger() 1574 sockets = create_sockets(opts, error_cb) 1575 #we don't have a display, 1576 #so we can't automatically create sockets: 1577 if "auto" in opts.bind: 1578 opts.bind.remove("auto") 1579 local_sockets = setup_local_sockets(opts.bind, 1580 opts.socket_dir, opts.socket_dirs, 1581 None, False, 1582 opts.mmap_group, opts.socket_permissions, 1583 get_username(), getuid, getgid) 1584 sockets += local_sockets 1585 saved_send_hello = app.send_hello 1586 def new_connection(socktype, sock, *args): 1587 app.send_hello = saved_send_hello 1588 netlog.warn("new_connection%s", (socktype, sock, args)) 1589 conn = accept_connection(socktype, sock) 1590 netlog.warn("accept_connection(%s, %s)=%s", socktype, sock, conn) 1591 app.setup_connection(conn) 1592 netlog.warn("saved_send_hello=%s", saved_send_hello) 1593 protocol = app._protocol 1594 protocol.start() 1595 app.send_hello() 1596 saved_server_connection_established = app.server_connection_established 1597 def server_connection_established(): 1598 #TODO: close the other sockets and stop listening for new connections 1599 app.send_deflate_level() 1600 netlog.error("server_connection_established") 1601 return saved_server_connection_established() 1602 app.server_connection_established = server_connection_established 1603 for socktype, sock, info, cleanup_socket in sockets: 1604 add_listen_socket(socktype, sock, info, new_connection) 1605 def noop(*_args): 1606 pass 1607 app.send_hello = noop 1608 conn = None 1609 else: 1610 conn, display_desc = connect() 1564 1611 #UGLY warning: connect will parse the display string, 1565 1612 #which may change the username and password.. 1566 1613 app.username = opts.username … … 1567 1614 app.password = opts.password 1568 1615 app.display = opts.display 1569 1616 app.display_desc = display_desc 1570 app.setup_connection(conn) 1617 if conn: 1618 app.setup_connection(conn) 1571 1619 except Exception as e: 1572 1620 may_notify = getattr(app, "may_notify", None) 1573 1621 if may_notify: … … 2315 2363 try: 2316 2364 stat_info = os.stat(sockpath) 2317 2365 if stat_info.st_uid==getuid(): 2318 os.unlink(sockpath)2366 #os.unlink(sockpath) 2319 2367 sys.stdout.write(" (cleaned up)") 2368 import traceback 2369 traceback.print_stack() 2320 2370 except OSError as e: 2321 2371 sys.stdout.write(" (delete failed: %s)" % e) 2322 2372 sys.stdout.write("\n") -
xpra/server/mixins/audio_server.py
234 234 log.warn(" the private pulseaudio directory containing it will not be removed") 235 235 else: 236 236 pulse = os.path.join(self.pulseaudio_private_dir, "pulse") 237 #maybe remove this: 238 #dbus_socket = os.path.join(pulse, "dbus-1") 237 239 native = os.path.join(pulse, "native") 238 240 path = None 239 241 try: … … 253 255 soundlog.error(" found %i file%s in '%s':", len(files), engs(files), path) 254 256 for f in files: 255 257 soundlog.error(" - '%s'", f) 258 from subprocess import Popen, PIPE 259 import sys 260 Popen(["ls", "-laZ", os.path.join(path, f)], stdout=sys.stdout, stderr=sys.stderr) 261 Popen(["lsof", os.path.join(path, f)], stdout=sys.stdout, stderr=sys.stderr) 256 262 except OSError: 257 263 pass 258 264