version 1.64, 2002/05/02 17:55:51 |
version 1.66.4.2, 2002/11/08 09:31:35 |
|
|
} |
} |
|
|
#ifdef SOSEND_LOAN |
#ifdef SOSEND_LOAN |
|
int use_sosend_loan = 1; |
|
#else |
|
int use_sosend_loan = 0; |
|
#endif |
|
|
struct mbuf *so_pendfree; |
struct mbuf *so_pendfree; |
|
|
Line 303 sosend_loan(struct socket *so, struct ui |
|
Line 307 sosend_loan(struct socket *so, struct ui |
|
return (space); |
return (space); |
} |
} |
|
|
#endif /* SOSEND_LOAN */ |
|
|
|
/* |
/* |
* Socket operation routines. |
* Socket operation routines. |
* These routines are called by the routines in |
* These routines are called by the routines in |
Line 390 solisten(struct socket *so, int backlog) |
|
Line 392 solisten(struct socket *so, int backlog) |
|
void |
void |
sofree(struct socket *so) |
sofree(struct socket *so) |
{ |
{ |
#ifdef SOSEND_LOAN |
|
struct mbuf *m; |
struct mbuf *m; |
#endif |
|
|
|
if (so->so_pcb || (so->so_state & SS_NOFDREF) == 0) |
if (so->so_pcb || (so->so_state & SS_NOFDREF) == 0) |
return; |
return; |
Line 407 sofree(struct socket *so) |
|
Line 407 sofree(struct socket *so) |
|
} |
} |
sbrelease(&so->so_snd); |
sbrelease(&so->so_snd); |
sorflush(so); |
sorflush(so); |
#ifdef SOSEND_LOAN |
|
while ((m = so->so_pendfree) != NULL) { |
while ((m = so->so_pendfree) != NULL) { |
so->so_pendfree = m->m_next; |
so->so_pendfree = m->m_next; |
m->m_next = so_pendfree; |
m->m_next = so_pendfree; |
so_pendfree = m; |
so_pendfree = m; |
} |
} |
#endif |
|
pool_put(&socket_pool, so); |
pool_put(&socket_pool, so); |
} |
} |
|
|
Line 569 sodisconnect(struct socket *so) |
|
Line 567 sodisconnect(struct socket *so) |
|
(struct proc *)0); |
(struct proc *)0); |
bad: |
bad: |
splx(s); |
splx(s); |
#ifdef SOSEND_LOAN |
|
sodopendfree(so); |
sodopendfree(so); |
#endif |
|
return (error); |
return (error); |
} |
} |
|
|
Line 602 sosend(struct socket *so, struct mbuf *a |
|
Line 598 sosend(struct socket *so, struct mbuf *a |
|
long space, len, resid, clen, mlen; |
long space, len, resid, clen, mlen; |
int error, s, dontroute, atomic; |
int error, s, dontroute, atomic; |
|
|
#ifdef SOSEND_LOAN |
|
sodopendfree(so); |
sodopendfree(so); |
#endif |
|
|
|
p = curproc; /* XXX */ |
p = curproc; /* XXX */ |
clen = 0; |
clen = 0; |
Line 691 sosend(struct socket *so, struct mbuf *a |
|
Line 685 sosend(struct socket *so, struct mbuf *a |
|
MGET(m, M_WAIT, MT_DATA); |
MGET(m, M_WAIT, MT_DATA); |
mlen = MLEN; |
mlen = MLEN; |
} |
} |
#ifdef SOSEND_LOAN |
if (use_sosend_loan && |
if (uio->uio_iov->iov_len >= SOCK_LOAN_THRESH && |
uio->uio_iov->iov_len >= SOCK_LOAN_THRESH && |
space >= SOCK_LOAN_THRESH && |
space >= SOCK_LOAN_THRESH && |
(len = sosend_loan(so, uio, m, |
(len = sosend_loan(so, uio, m, |
space)) != 0) { |
space)) != 0) { |
Line 700 sosend(struct socket *so, struct mbuf *a |
|
Line 694 sosend(struct socket *so, struct mbuf *a |
|
space -= len; |
space -= len; |
goto have_data; |
goto have_data; |
} |
} |
#endif /* SOSEND_LOAN */ |
|
if (resid >= MINCLSIZE && space >= MCLBYTES) { |
if (resid >= MINCLSIZE && space >= MCLBYTES) { |
SOSEND_COUNTER_INCR(&sosend_copy_big); |
SOSEND_COUNTER_INCR(&sosend_copy_big); |
MCLGET(m, M_WAIT); |
MCLGET(m, M_WAIT); |
Line 728 sosend(struct socket *so, struct mbuf *a |
|
Line 721 sosend(struct socket *so, struct mbuf *a |
|
} |
} |
error = uiomove(mtod(m, caddr_t), (int)len, |
error = uiomove(mtod(m, caddr_t), (int)len, |
uio); |
uio); |
#ifdef SOSEND_LOAN |
|
have_data: |
have_data: |
#endif |
|
resid = uio->uio_resid; |
resid = uio->uio_resid; |
m->m_len = len; |
m->m_len = len; |
*mp = m; |
*mp = m; |
Line 806 soreceive(struct socket *so, struct mbuf |
|
Line 797 soreceive(struct socket *so, struct mbuf |
|
int flags, len, error, s, offset, moff, type, orig_resid; |
int flags, len, error, s, offset, moff, type, orig_resid; |
struct protosw *pr; |
struct protosw *pr; |
struct mbuf *nextrecord; |
struct mbuf *nextrecord; |
|
int mbuf_removed = 0; |
#ifdef SOSEND_LOAN |
|
sodopendfree(so); |
|
#endif |
|
|
|
pr = so->so_proto; |
pr = so->so_proto; |
mp = mp0; |
mp = mp0; |
Line 823 soreceive(struct socket *so, struct mbuf |
|
Line 811 soreceive(struct socket *so, struct mbuf |
|
flags = *flagsp &~ MSG_EOR; |
flags = *flagsp &~ MSG_EOR; |
else |
else |
flags = 0; |
flags = 0; |
|
|
|
if ((flags & MSG_DONTWAIT) == 0) |
|
sodopendfree(so); |
|
|
if (flags & MSG_OOB) { |
if (flags & MSG_OOB) { |
m = m_get(M_WAIT, MT_DATA); |
m = m_get(M_WAIT, MT_DATA); |
error = (*pr->pr_usrreq)(so, PRU_RCVOOB, m, |
error = (*pr->pr_usrreq)(so, PRU_RCVOOB, m, |
Line 927 soreceive(struct socket *so, struct mbuf |
|
Line 919 soreceive(struct socket *so, struct mbuf |
|
m = m->m_next; |
m = m->m_next; |
} else { |
} else { |
sbfree(&so->so_rcv, m); |
sbfree(&so->so_rcv, m); |
|
mbuf_removed = 1; |
if (paddr) { |
if (paddr) { |
*paddr = m; |
*paddr = m; |
so->so_rcv.sb_mb = m->m_next; |
so->so_rcv.sb_mb = m->m_next; |
Line 945 soreceive(struct socket *so, struct mbuf |
|
Line 938 soreceive(struct socket *so, struct mbuf |
|
m = m->m_next; |
m = m->m_next; |
} else { |
} else { |
sbfree(&so->so_rcv, m); |
sbfree(&so->so_rcv, m); |
|
mbuf_removed = 1; |
if (controlp) { |
if (controlp) { |
if (pr->pr_domain->dom_externalize && |
if (pr->pr_domain->dom_externalize && |
mtod(m, struct cmsghdr *)->cmsg_type == |
mtod(m, struct cmsghdr *)->cmsg_type == |
Line 1001 soreceive(struct socket *so, struct mbuf |
|
Line 995 soreceive(struct socket *so, struct mbuf |
|
splx(s); |
splx(s); |
error = uiomove(mtod(m, caddr_t) + moff, (int)len, uio); |
error = uiomove(mtod(m, caddr_t) + moff, (int)len, uio); |
s = splsoftnet(); |
s = splsoftnet(); |
if (error) |
if (error) { |
|
/* |
|
* If any part of the record has been removed |
|
* (such as the MT_SONAME mbuf, which will |
|
* happen when PR_ADDR, and thus also |
|
* PR_ATOMIC, is set), then drop the entire |
|
* record to maintain the atomicity of the |
|
* receive operation. |
|
* |
|
* This avoids a later panic("receive 1a") |
|
* when compiled with DIAGNOSTIC. |
|
*/ |
|
if (m && mbuf_removed |
|
&& (pr->pr_flags & PR_ATOMIC)) |
|
(void) sbdroprecord(&so->so_rcv); |
|
|
goto release; |
goto release; |
|
} |
} else |
} else |
uio->uio_resid -= len; |
uio->uio_resid -= len; |
if (len == m->m_len - moff) { |
if (len == m->m_len - moff) { |
Line 1063 soreceive(struct socket *so, struct mbuf |
|
Line 1073 soreceive(struct socket *so, struct mbuf |
|
!sosendallatonce(so) && !nextrecord) { |
!sosendallatonce(so) && !nextrecord) { |
if (so->so_error || so->so_state & SS_CANTRCVMORE) |
if (so->so_error || so->so_state & SS_CANTRCVMORE) |
break; |
break; |
|
/* |
|
* If we are peeking and the socket receive buffer is |
|
* full, stop since we can't get more data to peek at. |
|
*/ |
|
if ((flags & MSG_PEEK) && sbspace(&so->so_rcv) <= 0) |
|
break; |
|
/* |
|
* If we've drained the socket buffer, tell the |
|
* protocol in case it needs to do something to |
|
* get it filled again. |
|
*/ |
|
if ((pr->pr_flags & PR_WANTRCVD) && so->so_pcb) |
|
(*pr->pr_usrreq)(so, PRU_RCVD, |
|
(struct mbuf *)0, |
|
(struct mbuf *)(long)flags, |
|
(struct mbuf *)0, |
|
(struct proc *)0); |
error = sbwait(&so->so_rcv); |
error = sbwait(&so->so_rcv); |
if (error) { |
if (error) { |
sbunlock(&so->so_rcv); |
sbunlock(&so->so_rcv); |