Skip to content
  • Jakub Janků's avatar
    webdav: don't buffer input from phodav · 9f5aee05
    Jakub Janků authored and Frediano Ziglio's avatar Frediano Ziglio committed
    
    
    The current approach with OutputQueue in webdav has several problems:
    
    * if the connection is slow, webdav keeps reading from phodav
    and pushing messages to the internal channel xmit_queue.
    This way, the queue can grow very quickly and the whole file
    that is being transferred using webdav essentially gets loaded into memory.
    
    * spice channel first flushes all messages in the xmit_queue and
    then proceeds to reading. If webdav floods the xmit_queue with
    a ton of messages, spice channel does not leave iterate_write until
    the queue gets empty. This way, reading from the channel is blocked
    till the whole file is transferred.
    
    * OutputQueue uses g_output_stream_flush_async() on SpiceVmcOutputStream
    that does not implement flush
    
    To solve these issues, don't read from phodav until the last message
    for a given client is written out to the socket.
    (main channel currently uses the same approach when transferring files)
    
    OutputQueue used an idle function to schedule the write and then
    called mux_pushed_cb which started reading from phodav with priority
    G_PRIORITY_DEFAULT.
    Since this new approach does not utilize the idle scheduling,
    lower the priority in client_start_read() to G_PRIORITY_DEFAULT_IDLE
    to make sure other sources with lower priority get dispatched as well
    (e.g. signals from coroutines, redrawing and resizing operations).
    
    Also implement spice_webdav_channel_reset(). This is necessary because
    spice_vmc_write_async() references the channel. If the channel is to be
    disconnected, the write operations need to be cancelled so that
    the references to the channel are released asap. Otherwise,
    spice session would be stuck waiting for the channel to finalize.
    
    Signed-off-by: default avatarJakub Janků <jjanku@redhat.com>
    Acked-by: default avatarFrediano Ziglio <fziglio@redhat.com>
    9f5aee05