diff options
author | Marcel Telka <marcel.telka@nexenta.com> | 2014-05-17 07:52:31 +0200 |
---|---|---|
committer | Richard Lowe <richlowe@richlowe.net> | 2015-02-11 11:29:32 -0500 |
commit | c62da27859e36f9fdd8cee3c6df3ad567543dcf9 (patch) | |
tree | 954f843c4ee70f4b2df818c8364654182686ce3f /usr/src/lib | |
parent | f4cf1a6a363de08977c8db91c119df49e9f6c296 (diff) | |
download | illumos-gate-c62da27859e36f9fdd8cee3c6df3ad567543dcf9.tar.gz |
4539 _t_checkfd() should not call find_tilink() if force_sync is set
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
Diffstat (limited to 'usr/src/lib')
-rw-r--r-- | usr/src/lib/libnsl/nsl/_utility.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/usr/src/lib/libnsl/nsl/_utility.c b/usr/src/lib/libnsl/nsl/_utility.c index f01cea5c6e..d29fe00d5d 100644 --- a/usr/src/lib/libnsl/nsl/_utility.c +++ b/usr/src/lib/libnsl/nsl/_utility.c @@ -26,6 +26,9 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2014 Nexenta Systems, Inc. All rights reserved. + */ #include "mt.h" #include <stdlib.h> @@ -82,15 +85,14 @@ _t_checkfd(int fd, int force_sync, int api_semantics) t_errno = TBADF; return (NULL); } - tiptr = NULL; - sig_mutex_lock(&_ti_userlock); - if ((tiptr = find_tilink(fd)) != NULL) { - if (!force_sync) { - sig_mutex_unlock(&_ti_userlock); + + if (!force_sync) { + sig_mutex_lock(&_ti_userlock); + tiptr = find_tilink(fd); + sig_mutex_unlock(&_ti_userlock); + if (tiptr != NULL) return (tiptr); - } } - sig_mutex_unlock(&_ti_userlock); /* * Not found or a forced sync is required. @@ -270,7 +272,7 @@ _t_register_lookevent( * signals are deferred, calls to malloc() are safe. */ if ((tlbs->tl_next = malloc(sizeof (struct _ti_lookbufs))) == - NULL) + NULL) return (-1); /* error */ tlbs = tlbs->tl_next; /* @@ -485,9 +487,9 @@ _t_do_ioctl(int fd, char *buf, int size, int cmd, int *retlenp) } if (retval > 0) { - t_errno = retval&0xff; + t_errno = retval & 0xff; if (t_errno == TSYSERR) - errno = (retval >> 8)&0xff; + errno = (retval >> 8) & 0xff; return (-1); } if (retlenp) @@ -689,7 +691,7 @@ add_tilink(int s) * duplicate entry or the end. */ for (curptr = hash_bucket[x]; curptr != NULL; - curptr = curptr->ti_next) { + curptr = curptr->ti_next) { if (curptr->ti_fd == s) { /* * This can happen when the user has close(2)'ed @@ -1162,8 +1164,8 @@ _t_adjust_state(int fd, int instate) * from the stream head. */ if ((arg.ctlbuf.len == 4) && - /* LINTED pointer cast */ - ((*(int32_t *)arg.ctlbuf.buf) == T_CONN_CON)) + /* LINTED pointer cast */ + ((*(int32_t *)arg.ctlbuf.buf) == T_CONN_CON)) outstate = T_OUTCON; break; case T_INREL: @@ -1375,7 +1377,7 @@ _t_acquire_ctlbuf( * allocate new buffer and free after use. */ if ((ctlbufp->maxlen = _t_cbuf_alloc(tiptr, - &ctlbufp->buf)) < 0) { + &ctlbufp->buf)) < 0) { t_errno = TSYSERR; return (-1); } @@ -1419,7 +1421,7 @@ _t_acquire_databuf( * allocate new buffer and free after use. */ if ((databufp->maxlen = _t_rbuf_alloc(tiptr, - &databufp->buf)) < 0) { + &databufp->buf)) < 0) { t_errno = TSYSERR; return (-1); } |