[TCP] tcp_read_sock: Allow recv_actor() return return negative error value.
authorJens Axboe <jens.axboe@oracle.com>
Sun, 24 Jun 2007 06:07:50 +0000 (23:07 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sun, 24 Jun 2007 06:07:50 +0000 (23:07 -0700)
tcp_read_sock() currently assumes that the recv_actor() only returns
number of bytes copied. For network splice receive, we may have to
return an error in some cases. So allow the actor to return a negative
error value.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/tcp.c

index cd3c7e95de9e07296de8583fdc5b3df73aa45cdf..450f44bb2c8e6591b90e846a056dee2a04f8d40a 100644 (file)
@@ -1064,7 +1064,11 @@ int tcp_read_sock(struct sock *sk, read_descriptor_t *desc,
                                        break;
                        }
                        used = recv_actor(desc, skb, offset, len);
-                       if (used <= len) {
+                       if (used < 0) {
+                               if (!copied)
+                                       copied = used;
+                               break;
+                       } else if (used <= len) {
                                seq += used;
                                copied += used;
                                offset += used;
@@ -1086,7 +1090,7 @@ int tcp_read_sock(struct sock *sk, read_descriptor_t *desc,
        tcp_rcv_space_adjust(sk);
 
        /* Clean up data we have read: This will do ACK frames. */
-       if (copied)
+       if (copied > 0)
                tcp_cleanup_rbuf(sk, copied);
        return copied;
 }