First step towards parallel transmit in UDP: if neither a specific

source or a specific destination address is requested as part of a send
on a UDP socket, read lock the inpcb rather than write lock it.  This
will allow fully parallel transmit down to the IP layer when sending
simultaneously from multiple threads on a connected UDP socket.

Parallel transmit for more complex cases, such as when sendto(2) is
invoked with an address and there's already a local binding, will
follow.

MFC after:	1 month
This commit is contained in:
Robert Watson 2008-07-07 10:56:55 +00:00
parent 65c577c01d
commit 948d0fc926
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=180344

View File

@ -841,10 +841,12 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr,
if (src.sin_family == AF_INET || addr != NULL) {
INP_INFO_WLOCK(&udbinfo);
INP_WLOCK(inp);
unlock_udbinfo = 1;
} else
} else {
unlock_udbinfo = 0;
INP_WLOCK(inp);
INP_RLOCK(inp);
}
#ifdef MAC
mac_inpcb_create_mbuf(inp, m);
@ -975,13 +977,18 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr,
INP_INFO_WUNLOCK(&udbinfo);
error = ip_output(m, inp->inp_options, NULL, ipflags,
inp->inp_moptions, inp);
INP_WUNLOCK(inp);
if (unlock_udbinfo)
INP_WUNLOCK(inp);
else
INP_RUNLOCK(inp);
return (error);
release:
INP_WUNLOCK(inp);
if (unlock_udbinfo)
if (unlock_udbinfo) {
INP_INFO_WUNLOCK(&udbinfo);
INP_WUNLOCK(inp);
} else
INP_RUNLOCK(inp);
m_freem(m);
return (error);
}