smb_trantcp.c (160954) | smb_trantcp.c (170307) |
---|---|
1/*- 2 * Copyright (c) 2000-2001 Boris Popov 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2000-2001 Boris Popov 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/sys/netsmb/smb_trantcp.c 160954 2006-08-03 15:31:52Z jhb $"); | 34__FBSDID("$FreeBSD: head/sys/netsmb/smb_trantcp.c 170307 2007-06-05 00:00:57Z jeff $"); |
35 36#include <sys/param.h> 37#include <sys/condvar.h> 38#include <sys/kernel.h> 39#include <sys/lock.h> 40#include <sys/malloc.h> 41#include <sys/mbuf.h> 42#include <sys/poll.h> --- 67 unchanged lines hidden (view full) --- 110 getmicrouptime(&rtv); 111 timevaladd(&atv, &rtv); 112 } 113 timo = 0; 114 mtx_lock(&sellock); 115retry: 116 117 ncoll = nselcoll; | 35 36#include <sys/param.h> 37#include <sys/condvar.h> 38#include <sys/kernel.h> 39#include <sys/lock.h> 40#include <sys/malloc.h> 41#include <sys/mbuf.h> 42#include <sys/poll.h> --- 67 unchanged lines hidden (view full) --- 110 getmicrouptime(&rtv); 111 timevaladd(&atv, &rtv); 112 } 113 timo = 0; 114 mtx_lock(&sellock); 115retry: 116 117 ncoll = nselcoll; |
118 mtx_lock_spin(&sched_lock); | 118 thread_lock(td); |
119 td->td_flags |= TDF_SELECT; | 119 td->td_flags |= TDF_SELECT; |
120 mtx_unlock_spin(&sched_lock); | 120 thread_unlock(td); |
121 mtx_unlock(&sellock); 122 123 /* XXX: Should be done when the thread is initialized. */ 124 TAILQ_INIT(&td->td_selq); 125 revents = sopoll(nbp->nbp_tso, events, NULL, td); 126 mtx_lock(&sellock); 127 if (revents) { 128 error = 0; --- 10 unchanged lines hidden (view full) --- 139 timo = tvtohz(&ttv); 140 } 141 /* 142 * An event of our interest may occur during locking a process. 143 * In order to avoid missing the event that occurred during locking 144 * the process, test P_SELECT and rescan file descriptors if 145 * necessary. 146 */ | 121 mtx_unlock(&sellock); 122 123 /* XXX: Should be done when the thread is initialized. */ 124 TAILQ_INIT(&td->td_selq); 125 revents = sopoll(nbp->nbp_tso, events, NULL, td); 126 mtx_lock(&sellock); 127 if (revents) { 128 error = 0; --- 10 unchanged lines hidden (view full) --- 139 timo = tvtohz(&ttv); 140 } 141 /* 142 * An event of our interest may occur during locking a process. 143 * In order to avoid missing the event that occurred during locking 144 * the process, test P_SELECT and rescan file descriptors if 145 * necessary. 146 */ |
147 mtx_lock_spin(&sched_lock); | 147 thread_lock(td); |
148 if ((td->td_flags & TDF_SELECT) == 0 || nselcoll != ncoll) { | 148 if ((td->td_flags & TDF_SELECT) == 0 || nselcoll != ncoll) { |
149 mtx_unlock_spin(&sched_lock); | 149 thread_unlock(td); |
150 goto retry; 151 } | 150 goto retry; 151 } |
152 mtx_unlock_spin(&sched_lock); | 152 thread_unlock(td); |
153 154 if (timo > 0) 155 error = cv_timedwait(&selwait, &sellock, timo); 156 else { 157 cv_wait(&selwait, &sellock); 158 error = 0; 159 } 160 161done: 162 clear_selinfo_list(td); 163 | 153 154 if (timo > 0) 155 error = cv_timedwait(&selwait, &sellock, timo); 156 else { 157 cv_wait(&selwait, &sellock); 158 error = 0; 159 } 160 161done: 162 clear_selinfo_list(td); 163 |
164 mtx_lock_spin(&sched_lock); | 164 thread_lock(td); |
165 td->td_flags &= ~TDF_SELECT; | 165 td->td_flags &= ~TDF_SELECT; |
166 mtx_unlock_spin(&sched_lock); | 166 thread_unlock(td); |
167 mtx_unlock(&sellock); 168 169done_noproclock: 170 if (error == ERESTART) 171 return 0; 172 return error; 173} 174 --- 581 unchanged lines hidden --- | 167 mtx_unlock(&sellock); 168 169done_noproclock: 170 if (error == ERESTART) 171 return 0; 172 return error; 173} 174 --- 581 unchanged lines hidden --- |