Increase the coverage scope of the receive socket buffer lock in

spx_reass() to increase atomicity across multiple operations on the
socket buffer when iterating over the SPX fragment reassembly list
for the ipxpcb, as well a to reduce the number of locking operations.
This commit is contained in:
Robert Watson 2005-01-02 15:36:16 +00:00
parent 97270cf1b6
commit 19e2d43969
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=139590

View File

@ -591,6 +591,7 @@ register struct spx *si;
}
present:
#define SPINC sizeof(struct spxhdr)
SOCKBUF_LOCK(&so->so_rcv);
/*
* Loop through all packets queued up to update acknowledge
* number, and present all acknowledged data to user;
@ -602,12 +603,10 @@ register struct spx *si;
m = dtom(q);
if (SI(q)->si_cc & SPX_OB) {
cb->s_oobflags &= ~SF_IOOB;
SOCKBUF_LOCK(&so->so_rcv);
if (so->so_rcv.sb_cc)
so->so_oobmark = so->so_rcv.sb_cc;
else
so->so_rcv.sb_state |= SBS_RCVATMARK;
SOCKBUF_UNLOCK(&so->so_rcv);
}
q = q->si_prev;
remque(q->si_next);
@ -630,16 +629,14 @@ register struct spx *si;
s[0] = 5;
s[1] = 1;
*(u_char *)(&s[2]) = dt;
sbappend(&so->so_rcv, mm);
sbappend_locked(&so->so_rcv, mm);
}
}
if (sp->spx_cc & SPX_OB) {
MCHTYPE(m, MT_OOBDATA);
spx_newchecks[1]++;
SOCKBUF_LOCK(&so->so_rcv);
so->so_oobmark = 0;
so->so_rcv.sb_state &= ~SBS_RCVATMARK;
SOCKBUF_UNLOCK(&so->so_rcv);
}
if (packetp == 0) {
m->m_data += SPINC;
@ -647,26 +644,28 @@ register struct spx *si;
m->m_pkthdr.len -= SPINC;
}
if ((sp->spx_cc & SPX_EM) || packetp) {
sbappendrecord(&so->so_rcv, m);
sbappendrecord_locked(&so->so_rcv, m);
spx_newchecks[9]++;
} else
sbappend(&so->so_rcv, m);
sbappend_locked(&so->so_rcv, m);
} else
#endif
if (packetp) {
sbappendrecord(&so->so_rcv, m);
sbappendrecord_locked(&so->so_rcv, m);
} else {
cb->s_rhdr = *mtod(m, struct spxhdr *);
m->m_data += SPINC;
m->m_len -= SPINC;
m->m_pkthdr.len -= SPINC;
sbappend(&so->so_rcv, m);
sbappend_locked(&so->so_rcv, m);
}
} else
break;
}
if (wakeup)
sorwakeup(so);
sorwakeup_locked(so);
else
SOCKBUF_UNLOCK(&so->so_rcv);
return (0);
}