<div dir="ltr">Hi,<br><div class="gmail_extra"><br><div class="gmail_quote">2017-03-24 4:57 GMT+00:00 Andrei Vagin <span dir="ltr"><<a href="mailto:avagin@virtuozzo.com" target="_blank">avagin@virtuozzo.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">On Sun, Mar 19, 2017 at 09:55:23PM +0000, rodrigo-bruno wrote:<br>
> Signed-off-by: rodrigo-bruno <<a href="mailto:rbruno@gsd.inesc-id.pt">rbruno@gsd.inesc-id.pt</a>><br>
> ---<br>
> criu/img-remote-proto.c | 2 +-<br>
> 1 file changed, 1 insertion(+), 1 deletion(-)<br>
><br>
> diff --git a/criu/img-remote-proto.c b/criu/img-remote-proto.c<br>
> index 3751b6f..51584bb 100644<br>
> --- a/criu/img-remote-proto.c<br>
> +++ b/criu/img-remote-proto.c<br>
> @@ -743,7 +743,7 @@ int64_t send_image(int fd, struct rimage *rimg, int flags, bool close_fd)<br>
> } else if (rimg->curr_sent_bytes == rimg->curr_sent_buf->nbytes) {<br>
> if (close_fd)<br>
> close(fd);<br>
> - return nblocks*BUF_SIZE + rimg->curr_sent_buf->nbytes;<br>
> + return ((int64_t)nblocks*BUF_SIZE) + rimg->curr_sent_buf->nbytes;<br>
<br>
</span>I'm not sure that I understand the logic of this function. For me it<br>
looks incorrect.<br>
<br>
The first thing is that I don't understand why you need to spit data to<br>
blocks.<br></blockquote><div><br></div><div>Data is split into blocks because the image proxy does not know the size of the image beforehand.</div><div>I.e., CRIU dump operation will open several images and will write directly to the proxy (through a UNIX</div><div>socket). If we are able to know, upon image opening, how much data we CRIU dump will need, them</div><div>we can avoid blocks. </div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
The second thing is that I think the following line is incorrect:<br>
<br>
min(BUF_SIZE, rimg->curr_sent_buf->nbytes) - rimg->curr_sent_bytes,<br>
<br>
nbytes is a constant in this function and it should be incorrect if<br>
nbytes is greater than BUF_SIZE and it isn't multiple to BUF_SIZE.<br>
<span class="gmail-"><br></span></blockquote><div><br></div><div>nbytes is the number of bytes that are being used in a block.</div><div>BUF_SIZE is the maximum number of used bytes in a block.</div><div>curr_sent_bytes is the number of bytes sent from the current block.</div><div><br></div><div>To send an image, we iterate through all blocks, sending one at a time.</div><div><br></div><div>min(BUF_SIZE, rimg->curr_sent_buf->nbytes) -> tells us how many bytes are being used in the block.<br></div><div><br></div><div>min(BUF_SIZE, rimg->curr_sent_buf->nbytes) - rimg->curr_sent_bytes -> tells us how many used bytes</div><div>still need to be sent.</div><div><br></div><div>Addressing your question: by design, nbytes should never be greater than BUF_SIZE (unless </div><div>there is a bug...). Is should always be true that nbytes <= BUF_SIZE.</div><div><br></div><div>Nevertheless, I'm open to suggestions to improve the code/design of the function :-)</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">
> }<br>
> } else if (errno == EPIPE || errno == ECONNRESET) {<br>
> pr_warn("Connection for %s:%s was closed early than expected\n",<br>
> --<br>
> 2.1.4<br>
><br>
</span>> ______________________________<wbr>_________________<br>
> CRIU mailing list<br>
> <a href="mailto:CRIU@openvz.org">CRIU@openvz.org</a><br>
> <a href="https://lists.openvz.org/mailman/listinfo/criu" rel="noreferrer" target="_blank">https://lists.openvz.org/<wbr>mailman/listinfo/criu</a><br>
</blockquote></div><br></div></div>