diff options
| author | meem <Peter.Memishian@Sun.COM> | 2009-02-10 20:25:26 -0500 |
|---|---|---|
| committer | meem <Peter.Memishian@Sun.COM> | 2009-02-10 20:25:26 -0500 |
| commit | a45f3f93509927476463caf678b7806c65d5efe1 (patch) | |
| tree | eaa42da4538db9ee3e4230e9ba7be4de78adcc85 /usr/src/uts/common/os/streamio.c | |
| parent | 9bd6d2697ce845da0f5a213c59b85b4a604e08db (diff) | |
| download | illumos-joyent-a45f3f93509927476463caf678b7806c65d5efe1.tar.gz | |
6646362 STREAMS flow trace should be enhanced to aid memory leak detection
6646366 strgetmsg() and kstrgetmsg() leak M_SIGs
6646890 rts_wrw() leaks short M_DATA/M_PROTO/M_PCPROTO messages
6653352 I_LIST implementation littered with voodoo
6797455 mdb/truss need to know about M_CMD/_I_CMD
Diffstat (limited to 'usr/src/uts/common/os/streamio.c')
| -rw-r--r-- | usr/src/uts/common/os/streamio.c | 158 |
1 files changed, 62 insertions, 96 deletions
diff --git a/usr/src/uts/common/os/streamio.c b/usr/src/uts/common/os/streamio.c index 42d0b8e17c..2b7daaab1f 100644 --- a/usr/src/uts/common/os/streamio.c +++ b/usr/src/uts/common/os/streamio.c @@ -23,7 +23,7 @@ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -1416,10 +1416,8 @@ ismdata: * sd_lock is held so the content of the * read queue can not change. */ - ASSERT(bp != NULL && - bp->b_datap->db_type == M_SIG); - strsignal_nolock(stp, *bp->b_rptr, - (int32_t)bp->b_band); + ASSERT(bp != NULL && DB_TYPE(bp) == M_SIG); + strsignal_nolock(stp, *bp->b_rptr, bp->b_band); mutex_exit(&stp->sd_lock); freemsg(bp); if (STREAM_NEEDSERVICE(stp)) @@ -1945,8 +1943,7 @@ log_dupioc(queue_t *rq, mblk_t *bp) claimstr(wq); qp = wq->q_next; do { - if ((dname = qp->q_qinfo->qi_minfo->mi_idname) == NULL) - dname = "?"; + dname = Q2NAME(qp); islast = !SAMESTR(qp) || qp->q_next == NULL; if (modnames == NULL) { /* @@ -3805,11 +3802,11 @@ strioctl(struct vnode *vp, int cmd, intptr_t arg, int flag, int copyflag, /* Look downstream to see if module is there. */ claimstr(stp->sd_wrq); for (q = stp->sd_wrq->q_next; q; q = q->q_next) { - if (q->q_flag&QREADR) { + if (q->q_flag & QREADR) { q = NULL; break; } - if (strcmp(mname, q->q_qinfo->qi_minfo->mi_idname) == 0) + if (strcmp(mname, Q2NAME(q)) == 0) break; } releasestr(stp->sd_wrq); @@ -4083,12 +4080,6 @@ strioctl(struct vnode *vp, int cmd, intptr_t arg, int flag, int copyflag, * about the implications of these ioctls before extending * their support. And we do not think these features are * valuable for pipes. - * - * Neither do we support O/C hot stream. Note that only - * the upper streams of TCP/IP stack are O/C hot streams. - * The lower IP stream is not. - * When there is a O/C cold barrier, we only allow inserts - * above the barrier. */ STRUCT_DECL(strmodconf, strmodinsert); char mod_name[FMNAMESZ + 1]; @@ -4255,12 +4246,6 @@ strioctl(struct vnode *vp, int cmd, intptr_t arg, int flag, int copyflag, * their support. And we do not think these features are * valuable for pipes. * - * Neither do we support O/C hot stream. Note that only - * the upper streams of TCP/IP stack are O/C hot streams. - * The lower IP stream is not. - * When there is a O/C cold barrier we do not allow removal - * below the barrier. - * * Also note that _I_REMOVE cannot be used to remove a * driver or the stream head. */ @@ -4305,9 +4290,8 @@ strioctl(struct vnode *vp, int cmd, intptr_t arg, int flag, int copyflag, for (q = stp->sd_wrq->q_next; SAMESTR(q) && pos > 0; q = q->q_next, pos--) ; - if (pos > 0 || ! SAMESTR(q) || - strncmp(q->q_qinfo->qi_minfo->mi_idname, mod_name, - strlen(q->q_qinfo->qi_minfo->mi_idname)) != 0) { + if (pos > 0 || !SAMESTR(q) || + strcmp(Q2NAME(q), mod_name) != 0) { mutex_enter(&stp->sd_lock); strendplumb(stp); mutex_exit(&stp->sd_lock); @@ -4413,10 +4397,10 @@ strioctl(struct vnode *vp, int cmd, intptr_t arg, int flag, int copyflag, * Get name of first module downstream. * If no module, return an error. */ - { claimstr(wrq); - if (_SAMESTR(wrq) && wrq->q_next->q_next) { - char *name = wrq->q_next->q_qinfo->qi_minfo->mi_idname; + if (_SAMESTR(wrq) && wrq->q_next->q_next != NULL) { + char *name = Q2NAME(wrq->q_next); + error = strcopyout(name, (void *)arg, strlen(name) + 1, copyflag); releasestr(wrq); @@ -4424,15 +4408,13 @@ strioctl(struct vnode *vp, int cmd, intptr_t arg, int flag, int copyflag, } releasestr(wrq); return (EINVAL); - } case I_LINK: case I_PLINK: /* * Link a multiplexor. */ - error = mlink(vp, cmd, (int)arg, crp, rvalp, 0); - return (error); + return (mlink(vp, cmd, (int)arg, crp, rvalp, 0)); case _I_PLINK_LH: /* @@ -5520,57 +5502,44 @@ strioctl(struct vnode *vp, int cmd, intptr_t arg, int flag, int copyflag, { queue_t *q; - int num_modules, space_allocated; + char *qname; + int i, nmods; + struct str_mlist *mlist; STRUCT_DECL(str_list, strlist); - struct str_mlist *mlist_ptr; if (arg == NULL) { /* Return number of modules plus driver */ - q = stp->sd_wrq; - if (stp->sd_vnode->v_type == VFIFO) { + if (stp->sd_vnode->v_type == VFIFO) *rvalp = stp->sd_pushcnt; - } else { + else *rvalp = stp->sd_pushcnt + 1; - } - } else { - STRUCT_INIT(strlist, flag); + return (0); + } - error = strcopyin((void *)arg, STRUCT_BUF(strlist), - STRUCT_SIZE(strlist), copyflag); - if (error) - return (error); + STRUCT_INIT(strlist, flag); - space_allocated = STRUCT_FGET(strlist, sl_nmods); - if ((space_allocated) <= 0) - return (EINVAL); - claimstr(stp->sd_wrq); - q = stp->sd_wrq; - num_modules = 0; - while (_SAMESTR(q) && (space_allocated != 0)) { - char *name = - q->q_next->q_qinfo->qi_minfo->mi_idname; - - mlist_ptr = STRUCT_FGETP(strlist, sl_modlist); + error = strcopyin((void *)arg, STRUCT_BUF(strlist), + STRUCT_SIZE(strlist), copyflag); + if (error != 0) + return (error); - error = strcopyout(name, mlist_ptr, - strlen(name) + 1, copyflag); + mlist = STRUCT_FGETP(strlist, sl_modlist); + nmods = STRUCT_FGET(strlist, sl_nmods); + if (nmods <= 0) + return (EINVAL); - if (error) { - releasestr(stp->sd_wrq); - return (error); - } - q = q->q_next; - space_allocated--; - num_modules++; - mlist_ptr = - (struct str_mlist *)((uintptr_t)mlist_ptr + - sizeof (struct str_mlist)); - STRUCT_FSETP(strlist, sl_modlist, mlist_ptr); + claimstr(stp->sd_wrq); + q = stp->sd_wrq; + for (i = 0; i < nmods && _SAMESTR(q); i++, q = q->q_next) { + qname = Q2NAME(q->q_next); + error = strcopyout(qname, &mlist[i], strlen(qname) + 1, + copyflag); + if (error != 0) { + releasestr(stp->sd_wrq); + return (error); } - releasestr(stp->sd_wrq); - error = strcopyout(&num_modules, (void *)arg, - sizeof (int), copyflag); } - return (error); + releasestr(stp->sd_wrq); + return (strcopyout(&i, (void *)arg, sizeof (int), copyflag)); } case I_CKBAND: @@ -6705,17 +6674,17 @@ strgetmsg( ASSERT(MUTEX_HELD(&stp->sd_lock)); if (bp != NULL) { ASSERT(!(bp->b_datap->db_flags & DBLK_UIOA)); - if (bp->b_datap->db_type == M_SIG) { + if (DB_TYPE(bp) == M_SIG) { strsignal_nolock(stp, *bp->b_rptr, - (int32_t)bp->b_band); + bp->b_band); + freemsg(bp); continue; } else { break; } } - if (error != 0) { + if (error != 0) goto getmout; - } /* * We can't depend on the value of STRPRI here because @@ -6724,24 +6693,22 @@ strgetmsg( * determine if a high priority messages is waiting */ } else if ((*flagsp & MSG_HIPRI) && q_first != NULL && - q_first->b_datap->db_type >= QPCTL && + DB_TYPE(q_first) >= QPCTL && (bp = getq_noenab(q, 0)) != NULL) { /* Asked for HIPRI and got one */ - ASSERT(bp->b_datap->db_type >= QPCTL); + ASSERT(DB_TYPE(bp) >= QPCTL); break; } else if ((*flagsp & MSG_BAND) && q_first != NULL && - ((q_first->b_band >= *prip) || - q_first->b_datap->db_type >= QPCTL) && + ((q_first->b_band >= *prip) || DB_TYPE(q_first) >= QPCTL) && (bp = getq_noenab(q, 0)) != NULL) { /* * Asked for at least band "prip" and got either at * least that band or a hipri message. */ - ASSERT(bp->b_band >= *prip || - bp->b_datap->db_type >= QPCTL); - if (bp->b_datap->db_type == M_SIG) { - strsignal_nolock(stp, *bp->b_rptr, - (int32_t)bp->b_band); + ASSERT(bp->b_band >= *prip || DB_TYPE(bp) >= QPCTL); + if (DB_TYPE(bp) == M_SIG) { + strsignal_nolock(stp, *bp->b_rptr, bp->b_band); + freemsg(bp); continue; } else { break; @@ -7058,7 +7025,7 @@ getmout: bp = getq(q); ASSERT(bp != NULL && bp->b_datap->db_type == M_SIG); - strsignal_nolock(stp, *bp->b_rptr, (int32_t)bp->b_band); + strsignal_nolock(stp, *bp->b_rptr, bp->b_band); mutex_exit(&stp->sd_lock); freemsg(bp); if (STREAM_NEEDSERVICE(stp)) @@ -7247,9 +7214,10 @@ retry: bp = strget(stp, q, uiop, first, &error); ASSERT(MUTEX_HELD(&stp->sd_lock)); if (bp != NULL) { - if (bp->b_datap->db_type == M_SIG) { + if (DB_TYPE(bp) == M_SIG) { strsignal_nolock(stp, *bp->b_rptr, - (int32_t)bp->b_band); + bp->b_band); + freemsg(bp); continue; } else { break; @@ -7265,23 +7233,21 @@ retry: * determine if a high priority messages is waiting */ } else if ((flags & MSG_HIPRI) && q_first != NULL && - q_first->b_datap->db_type >= QPCTL && + DB_TYPE(q_first) >= QPCTL && (bp = getq_noenab(q, 0)) != NULL) { - ASSERT(bp->b_datap->db_type >= QPCTL); + ASSERT(DB_TYPE(bp) >= QPCTL); break; } else if ((flags & MSG_BAND) && q_first != NULL && - ((q_first->b_band >= *prip) || - q_first->b_datap->db_type >= QPCTL) && + ((q_first->b_band >= *prip) || DB_TYPE(q_first) >= QPCTL) && (bp = getq_noenab(q, 0)) != NULL) { /* * Asked for at least band "prip" and got either at * least that band or a hipri message. */ - ASSERT(bp->b_band >= *prip || - bp->b_datap->db_type >= QPCTL); - if (bp->b_datap->db_type == M_SIG) { - strsignal_nolock(stp, *bp->b_rptr, - (int32_t)bp->b_band); + ASSERT(bp->b_band >= *prip || DB_TYPE(bp) >= QPCTL); + if (DB_TYPE(bp) == M_SIG) { + strsignal_nolock(stp, *bp->b_rptr, bp->b_band); + freemsg(bp); continue; } else { break; @@ -7734,7 +7700,7 @@ getmout: bp = getq(q); ASSERT(bp != NULL && bp->b_datap->db_type == M_SIG); - strsignal_nolock(stp, *bp->b_rptr, (int32_t)bp->b_band); + strsignal_nolock(stp, *bp->b_rptr, bp->b_band); mutex_exit(&stp->sd_lock); freemsg(bp); if (STREAM_NEEDSERVICE(stp)) |
