Skip to content

Commit

Permalink
net/socket.c : introduce helper function do_sock_sendmsg to replace r…
Browse files Browse the repository at this point in the history
…eduplicate code

Introduce helper function do_sock_sendmsg() to simplify sock_sendmsg{_nosec},
and replace reduplicate code.

Signed-off-by: Gu Zheng <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Gu Zheng authored and davem330 committed Dec 9, 2014
1 parent 42eef7a commit 0cf00c6
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions net/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,33 +651,31 @@ static inline int __sock_sendmsg(struct kiocb *iocb, struct socket *sock,
return err ?: __sock_sendmsg_nosec(iocb, sock, msg, size);
}

int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
static int do_sock_sendmsg(struct socket *sock, struct msghdr *msg,
size_t size, bool nosec)
{
struct kiocb iocb;
struct sock_iocb siocb;
int ret;

init_sync_kiocb(&iocb, NULL);
iocb.private = &siocb;
ret = __sock_sendmsg(&iocb, sock, msg, size);
ret = nosec ? __sock_sendmsg_nosec(&iocb, sock, msg, size) :
__sock_sendmsg(&iocb, sock, msg, size);
if (-EIOCBQUEUED == ret)
ret = wait_on_sync_kiocb(&iocb);
return ret;
}

int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
{
return do_sock_sendmsg(sock, msg, size, false);
}
EXPORT_SYMBOL(sock_sendmsg);

static int sock_sendmsg_nosec(struct socket *sock, struct msghdr *msg, size_t size)
{
struct kiocb iocb;
struct sock_iocb siocb;
int ret;

init_sync_kiocb(&iocb, NULL);
iocb.private = &siocb;
ret = __sock_sendmsg_nosec(&iocb, sock, msg, size);
if (-EIOCBQUEUED == ret)
ret = wait_on_sync_kiocb(&iocb);
return ret;
return do_sock_sendmsg(sock, msg, size, true);
}

int kernel_sendmsg(struct socket *sock, struct msghdr *msg,
Expand Down

0 comments on commit 0cf00c6

Please sign in to comment.