提交 470aaa20 编写于 作者: M Michal Privoznik

daemon: Implement VIR_NET_STREAM_HOLE handling

Basically, whenever the new type of stream packet arrives to the
daemon call this function that decodes it and calls
virStreamSendHole(). Otherwise a regular data stream packet has
arrived and therefore continue its processing.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 87f2a5c6
......@@ -653,6 +653,52 @@ daemonStreamHandleAbort(virNetServerClientPtr client,
}
static int
daemonStreamHandleHole(virNetServerClientPtr client,
daemonClientStream *stream,
virNetMessagePtr msg)
{
int ret;
virNetStreamHole data;
VIR_DEBUG("client=%p, stream=%p, proc=%d, serial=%u",
client, stream, msg->header.proc, msg->header.serial);
/* Let's check if client plays nicely and advertised usage of
* sparse stream upfront. */
if (!stream->allowSkip) {
virReportError(VIR_ERR_RPC, "%s",
_("Unexpected stream hole"));
return -1;
}
if (virNetMessageDecodePayload(msg,
(xdrproc_t) xdr_virNetStreamHole,
&data) < 0)
return -1;
ret = virStreamSendHole(stream->st, data.length, data.flags);
if (ret < 0) {
virNetMessageError rerr;
memset(&rerr, 0, sizeof(rerr));
VIR_INFO("Stream send hole failed");
stream->closed = true;
virStreamEventRemoveCallback(stream->st);
virStreamAbort(stream->st);
return virNetServerProgramSendReplyError(stream->prog,
client,
msg,
&rerr,
&msg->header);
}
return 0;
}
/*
* Called when the stream is signalled has being able to accept
......@@ -671,6 +717,12 @@ daemonStreamHandleWrite(virNetServerClientPtr client,
virNetMessagePtr msg = stream->rx;
int ret;
if (msg->header.type == VIR_NET_STREAM_HOLE) {
/* Handle special case when the client sent us a hole.
* Otherwise just carry on with processing stream
* data. */
ret = daemonStreamHandleHole(client, stream, msg);
} else if (msg->header.type == VIR_NET_STREAM) {
switch (msg->header.status) {
case VIR_NET_OK:
ret = daemonStreamHandleFinish(client, stream, msg);
......@@ -685,6 +737,12 @@ daemonStreamHandleWrite(virNetServerClientPtr client,
ret = daemonStreamHandleAbort(client, stream, msg);
break;
}
} else {
virReportError(VIR_ERR_RPC,
_("Unexpected message type: %d"),
msg->header.type);
ret = -1;
}
if (ret > 0)
break; /* still processing data from msg */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册