xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #2587: peekable-v2.patch

File peekable-v2.patch, 1.6 KB (added by Antoine Martin, 6 months ago)

updated patch

  • xpra/net/socket_util.py

     
    1313    EXIT_SSL_FAILURE, EXIT_SSL_CERTIFICATE_VERIFY_FAILURE,
    1414    EXIT_SERVER_ALREADY_EXISTS, EXIT_SOCKET_CREATION_ERROR,
    1515    )
     16from xpra.net.bytestreams import PeekableSocketConnection
    1617from xpra.os_util import (
    1718    getuid, get_username_for_uid, get_groups, get_group_id,
    1819    path_permission_info, monotonic_time, umask_context, WIN32, OSX, POSIX,
     
    174175        peername = address
    175176    sock.settimeout(timeout)
    176177    sockname = sock.getsockname()
    177     from xpra.net.bytestreams import SocketConnection
    178     conn = SocketConnection(sock, sockname, address, peername, socktype, None, socket_options)
     178    conn = PeekableSocketConnection(sock, sockname, address, peername, socktype, None, socket_options)
    179179    log("accept_connection(%s, %s, %s)=%s", listener, socktype, timeout, conn)
    180180    return conn
    181181
     
    198198        sleep(timeout/4000.0)
    199199        elapsed = int(1000*(monotonic_time()-start))
    200200        log("peek: elapsed=%s, timeout=%s", elapsed, timeout)
    201     log("socket %s peek: got %i bytes", conn, len(peek_data))
     201    if not peek_data and isinstance(conn, PeekableSocketConnection):
     202        conn.enable_peek()
     203        try:
     204            peek_data = conn.peek(size)
     205        except Exception:
     206            log("peek_connection(%s, %i) failed", conn, timeout, exc_info=True)
     207    log.info("socket %s peek: got %i bytes (%s)", conn, len(peek_data), type(conn))
    202208    return peek_data
    203209
    204210