Deleted Added
full compact
thr_sig.c (115080) thr_sig.c (115278)
1/*
2 * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
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

--- 15 unchanged lines hidden (view full) ---

24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
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 *
1/*
2 * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
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

--- 15 unchanged lines hidden (view full) ---

24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
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 * $FreeBSD: head/lib/libkse/thread/thr_sig.c 115080 2003-05-16 19:58:30Z deischen $
32 * $FreeBSD: head/lib/libkse/thread/thr_sig.c 115278 2003-05-24 02:29:25Z deischen $
33 */
34#include <sys/param.h>
35#include <sys/types.h>
36#include <sys/signalvar.h>
37#include <signal.h>
38#include <errno.h>
39#include <fcntl.h>
40#include <unistd.h>

--- 105 unchanged lines hidden (view full) ---

146_thr_sig_dispatch(struct kse *curkse, int sig, siginfo_t *info)
147{
148 struct pthread *thread;
149
150 DBG_MSG(">>> _thr_sig_dispatch(%d)\n", sig);
151
152 /* Some signals need special handling: */
153 handle_special_signals(curkse, sig);
33 */
34#include <sys/param.h>
35#include <sys/types.h>
36#include <sys/signalvar.h>
37#include <signal.h>
38#include <errno.h>
39#include <fcntl.h>
40#include <unistd.h>

--- 105 unchanged lines hidden (view full) ---

146_thr_sig_dispatch(struct kse *curkse, int sig, siginfo_t *info)
147{
148 struct pthread *thread;
149
150 DBG_MSG(">>> _thr_sig_dispatch(%d)\n", sig);
151
152 /* Some signals need special handling: */
153 handle_special_signals(curkse, sig);
154
155 if ((thread = thr_sig_find(curkse, sig, info)) != NULL) {
154 stderr_debug("dispatch sig:%d\n", sig);
155 while ((thread = thr_sig_find(curkse, sig, info)) != NULL) {
156 /*
157 * Setup the target thread to receive the signal:
158 */
159 DBG_MSG("Got signal %d, selecting thread %p\n", sig, thread);
160 KSE_SCHED_LOCK(curkse, thread->kseg);
156 /*
157 * Setup the target thread to receive the signal:
158 */
159 DBG_MSG("Got signal %d, selecting thread %p\n", sig, thread);
160 KSE_SCHED_LOCK(curkse, thread->kseg);
161 _thr_sig_add(thread, sig, info);
162 KSE_SCHED_UNLOCK(curkse, thread->kseg);
161 if ((thread->state == PS_DEAD) ||
162 (thread->state == PS_DEADLOCK) ||
163 THR_IS_EXITING(thread) || THR_IS_SUSPENDED(thread)) {
164 KSE_SCHED_UNLOCK(curkse, thread->kseg);
165 _thr_ref_delete(NULL, thread);
166 } else {
167 _thr_sig_add(thread, sig, info);
168 KSE_SCHED_UNLOCK(curkse, thread->kseg);
169 _thr_ref_delete(NULL, thread);
170 break;
171 }
163 }
164}
165
166void
167_thr_sig_handler(int sig, siginfo_t *info, ucontext_t *ucp)
168{
169 void (*sigfunc)(int, siginfo_t *, void *);
170 struct kse *curkse;

--- 145 unchanged lines hidden (view full) ---

316 }
317 else if ((pthread->state == PS_DEAD) ||
318 (pthread->state == PS_DEADLOCK) ||
319 THR_IS_EXITING(pthread) || THR_IS_SUSPENDED(pthread))
320 ; /* Skip this thread. */
321 else if ((handler_installed != 0) &&
322 !sigismember(&pthread->tmbx.tm_context.uc_sigmask, sig)) {
323 if (pthread->state == PS_SIGSUSPEND) {
172 }
173}
174
175void
176_thr_sig_handler(int sig, siginfo_t *info, ucontext_t *ucp)
177{
178 void (*sigfunc)(int, siginfo_t *, void *);
179 struct kse *curkse;

--- 145 unchanged lines hidden (view full) ---

325 }
326 else if ((pthread->state == PS_DEAD) ||
327 (pthread->state == PS_DEADLOCK) ||
328 THR_IS_EXITING(pthread) || THR_IS_SUSPENDED(pthread))
329 ; /* Skip this thread. */
330 else if ((handler_installed != 0) &&
331 !sigismember(&pthread->tmbx.tm_context.uc_sigmask, sig)) {
332 if (pthread->state == PS_SIGSUSPEND) {
324 if (suspended_thread == NULL)
333 if (suspended_thread == NULL) {
325 suspended_thread = pthread;
334 suspended_thread = pthread;
326 } else if (signaled_thread == NULL)
335 suspended_thread->refcount++;
336 }
337 } else if (signaled_thread == NULL) {
327 signaled_thread = pthread;
338 signaled_thread = pthread;
339 signaled_thread->refcount++;
340 }
328 }
329 KSE_SCHED_UNLOCK(curkse, pthread->kseg);
330 }
331 KSE_LOCK_RELEASE(curkse, &_thread_list_lock);
332
333 /*
334 * Only perform wakeups and signal delivery if there is a
335 * custom handler installed:

--- 18 unchanged lines hidden (view full) ---

354 sizeof(*info));
355 }
356 KSE_LOCK_RELEASE(curkse, &_thread_signal_lock);
357 } else {
358 /*
359 * We only deliver the signal to one thread;
360 * give preference to the suspended thread:
361 */
341 }
342 KSE_SCHED_UNLOCK(curkse, pthread->kseg);
343 }
344 KSE_LOCK_RELEASE(curkse, &_thread_list_lock);
345
346 /*
347 * Only perform wakeups and signal delivery if there is a
348 * custom handler installed:

--- 18 unchanged lines hidden (view full) ---

367 sizeof(*info));
368 }
369 KSE_LOCK_RELEASE(curkse, &_thread_signal_lock);
370 } else {
371 /*
372 * We only deliver the signal to one thread;
373 * give preference to the suspended thread:
374 */
362 if (suspended_thread != NULL)
375 if (suspended_thread != NULL) {
363 pthread = suspended_thread;
376 pthread = suspended_thread;
364 else
377 _thr_ref_delete(NULL, signaled_thread);
378 } else
365 pthread = signaled_thread;
366 return (pthread);
367 }
368 return (NULL);
369}
370
371static void
372build_siginfo(siginfo_t *info, int signo)

--- 518 unchanged lines hidden ---
379 pthread = signaled_thread;
380 return (pthread);
381 }
382 return (NULL);
383}
384
385static void
386build_siginfo(siginfo_t *info, int signo)

--- 518 unchanged lines hidden ---