If this is a problem with sbsize, this should take care of any possibility
ever of there being a problem...

Index: kern/kern_proc.c
===================================================================
RCS file: /usr2/ncvs/src/sys/kern/kern_proc.c,v
retrieving revision 1.69
diff -u -r1.69 kern_proc.c
--- kern/kern_proc.c    2000/07/04 11:25:22     1.69
+++ kern/kern_proc.c    2000/08/26 23:50:40
@@ -190,25 +190,33 @@
  * Change the total socket buffer size a user has used.
  */
 int
-chgsbsize(uid, diff, max)
+chgsbsize(uid, hiwat, to, max)
        uid_t   uid;
-       rlim_t  diff;
+       u_long *hiwat;
+       u_long  to;
        rlim_t  max;
 {
        struct uidinfo *uip;
+       rlim_t diff;
+       int s;
 
        uip = uifind(uid);
-       if (diff < 0)
-               KASSERT(uip != NULL, ("reducing sbsize: lost count, uid = %d", uid));
+       KASSERT(to < *hiwat && uip != NULL,
+           ("reducing sbsize: lost count, uid = %d", uid));
        if (uip == NULL)
                uip = uicreate(uid);
+       s = splnet();
+       diff = to - *hiwat;
        /* don't allow them to exceed max, but allow subtraction */
        if (diff > 0 && uip->ui_sbsize + diff > max) {
                (void)uifree(uip);
+               splx(s);
                return (0);
        }
        uip->ui_sbsize += diff;
+       *hiwat = to;
        (void)uifree(uip);
+       splx(s);
        return (1);
 }
 
Index: kern/uipc_socket2.c
===================================================================
RCS file: /usr2/ncvs/src/sys/kern/uipc_socket2.c,v
retrieving revision 1.61
diff -u -r1.61 uipc_socket2.c
--- kern/uipc_socket2.c 2000/07/31 08:23:43     1.61
+++ kern/uipc_socket2.c 2000/08/26 23:36:25
@@ -420,7 +420,6 @@
        struct socket *so;
        struct proc *p;
 {
-       rlim_t delta;
 
        /*
         * p will only be NULL when we're in an interrupt
@@ -428,8 +427,7 @@
         */
        if ((u_quad_t)cc > (u_quad_t)sb_max * MCLBYTES / (MSIZE + MCLBYTES))
                return (0);
-       delta = (rlim_t)cc - sb->sb_hiwat;
-       if (p && !chgsbsize(so->so_cred->cr_uid, delta,
+       if (p && !chgsbsize(so->so_cred->cr_uid, &sb->sb_hiwat, cc,
                p->p_rlimit[RLIMIT_SBSIZE].rlim_cur)) {
                return (0);
        }
@@ -450,8 +448,8 @@
 {
 
        sbflush(sb);
-       (void)chgsbsize(so->so_cred->cr_uid, -(rlim_t)sb->sb_hiwat, RLIM_INFINITY);
-       sb->sb_hiwat = sb->sb_mbmax = 0;
+       (void)chgsbsize(so->so_cred->cr_uid, &sb->sb_hiwat, 0, RLIM_INFINITY);
+       sb->sb_mbmax = 0;
 }
 
 /*
Index: kern/uipc_socket.c
===================================================================
RCS file: /usr2/ncvs/src/sys/kern/uipc_socket.c,v
retrieving revision 1.80
diff -u -r1.80 uipc_socket.c
--- kern/uipc_socket.c  2000/08/07 17:52:08     1.80
+++ kern/uipc_socket.c  2000/08/26 23:37:00
@@ -191,10 +191,10 @@
        so->so_gencnt = ++so_gencnt;
        if (so->so_rcv.sb_hiwat)
                (void)chgsbsize(so->so_cred->cr_uid,
-                   -(rlim_t)so->so_rcv.sb_hiwat, RLIM_INFINITY);
+                   &so->so_rcv.sb_hiwat, 0, RLIM_INFINITY);
        if (so->so_snd.sb_hiwat)
                (void)chgsbsize(so->so_cred->cr_uid,
-                   -(rlim_t)so->so_snd.sb_hiwat, RLIM_INFINITY);
+                   &so->so_snd.sb_hiwat, 0, RLIM_INFINITY);
        if (so->so_accf != NULL) {
                if (so->so_accf->so_accept_filter != NULL && 
                        so->so_accf->so_accept_filter->accf_destroy != NULL) {
Index: kern/uipc_usrreq.c
===================================================================
RCS file: /usr2/ncvs/src/sys/kern/uipc_usrreq.c,v
retrieving revision 1.58
diff -u -r1.58 uipc_usrreq.c
--- kern/uipc_usrreq.c  2000/07/11 22:07:43     1.58
+++ kern/uipc_usrreq.c  2000/08/26 23:52:24
@@ -217,6 +217,7 @@
 {
        struct unpcb *unp = sotounpcb(so);
        struct socket *so2;
+       u_long newhiwat;
 
        if (unp == 0)
                return EINVAL;
@@ -235,9 +236,10 @@
                 */
                so2->so_snd.sb_mbmax += unp->unp_mbcnt - so->so_rcv.sb_mbcnt;
                unp->unp_mbcnt = so->so_rcv.sb_mbcnt;
-               so2->so_snd.sb_hiwat += unp->unp_cc - so->so_rcv.sb_cc;
-               (void)chgsbsize(so2->so_cred->cr_uid,
-                   (rlim_t)unp->unp_cc - so->so_rcv.sb_cc, RLIM_INFINITY);
+               newhiwat = so2->so_snd.sb_hiwat + unp->unp_cc -
+                   so->so_rcv.sb_cc;
+               (void)chgsbsize(so2->so_cred->cr_uid, &so2->so_snd.sb_hiwat,
+                   newhiwat, RLIM_INFINITY);
                unp->unp_cc = so->so_rcv.sb_cc;
                sowwakeup(so2);
                break;
@@ -257,6 +259,7 @@
        int error = 0;
        struct unpcb *unp = sotounpcb(so);
        struct socket *so2;
+       u_long newhiwat;
 
        if (unp == 0) {
                error = EINVAL;
@@ -342,10 +345,10 @@
                so->so_snd.sb_mbmax -=
                        so2->so_rcv.sb_mbcnt - unp->unp_conn->unp_mbcnt;
                unp->unp_conn->unp_mbcnt = so2->so_rcv.sb_mbcnt;
-               so->so_snd.sb_hiwat -=
-                   so2->so_rcv.sb_cc - unp->unp_conn->unp_cc;
-               (void)chgsbsize(so->so_cred->cr_uid,
-                   (rlim_t)unp->unp_conn->unp_cc - so2->so_rcv.sb_cc, RLIM_INFINITY);
+               newhiwat = so->so_snd.sb_hiwat -
+                   (so2->so_rcv.sb_cc - unp->unp_conn->unp_cc);
+               (void)chgsbsize(so->so_cred->cr_uid, &so->so_snd.sb_hiwat,
+                   newhiwat, RLIM_INFINITY);
                unp->unp_conn->unp_cc = so2->so_rcv.sb_cc;
                sorwakeup(so2);
                m = 0;
Index: sys/proc.h
===================================================================
RCS file: /usr2/ncvs/src/sys/sys/proc.h,v
retrieving revision 1.107
diff -u -r1.107 proc.h
--- sys/proc.h  2000/07/11 22:07:53     1.107
+++ sys/proc.h  2000/08/26 23:31:17
@@ -422,7 +423,7 @@
 extern struct vm_zone *proc_zone;
 
 int    chgproccnt __P((uid_t uid, int diff, int max));
-int    chgsbsize __P((uid_t uid, rlim_t diff, rlim_t max));
+int    chgsbsize __P((uid_t uid, u_long *hiwat, u_long to, rlim_t max));
 int    enterpgrp __P((struct proc *p, pid_t pgid, int mksess));
 void   fixjobc __P((struct proc *p, struct pgrp *pgrp, int entering));
 int    inferior __P((struct proc *p));

--
 Brian Fundakowski Feldman           \  FreeBSD: The Power to Serve!  /
 [EMAIL PROTECTED]                    `------------------------------'



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to