[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH 2/4] Add a "confirm_read" call



From: Wouter Verhelst <w@uter.be>

This doesn't currently do anything, but we call it when the buffer is
ready to be sent out, so that when we get to structured replies, we can
optionally send out our buffer there.

Signed-off-by: Wouter Verhelst <w@uter.be>
---
 nbd-server.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/nbd-server.c b/nbd-server.c
index 3bfa857..64609f3 100644
--- a/nbd-server.c
+++ b/nbd-server.c
@@ -1301,6 +1301,9 @@ char * find_read_buf(READ_CTX *ctx) {
 	return ctx->buf + ctx->current_offset;
 }
 
+void confirm_read(CLIENT *client, READ_CTX *ctx, size_t len_read) {
+}
+
 void complete_read(CLIENT *client, READ_CTX *ctx, uint32_t error, char *errmsg, uint16_t msglen, bool with_offset, uint64_t err_offset) {
 	uint16_t type;
 	uint64_t offset = 0;
@@ -1364,6 +1367,7 @@ int rawexpread_fully(READ_CTX *ctx, CLIENT *client) {
 		if((ret = rawexpread((off_t)ctx->req->from + (off_t)ctx->current_offset, buf, ctx->current_len, client)) < 0) {
 			return ret;
 		}
+		confirm_read(client, ctx, ret);
 		ctx->current_offset += ret;
 		ctx->current_len -= ret;
 	}
@@ -1470,6 +1474,7 @@ int expread(READ_CTX *ctx, CLIENT *client) {
 			if (pread(client->difffile, buf, rdlen, client->difmap[mapcnt]*DIFFPAGESIZE+offset) != rdlen) {
 				goto fail;
 			}
+			confirm_read(client, ctx, rdlen);
 		} else { /* the block is not there */
 			if ((client->server->flags & F_WAIT) && (client->export == NULL)){
 				DEBUG("Page %llu is not here, and waiting for file\n",
-- 
2.39.2


Reply to: