Deleted Added
full compact
thr_cancel.c (114767) thr_cancel.c (115278)
1/*
2 * David Leonard <d@openbsd.org>, 1999. Public domain.
1/*
2 * David Leonard <d@openbsd.org>, 1999. Public domain.
3 * $FreeBSD: head/lib/libkse/thread/thr_cancel.c 114767 2003-05-06 00:02:54Z deischen $
3 * $FreeBSD: head/lib/libkse/thread/thr_cancel.c 115278 2003-05-24 02:29:25Z deischen $
4 */
5#include <sys/errno.h>
6#include <pthread.h>
7#include "thr_private.h"
8
9__weak_reference(_pthread_cancel, pthread_cancel);
10__weak_reference(_pthread_setcancelstate, pthread_setcancelstate);
11__weak_reference(_pthread_setcanceltype, pthread_setcanceltype);
12__weak_reference(_pthread_testcancel, pthread_testcancel);
13
14static int checkcancel(struct pthread *curthread);
15static void testcancel(struct pthread *curthread);
16static void finish_cancellation(void *arg);
17
18int
19_pthread_cancel(pthread_t pthread)
20{
21 struct pthread *curthread = _get_curthread();
4 */
5#include <sys/errno.h>
6#include <pthread.h>
7#include "thr_private.h"
8
9__weak_reference(_pthread_cancel, pthread_cancel);
10__weak_reference(_pthread_setcancelstate, pthread_setcancelstate);
11__weak_reference(_pthread_setcanceltype, pthread_setcanceltype);
12__weak_reference(_pthread_testcancel, pthread_testcancel);
13
14static int checkcancel(struct pthread *curthread);
15static void testcancel(struct pthread *curthread);
16static void finish_cancellation(void *arg);
17
18int
19_pthread_cancel(pthread_t pthread)
20{
21 struct pthread *curthread = _get_curthread();
22 struct pthread *joinee = NULL;
22 int ret;
23
24 if ((ret = _thr_ref_add(curthread, pthread, /*include dead*/0)) == 0) {
25 /*
26 * Take the scheduling lock while we change the cancel flags.
27 */
28 THR_SCHED_LOCK(curthread, pthread);
29

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

59 case PS_SIGWAIT:
60 /* Interrupt and resume: */
61 pthread->interrupted = 1;
62 pthread->cancelflags |= THR_CANCELLING;
63 _thr_setrunnable_unlocked(pthread);
64 break;
65
66 case PS_JOIN:
23 int ret;
24
25 if ((ret = _thr_ref_add(curthread, pthread, /*include dead*/0)) == 0) {
26 /*
27 * Take the scheduling lock while we change the cancel flags.
28 */
29 THR_SCHED_LOCK(curthread, pthread);
30

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

60 case PS_SIGWAIT:
61 /* Interrupt and resume: */
62 pthread->interrupted = 1;
63 pthread->cancelflags |= THR_CANCELLING;
64 _thr_setrunnable_unlocked(pthread);
65 break;
66
67 case PS_JOIN:
68 /* Disconnect the thread from the joinee: */
69 joinee = pthread->join_status.thread;
70 pthread->join_status.thread = NULL;
67 pthread->cancelflags |= THR_CANCELLING;
71 pthread->cancelflags |= THR_CANCELLING;
72 _thr_setrunnable_unlocked(pthread);
73 if ((joinee != NULL) &&
74 (curthread->kseg == joinee->kseg)) {
75 /* Remove the joiner from the joinee. */
76 joinee->joiner = NULL;
77 joinee = NULL;
78 }
68 break;
69
70 case PS_SUSPENDED:
71 case PS_MUTEX_WAIT:
72 case PS_COND_WAIT:
73 /*
74 * Threads in these states may be in queues.
75 * In order to preserve queue integrity, the

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

98 }
99
100 /*
101 * Release the thread's scheduling lock and remove the
102 * reference:
103 */
104 THR_SCHED_UNLOCK(curthread, pthread);
105 _thr_ref_delete(curthread, pthread);
79 break;
80
81 case PS_SUSPENDED:
82 case PS_MUTEX_WAIT:
83 case PS_COND_WAIT:
84 /*
85 * Threads in these states may be in queues.
86 * In order to preserve queue integrity, the

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

109 }
110
111 /*
112 * Release the thread's scheduling lock and remove the
113 * reference:
114 */
115 THR_SCHED_UNLOCK(curthread, pthread);
116 _thr_ref_delete(curthread, pthread);
117
118 if ((joinee != NULL) &&
119 (_thr_ref_add(curthread, joinee, /* include dead */1) == 0)) {
120 /* Remove the joiner from the joinee. */
121 THR_SCHED_LOCK(curthread, joinee);
122 joinee->joiner = NULL;
123 THR_SCHED_UNLOCK(curthread, joinee);
124 _thr_ref_delete(curthread, joinee);
125 }
106 }
107 return (ret);
108}
109
110int
111_pthread_setcancelstate(int state, int *oldstate)
112{
113 struct pthread *curthread = _get_curthread();

--- 155 unchanged lines hidden ---
126 }
127 return (ret);
128}
129
130int
131_pthread_setcancelstate(int state, int *oldstate)
132{
133 struct pthread *curthread = _get_curthread();

--- 155 unchanged lines hidden ---