Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Kernel Services Thread |
| 3 | * |
| 4 | * Copyright 1999 Ulrich Weigand |
| 5 | */ |
| 6 | |
| 7 | #include <sys/time.h> |
| 8 | #include <unistd.h> |
| 9 | |
| 10 | #include "services.h" |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 11 | #include "debugtools.h" |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 12 | |
Alexandre Julliard | 46733de | 2000-08-09 22:31:24 +0000 | [diff] [blame] | 13 | DEFAULT_DEBUG_CHANNEL(timer); |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 14 | |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 15 | typedef struct _SERVICE |
| 16 | { |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 17 | struct _SERVICE *next; |
| 18 | HANDLE self; |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 19 | |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 20 | PAPCFUNC callback; |
| 21 | ULONG_PTR callback_arg; |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 22 | |
Alexandre Julliard | 000c980 | 1999-12-13 01:42:03 +0000 | [diff] [blame] | 23 | BOOL disabled; |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 24 | HANDLE object; |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 25 | } SERVICE; |
| 26 | |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 27 | |
Alexandre Julliard | 46733de | 2000-08-09 22:31:24 +0000 | [diff] [blame] | 28 | static HANDLE service_thread; |
| 29 | static SERVICE *service_first; |
| 30 | static DWORD service_counter; |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 31 | |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 32 | /*********************************************************************** |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 33 | * SERVICE_Loop |
| 34 | */ |
Alexandre Julliard | 46733de | 2000-08-09 22:31:24 +0000 | [diff] [blame] | 35 | static DWORD CALLBACK SERVICE_Loop( void *dummy ) |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 36 | { |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 37 | HANDLE handles[MAXIMUM_WAIT_OBJECTS]; |
| 38 | int count = 0; |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 39 | DWORD retval = WAIT_FAILED; |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 40 | |
| 41 | while ( TRUE ) |
| 42 | { |
| 43 | PAPCFUNC callback; |
| 44 | ULONG_PTR callback_arg; |
| 45 | SERVICE *s; |
| 46 | |
| 47 | /* Check whether some condition is fulfilled */ |
| 48 | |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 49 | HeapLock( GetProcessHeap() ); |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 50 | |
| 51 | callback = NULL; |
| 52 | callback_arg = 0L; |
Alexandre Julliard | 46733de | 2000-08-09 22:31:24 +0000 | [diff] [blame] | 53 | for ( s = service_first; s; s = s->next ) |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 54 | { |
Alexandre Julliard | 000c980 | 1999-12-13 01:42:03 +0000 | [diff] [blame] | 55 | if (s->disabled) continue; |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 56 | |
Alexandre Julliard | 000c980 | 1999-12-13 01:42:03 +0000 | [diff] [blame] | 57 | if ( retval >= WAIT_OBJECT_0 && retval < WAIT_OBJECT_0 + count ) |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 58 | { |
Alexandre Julliard | 000c980 | 1999-12-13 01:42:03 +0000 | [diff] [blame] | 59 | if ( handles[retval - WAIT_OBJECT_0] == s->object ) |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 60 | { |
Alexandre Julliard | 000c980 | 1999-12-13 01:42:03 +0000 | [diff] [blame] | 61 | retval = WAIT_TIMEOUT; |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 62 | callback = s->callback; |
| 63 | callback_arg = s->callback_arg; |
| 64 | break; |
| 65 | } |
Alexandre Julliard | 000c980 | 1999-12-13 01:42:03 +0000 | [diff] [blame] | 66 | } |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 67 | } |
| 68 | |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 69 | HeapUnlock( GetProcessHeap() ); |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 70 | |
| 71 | /* If found, call callback routine */ |
| 72 | |
| 73 | if ( callback ) |
| 74 | { |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 75 | callback( callback_arg ); |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 76 | continue; |
| 77 | } |
| 78 | |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 79 | /* If not found, determine wait condition */ |
| 80 | |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 81 | HeapLock( GetProcessHeap() ); |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 82 | |
| 83 | count = 0; |
Alexandre Julliard | 46733de | 2000-08-09 22:31:24 +0000 | [diff] [blame] | 84 | for ( s = service_first; s; s = s->next ) |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 85 | { |
Alexandre Julliard | 000c980 | 1999-12-13 01:42:03 +0000 | [diff] [blame] | 86 | if (s->disabled) continue; |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 87 | |
Alexandre Julliard | 000c980 | 1999-12-13 01:42:03 +0000 | [diff] [blame] | 88 | if ( count < MAXIMUM_WAIT_OBJECTS ) |
| 89 | handles[count++] = s->object; |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 90 | } |
| 91 | |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 92 | HeapUnlock( GetProcessHeap() ); |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 93 | |
| 94 | |
| 95 | /* Wait until some condition satisfied */ |
| 96 | |
Alexandre Julliard | 000c980 | 1999-12-13 01:42:03 +0000 | [diff] [blame] | 97 | TRACE("Waiting for %d objects\n", count ); |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 98 | |
Alexandre Julliard | 000c980 | 1999-12-13 01:42:03 +0000 | [diff] [blame] | 99 | retval = WaitForMultipleObjectsEx( count, handles, FALSE, INFINITE, TRUE ); |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 100 | |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 101 | TRACE("Wait returned: %ld\n", retval ); |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | return 0L; |
| 105 | } |
| 106 | |
| 107 | /*********************************************************************** |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 108 | * SERVICE_CreateServiceTable |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 109 | */ |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 110 | static BOOL SERVICE_CreateServiceTable( void ) |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 111 | { |
Alexandre Julliard | 46733de | 2000-08-09 22:31:24 +0000 | [diff] [blame] | 112 | /* service_thread must be set *BEFORE* calling CreateThread |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 113 | * otherwise the thread cleanup service will cause an infinite recursion |
| 114 | * when installed |
| 115 | */ |
Alexandre Julliard | 46733de | 2000-08-09 22:31:24 +0000 | [diff] [blame] | 116 | service_thread = INVALID_HANDLE_VALUE; |
Alexandre Julliard | 46733de | 2000-08-09 22:31:24 +0000 | [diff] [blame] | 117 | service_thread = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)SERVICE_Loop, |
| 118 | NULL, 0, NULL ); |
Josh DuBois | ec33cd6 | 2001-01-17 21:50:17 +0000 | [diff] [blame] | 119 | return (service_thread != 0); |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | /*********************************************************************** |
| 123 | * SERVICE_AddObject |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 124 | * |
| 125 | * Warning: the object supplied by the caller must not be closed. It'll |
| 126 | * be destroyed when the service is deleted. It's up to the caller |
| 127 | * to ensure that object will not be destroyed in between. |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 128 | */ |
| 129 | HANDLE SERVICE_AddObject( HANDLE object, |
| 130 | PAPCFUNC callback, ULONG_PTR callback_arg ) |
| 131 | { |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 132 | SERVICE *s; |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 133 | HANDLE handle; |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 134 | |
François Gouget | 1dac6ea | 2001-01-09 20:51:36 +0000 | [diff] [blame] | 135 | if ( !object || object == INVALID_HANDLE_VALUE || !callback ) |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 136 | return INVALID_HANDLE_VALUE; |
| 137 | |
Alexandre Julliard | 46733de | 2000-08-09 22:31:24 +0000 | [diff] [blame] | 138 | if (!service_thread && !SERVICE_CreateServiceTable()) return INVALID_HANDLE_VALUE; |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 139 | |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 140 | s = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SERVICE) ); |
| 141 | if ( !s ) return INVALID_HANDLE_VALUE; |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 142 | |
| 143 | s->callback = callback; |
| 144 | s->callback_arg = callback_arg; |
| 145 | s->object = object; |
Alexandre Julliard | 000c980 | 1999-12-13 01:42:03 +0000 | [diff] [blame] | 146 | s->disabled = FALSE; |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 147 | |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 148 | HeapLock( GetProcessHeap() ); |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 149 | |
Alexandre Julliard | 46733de | 2000-08-09 22:31:24 +0000 | [diff] [blame] | 150 | s->self = handle = (HANDLE)++service_counter; |
| 151 | s->next = service_first; |
| 152 | service_first = s; |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 153 | |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 154 | HeapUnlock( GetProcessHeap() ); |
| 155 | |
Alexandre Julliard | 46733de | 2000-08-09 22:31:24 +0000 | [diff] [blame] | 156 | QueueUserAPC( NULL, service_thread, 0L ); |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 157 | |
| 158 | return handle; |
| 159 | } |
| 160 | |
| 161 | /*********************************************************************** |
| 162 | * SERVICE_AddTimer |
| 163 | */ |
| 164 | HANDLE SERVICE_AddTimer( LONG rate, |
| 165 | PAPCFUNC callback, ULONG_PTR callback_arg ) |
| 166 | { |
Alexandre Julliard | 000c980 | 1999-12-13 01:42:03 +0000 | [diff] [blame] | 167 | HANDLE handle, ret; |
| 168 | LARGE_INTEGER when; |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 169 | |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 170 | if ( !rate || !callback ) |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 171 | return INVALID_HANDLE_VALUE; |
| 172 | |
Alexandre Julliard | 000c980 | 1999-12-13 01:42:03 +0000 | [diff] [blame] | 173 | handle = CreateWaitableTimerA( NULL, FALSE, NULL ); |
| 174 | if (!handle) return INVALID_HANDLE_VALUE; |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 175 | |
Alexandre Julliard | 000c980 | 1999-12-13 01:42:03 +0000 | [diff] [blame] | 176 | if (!rate) rate = 1; |
| 177 | when.s.LowPart = when.s.HighPart = 0; |
| 178 | if (!SetWaitableTimer( handle, &when, rate, NULL, NULL, FALSE )) |
| 179 | { |
| 180 | CloseHandle( handle ); |
| 181 | return INVALID_HANDLE_VALUE; |
| 182 | } |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 183 | |
Alexandre Julliard | 000c980 | 1999-12-13 01:42:03 +0000 | [diff] [blame] | 184 | if ((ret = SERVICE_AddObject( handle, callback, callback_arg )) == INVALID_HANDLE_VALUE) |
| 185 | { |
| 186 | CloseHandle( handle ); |
| 187 | return INVALID_HANDLE_VALUE; |
| 188 | } |
| 189 | return ret; |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | /*********************************************************************** |
| 193 | * SERVICE_Delete |
| 194 | */ |
| 195 | BOOL SERVICE_Delete( HANDLE service ) |
| 196 | { |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 197 | HANDLE handle = INVALID_HANDLE_VALUE; |
| 198 | BOOL retv = FALSE; |
| 199 | SERVICE **s, *next; |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 200 | |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 201 | HeapLock( GetProcessHeap() ); |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 202 | |
Alexandre Julliard | 46733de | 2000-08-09 22:31:24 +0000 | [diff] [blame] | 203 | for ( s = &service_first; *s; s = &(*s)->next ) |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 204 | { |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 205 | if ( (*s)->self == service ) |
| 206 | { |
Alexandre Julliard | 000c980 | 1999-12-13 01:42:03 +0000 | [diff] [blame] | 207 | handle = (*s)->object; |
Ulrich Weigand | 70b2e38 | 1999-05-04 16:43:38 +0000 | [diff] [blame] | 208 | next = (*s)->next; |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 209 | HeapFree( GetProcessHeap(), 0, *s ); |
Ulrich Weigand | 70b2e38 | 1999-05-04 16:43:38 +0000 | [diff] [blame] | 210 | *s = next; |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 211 | retv = TRUE; |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 212 | break; |
| 213 | } |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 214 | } |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 215 | |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 216 | HeapUnlock( GetProcessHeap() ); |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 217 | |
Ulrich Weigand | 70b2e38 | 1999-05-04 16:43:38 +0000 | [diff] [blame] | 218 | if ( handle != INVALID_HANDLE_VALUE ) |
| 219 | CloseHandle( handle ); |
| 220 | |
Alexandre Julliard | 46733de | 2000-08-09 22:31:24 +0000 | [diff] [blame] | 221 | QueueUserAPC( NULL, service_thread, 0L ); |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 222 | |
| 223 | return retv; |
| 224 | } |
| 225 | |
| 226 | /*********************************************************************** |
| 227 | * SERVICE_Enable |
| 228 | */ |
| 229 | BOOL SERVICE_Enable( HANDLE service ) |
| 230 | { |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 231 | BOOL retv = FALSE; |
| 232 | SERVICE *s; |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 233 | |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 234 | HeapLock( GetProcessHeap() ); |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 235 | |
Alexandre Julliard | 46733de | 2000-08-09 22:31:24 +0000 | [diff] [blame] | 236 | for ( s = service_first; s; s = s->next ) |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 237 | { |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 238 | if ( s->self == service ) |
| 239 | { |
Alexandre Julliard | 000c980 | 1999-12-13 01:42:03 +0000 | [diff] [blame] | 240 | s->disabled = FALSE; |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 241 | retv = TRUE; |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 242 | break; |
| 243 | } |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 244 | } |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 245 | |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 246 | HeapUnlock( GetProcessHeap() ); |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 247 | |
Alexandre Julliard | 46733de | 2000-08-09 22:31:24 +0000 | [diff] [blame] | 248 | QueueUserAPC( NULL, service_thread, 0L ); |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 249 | |
| 250 | return retv; |
| 251 | } |
| 252 | |
| 253 | /*********************************************************************** |
| 254 | * SERVICE_Disable |
| 255 | */ |
| 256 | BOOL SERVICE_Disable( HANDLE service ) |
| 257 | { |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 258 | BOOL retv = TRUE; |
| 259 | SERVICE *s; |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 260 | |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 261 | HeapLock( GetProcessHeap() ); |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 262 | |
Alexandre Julliard | 46733de | 2000-08-09 22:31:24 +0000 | [diff] [blame] | 263 | for ( s = service_first; s; s = s->next ) |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 264 | { |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 265 | if ( s->self == service ) |
| 266 | { |
Alexandre Julliard | 000c980 | 1999-12-13 01:42:03 +0000 | [diff] [blame] | 267 | s->disabled = TRUE; |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 268 | retv = TRUE; |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 269 | break; |
| 270 | } |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 271 | } |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 272 | |
Eric Pouech | 63c7cdf | 1999-06-12 08:24:23 +0000 | [diff] [blame] | 273 | HeapUnlock( GetProcessHeap() ); |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 274 | |
Alexandre Julliard | 46733de | 2000-08-09 22:31:24 +0000 | [diff] [blame] | 275 | QueueUserAPC( NULL, service_thread, 0L ); |
Ulrich Weigand | 7761cbe | 1999-04-11 15:01:20 +0000 | [diff] [blame] | 276 | |
| 277 | return retv; |
| 278 | } |
| 279 | |
| 280 | |