This field contains optimization flags (ie. MSG_MORE) which are passed through to the socket layer if it supports them. The flags are reset automatically when we move to another state. --- generator/states.c | 6 ++++-- lib/internal.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/generator/states.c b/generator/states.c index e879a83..36cca37 100644 --- a/generator/states.c +++ b/generator/states.c @@ -92,7 +92,7 @@ send_from_wbuf (struct nbd_handle *h) if (h->wlen == 0) return 0; /* move to next state */ - r = h->sock->ops->send (h, h->sock, h->wbuf, h->wlen, 0); + r = h->sock->ops->send (h, h->sock, h->wbuf, h->wlen, h->wflags); if (r == -1) { if (errno == EAGAIN || errno == EWOULDBLOCK) return 1; /* more data */ @@ -101,8 +101,10 @@ send_from_wbuf (struct nbd_handle *h) } h->wbuf += r; h->wlen -= r; - if (h->wlen == 0) + if (h->wlen == 0) { + h->wflags = 0; /* reset this when moving to next state */ return 0; /* move to next state */ + } else return 1; /* more data */ } diff --git a/lib/internal.h b/lib/internal.h index 1ffb5b7..e7be05b 100644 --- a/lib/internal.h +++ b/lib/internal.h @@ -110,6 +110,7 @@ struct nbd_handle { /* As above, but for writing using send_from_wbuf. */ const void *wbuf; size_t wlen; + int wflags; /* Static buffer used for short amounts of data, such as handshake * and commands. -- 2.21.0