• D
    Fix tracking of RPC messages wrt streams · b3fb288e
    Daniel P. Berrange 提交于
    Commit 2c85644b attempted to
    fix a problem with tracking RPC messages from streams by doing
    
    -            if (msg->header.type == VIR_NET_REPLY) {
    +            if (msg->header.type == VIR_NET_REPLY ||
    +                (msg->header.type == VIR_NET_STREAM &&
    +                 msg->header.status != VIR_NET_CONTINUE)) {
                     client->nrequests--;
    
    In other words any stream packet, with status NET_OK or NET_ERROR
    would cause nrequests to be decremented. This is great if the
    packet from from a synchronous virStreamFinish or virStreamAbort
    API call, but wildly wrong if from a server initiated abort.
    The latter resulted in 'nrequests' being decremented below zero.
    This then causes all I/O for that client to be stopped.
    
    Instead of trying to infer whether we need to decrement the
    nrequests field, from the message type/status, introduce an
    explicit 'bool tracked' field to mark whether the virNetMessagePtr
    object is subject to tracking.
    
    Also add a virNetMessageClear function to allow a message
    contents to be cleared out, without adversely impacting the
    'tracked' field as a naive memset() would do
    
    * src/rpc/virnetmessage.c, src/rpc/virnetmessage.h: Add
      a 'bool tracked' field and virNetMessageClear() API
    * daemon/remote.c, daemon/stream.c, src/rpc/virnetclientprogram.c,
      src/rpc/virnetclientstream.c, src/rpc/virnetserverclient.c,
      src/rpc/virnetserverprogram.c: Switch over to use
      virNetMessageClear() and pass in the 'bool tracked' value
      when creating messages.
    b3fb288e
virnetclientprogram.c 9.5 KB