Polish two functions a bit so that it is easier to wrap them in
locks if/when we need that.
This commit is contained in:
parent
832b0b55ac
commit
e364b59197
@ -126,7 +126,8 @@ soo_ioctl(fp, cmd, data, active_cred, td)
|
||||
struct ucred *active_cred;
|
||||
struct thread *td;
|
||||
{
|
||||
register struct socket *so = fp->f_data;
|
||||
struct socket *so = fp->f_data;
|
||||
int error = 0;
|
||||
|
||||
switch (cmd) {
|
||||
|
||||
@ -137,7 +138,7 @@ soo_ioctl(fp, cmd, data, active_cred, td)
|
||||
else
|
||||
so->so_state &= ~SS_NBIO;
|
||||
SOCK_UNLOCK(so);
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case FIOASYNC:
|
||||
/*
|
||||
@ -167,42 +168,49 @@ soo_ioctl(fp, cmd, data, active_cred, td)
|
||||
so->so_snd.sb_flags &= ~SB_ASYNC;
|
||||
SOCKBUF_UNLOCK(&so->so_snd);
|
||||
}
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case FIONREAD:
|
||||
/* Unlocked read. */
|
||||
*(int *)data = so->so_rcv.sb_cc;
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case FIOSETOWN:
|
||||
return (fsetown(*(int *)data, &so->so_sigio));
|
||||
error = fsetown(*(int *)data, &so->so_sigio);
|
||||
break;
|
||||
|
||||
case FIOGETOWN:
|
||||
*(int *)data = fgetown(&so->so_sigio);
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case SIOCSPGRP:
|
||||
return (fsetown(-(*(int *)data), &so->so_sigio));
|
||||
error = fsetown(-(*(int *)data), &so->so_sigio);
|
||||
break;
|
||||
|
||||
case SIOCGPGRP:
|
||||
*(int *)data = -fgetown(&so->so_sigio);
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case SIOCATMARK:
|
||||
/* Unlocked read. */
|
||||
*(int *)data = (so->so_rcv.sb_state & SBS_RCVATMARK) != 0;
|
||||
return (0);
|
||||
break;
|
||||
default:
|
||||
/*
|
||||
* Interface/routing/protocol specific ioctls:
|
||||
* interface and routing ioctls should have a
|
||||
* different entry since a socket's unnecessary
|
||||
*/
|
||||
if (IOCGROUP(cmd) == 'i')
|
||||
error = ifioctl(so, cmd, data, td);
|
||||
else if (IOCGROUP(cmd) == 'r')
|
||||
error = rtioctl(cmd, data);
|
||||
else
|
||||
error = ((*so->so_proto->pr_usrreqs->pru_control)
|
||||
(so, cmd, data, 0, td));
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* Interface/routing/protocol specific ioctls:
|
||||
* interface and routing ioctls should have a
|
||||
* different entry since a socket's unnecessary
|
||||
*/
|
||||
if (IOCGROUP(cmd) == 'i')
|
||||
return (ifioctl(so, cmd, data, td));
|
||||
if (IOCGROUP(cmd) == 'r')
|
||||
return (rtioctl(cmd, data));
|
||||
return ((*so->so_proto->pr_usrreqs->pru_control)(so, cmd, data, 0, td));
|
||||
return(error);
|
||||
}
|
||||
|
||||
int
|
||||
@ -213,8 +221,12 @@ soo_poll(fp, events, active_cred, td)
|
||||
struct thread *td;
|
||||
{
|
||||
struct socket *so = fp->f_data;
|
||||
return so->so_proto->pr_usrreqs->pru_sopoll(so, events,
|
||||
fp->f_cred, td);
|
||||
int error;
|
||||
|
||||
error = (so->so_proto->pr_usrreqs->pru_sopoll)
|
||||
(so, events, fp->f_cred, td);
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
|
Loading…
Reference in New Issue
Block a user