summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_socket.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2004-06-14 18:16:22 +0000
committerrwatson <rwatson@FreeBSD.org>2004-06-14 18:16:22 +0000
commitf2c0db1521299639d6b16b7d477a777fbd81ada6 (patch)
tree38ab74987dd7d2d27fad4ea4e4772c7d36baf7d4 /sys/kern/uipc_socket.c
parent1598e7b4234febacb1b16af62169c90a2e93cc6b (diff)
downloadFreeBSD-src-f2c0db1521299639d6b16b7d477a777fbd81ada6.zip
FreeBSD-src-f2c0db1521299639d6b16b7d477a777fbd81ada6.tar.gz
The socket field so_state is used to hold a variety of socket related
flags relating to several aspects of socket functionality. This change breaks out several bits relating to send and receive operation into a new per-socket buffer field, sb_state, in order to facilitate locking. This is required because, in order to provide more granular locking of sockets, different state fields have different locking properties. The following fields are moved to sb_state: SS_CANTRCVMORE (so_state) SS_CANTSENDMORE (so_state) SS_RCVATMARK (so_state) Rename respectively to: SBS_CANTRCVMORE (so_rcv.sb_state) SBS_CANTSENDMORE (so_snd.sb_state) SBS_RCVATMARK (so_rcv.sb_state) This facilitates locking by isolating fields to be located with other identically locked fields, and permits greater granularity in socket locking by avoiding storing fields with different locking semantics in the same short (avoiding locking conflicts). In the future, we may wish to coallesce sb_state and sb_flags; for the time being I leave them separate and there is no additional memory overhead due to the packing/alignment of shorts in the socket buffer structure.
Diffstat (limited to 'sys/kern/uipc_socket.c')
-rw-r--r--sys/kern/uipc_socket.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 145a5a6..fb9043c 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -608,7 +608,7 @@ restart:
goto out;
do {
s = splnet();
- if (so->so_state & SS_CANTSENDMORE)
+ if (so->so_snd.sb_state & SBS_CANTSENDMORE)
snderr(EPIPE);
if (so->so_error) {
error = so->so_error;
@@ -758,7 +758,7 @@ restart:
so->so_options |= SO_DONTROUTE;
s = splnet(); /* XXX */
/*
- * XXX all the SS_CANTSENDMORE checks previously
+ * XXX all the SBS_CANTSENDMORE checks previously
* done could be out of date. We could have recieved
* a reset packet in an interrupt or maybe we slept
* while doing page faults in uiomove() etc. We could
@@ -920,7 +920,7 @@ restart:
so->so_error = 0;
goto release;
}
- if (so->so_state & SS_CANTRCVMORE) {
+ if (so->so_rcv.sb_state & SBS_CANTRCVMORE) {
if (m)
goto dontblock;
else
@@ -1035,7 +1035,7 @@ dontblock:
else
KASSERT(m->m_type == MT_DATA || m->m_type == MT_HEADER,
("m->m_type == %d", m->m_type));
- so->so_state &= ~SS_RCVATMARK;
+ so->so_rcv.sb_state &= ~SBS_RCVATMARK;
len = uio->uio_resid;
if (so->so_oobmark && len > so->so_oobmark - offset)
len = so->so_oobmark - offset;
@@ -1125,7 +1125,7 @@ dontblock:
if ((flags & MSG_PEEK) == 0) {
so->so_oobmark -= len;
if (so->so_oobmark == 0) {
- so->so_state |= SS_RCVATMARK;
+ so->so_rcv.sb_state |= SBS_RCVATMARK;
break;
}
} else {
@@ -1145,7 +1145,7 @@ dontblock:
*/
while (flags & MSG_WAITALL && m == NULL && uio->uio_resid > 0 &&
!sosendallatonce(so) && nextrecord == NULL) {
- if (so->so_error || so->so_state & SS_CANTRCVMORE)
+ if (so->so_error || so->so_rcv.sb_state & SBS_CANTRCVMORE)
break;
/*
* Notify the protocol that some data has been
@@ -1192,7 +1192,7 @@ dontblock:
(*pr->pr_usrreqs->pru_rcvd)(so, flags);
}
if (orig_resid == uio->uio_resid && orig_resid &&
- (flags & MSG_EOR) == 0 && (so->so_state & SS_CANTRCVMORE) == 0) {
+ (flags & MSG_EOR) == 0 && (so->so_rcv.sb_state & SBS_CANTRCVMORE) == 0) {
sbunlock(&so->so_rcv);
splx(s);
goto restart;
@@ -1834,7 +1834,7 @@ sopoll(struct socket *so, int events, struct ucred *active_cred,
revents |= events & (POLLOUT | POLLWRNORM);
if (events & (POLLPRI | POLLRDBAND))
- if (so->so_oobmark || (so->so_state & SS_RCVATMARK))
+ if (so->so_oobmark || (so->so_rcv.sb_state & SBS_RCVATMARK))
revents |= events & (POLLPRI | POLLRDBAND);
if (revents == 0) {
@@ -1905,7 +1905,7 @@ filt_soread(struct knote *kn, long hint)
int result;
kn->kn_data = so->so_rcv.sb_cc - so->so_rcv.sb_ctl;
- if (so->so_state & SS_CANTRCVMORE) {
+ if (so->so_rcv.sb_state & SBS_CANTRCVMORE) {
kn->kn_flags |= EV_EOF;
kn->kn_fflags = so->so_error;
result = 1;
@@ -1938,7 +1938,7 @@ filt_sowrite(struct knote *kn, long hint)
int result;
kn->kn_data = sbspace(&so->so_snd);
- if (so->so_state & SS_CANTSENDMORE) {
+ if (so->so_snd.sb_state & SBS_CANTSENDMORE) {
kn->kn_flags |= EV_EOF;
kn->kn_fflags = so->so_error;
result = 1;
OpenPOWER on IntegriCloud