drbd: Add drbd_recv_all(): Receive an entire buffer
authorAndreas Gruenbacher <agruen@linbit.com>
Thu, 17 Mar 2011 16:15:20 +0000 (17:15 +0100)
committerPhilipp Reisner <philipp.reisner@linbit.com>
Thu, 8 Nov 2012 15:44:47 +0000 (16:44 +0100)
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
drivers/block/drbd/drbd_receiver.c

index 28980145b92c8feaa349793f7eb1c9489ccc1cb5..880634264e96d3fa15e1d84d4a90f667f8896ec2 100644 (file)
@@ -565,6 +565,19 @@ static int drbd_recv(struct drbd_tconn *tconn, void *buf, size_t size)
        return rv;
 }
 
+static int drbd_recv_all(struct drbd_tconn *tconn, void *buf, size_t size)
+{
+       int err;
+
+       err = drbd_recv(tconn, buf, size);
+       if (err != size) {
+               if (err >= 0)
+                       err = -EIO;
+       } else
+               err = 0;
+       return err;
+}
+
 /* quoting tcp(7):
  *   On individual connections, the socket buffer size must be set prior to the
  *   listen(2) or connect(2) calls in order to have it take effect.