aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAllan Stephens <allan.stephens@windriver.com>2006-06-26 02:46:50 -0400
committerDavid S. Miller <davem@davemloft.net>2006-06-26 02:46:50 -0400
commit1303e8f173a8a5000ee6e2fba876fec9474ed1f6 (patch)
tree1a4e21bce31d879f550d81fd88e5358ae2438248 /net
parentbdd94789d2348e20d13c1d5e477c8cf830dd204b (diff)
[TIPC]: Stream socket send indicates partial success if data partially sent.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com> Signed-off-by: Per Liden <per.liden@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/tipc/socket.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 9c834fc30112..8cefacb55aad 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -601,7 +601,8 @@ exit:
601 * 601 *
602 * Used for SOCK_STREAM data. 602 * Used for SOCK_STREAM data.
603 * 603 *
604 * Returns the number of bytes sent on success, or errno otherwise 604 * Returns the number of bytes sent on success (or partial success),
605 * or errno if no data sent
605 */ 606 */
606 607
607 608
@@ -615,6 +616,7 @@ static int send_stream(struct kiocb *iocb, struct socket *sock,
615 char __user *curr_start; 616 char __user *curr_start;
616 int curr_left; 617 int curr_left;
617 int bytes_to_send; 618 int bytes_to_send;
619 int bytes_sent;
618 int res; 620 int res;
619 621
620 if (likely(total_len <= TIPC_MAX_USER_MSG_SIZE)) 622 if (likely(total_len <= TIPC_MAX_USER_MSG_SIZE))
@@ -637,11 +639,11 @@ static int send_stream(struct kiocb *iocb, struct socket *sock,
637 * of small iovec entries into send_packet(). 639 * of small iovec entries into send_packet().
638 */ 640 */
639 641
640 my_msg = *m; 642 curr_iov = m->msg_iov;
641 curr_iov = my_msg.msg_iov; 643 curr_iovlen = m->msg_iovlen;
642 curr_iovlen = my_msg.msg_iovlen;
643 my_msg.msg_iov = &my_iov; 644 my_msg.msg_iov = &my_iov;
644 my_msg.msg_iovlen = 1; 645 my_msg.msg_iovlen = 1;
646 bytes_sent = 0;
645 647
646 while (curr_iovlen--) { 648 while (curr_iovlen--) {
647 curr_start = curr_iov->iov_base; 649 curr_start = curr_iov->iov_base;
@@ -652,16 +654,18 @@ static int send_stream(struct kiocb *iocb, struct socket *sock,
652 ? curr_left : TIPC_MAX_USER_MSG_SIZE; 654 ? curr_left : TIPC_MAX_USER_MSG_SIZE;
653 my_iov.iov_base = curr_start; 655 my_iov.iov_base = curr_start;
654 my_iov.iov_len = bytes_to_send; 656 my_iov.iov_len = bytes_to_send;
655 if ((res = send_packet(iocb, sock, &my_msg, 0)) < 0) 657 if ((res = send_packet(iocb, sock, &my_msg, 0)) < 0) {
656 return res; 658 return bytes_sent ? bytes_sent : res;
659 }
657 curr_left -= bytes_to_send; 660 curr_left -= bytes_to_send;
658 curr_start += bytes_to_send; 661 curr_start += bytes_to_send;
662 bytes_sent += bytes_to_send;
659 } 663 }
660 664
661 curr_iov++; 665 curr_iov++;
662 } 666 }
663 667
664 return total_len; 668 return bytes_sent;
665} 669}
666 670
667/** 671/**