Changeset c13d67b82c674fffe5d65656aff7484c227a74a1
- Timestamp:
- 03/01/07 21:09:41
(1 year ago)
- Author:
- Rémi Denis-Courmont <rem@videolan.org>
- git-committer:
- Rémi Denis-Courmont <rem@videolan.org> 1172779781 +0000
- git-parent:
[1d58919125812d569c23bde687e42fca86858e33]
- git-author:
- Rémi Denis-Courmont <rem@videolan.org> 1172779781 +0000
- Message:
Fix race condition and simplify SigHandler?
Missing piece pointed out by Pierre d'H.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r1d58919 |
rc13d67b |
|
| 40 | 40 | extern void __wgetmainargs(int *argc, wchar_t ***wargv, wchar_t ***wenviron, |
|---|
| 41 | 41 | int expand_wildcards, int *startupinfo); |
|---|
| | 42 | static inline void Kill(void) { } |
|---|
| 42 | 43 | #else |
|---|
| 43 | 44 | |
|---|
| … | … | |
| 45 | 46 | # include <time.h> |
|---|
| 46 | 47 | # include <pthread.h> |
|---|
| 47 | | # include <stdbool.h> |
|---|
| 48 | | |
|---|
| 49 | | static struct |
|---|
| 50 | | { |
|---|
| 51 | | bool flag; |
|---|
| 52 | | pthread_mutex_t lock; |
|---|
| 53 | | } live = { true, PTHREAD_MUTEX_INITIALIZER }; |
|---|
| 54 | | |
|---|
| | 48 | |
|---|
| | 49 | static void Kill (void); |
|---|
| 55 | 50 | static void *SigHandler (void *set); |
|---|
| 56 | 51 | #endif |
|---|
| … | … | |
| 176 | 171 | VLC_CleanUp( 0 ); |
|---|
| 177 | 172 | |
|---|
| | 173 | Kill (); |
|---|
| | 174 | |
|---|
| 178 | 175 | /* Destroy the libvlc structure */ |
|---|
| 179 | 176 | VLC_Destroy( 0 ); |
|---|
| … | … | |
| 219 | 216 | |
|---|
| 220 | 217 | /* Acknowledge the signal received */ |
|---|
| 221 | | pthread_mutex_lock (&live.lock); |
|---|
| 222 | | if (live.flag) |
|---|
| 223 | | { |
|---|
| 224 | | VLC_Die (0); |
|---|
| 225 | | live.flag = false; |
|---|
| 226 | | } |
|---|
| 227 | | pthread_mutex_unlock (&live.lock); |
|---|
| | 218 | Kill (); |
|---|
| 228 | 219 | } |
|---|
| 229 | 220 | else if( time( NULL ) > abort_time + 2 ) |
|---|
| … | … | |
| 238 | 229 | /* Never reached */ |
|---|
| 239 | 230 | } |
|---|
| | 231 | |
|---|
| | 232 | |
|---|
| | 233 | static void KillOnce (void) |
|---|
| | 234 | { |
|---|
| | 235 | VLC_Die (0); |
|---|
| | 236 | } |
|---|
| | 237 | |
|---|
| | 238 | |
|---|
| | 239 | static void Kill (void) |
|---|
| | 240 | { |
|---|
| | 241 | static pthread_once_t once = PTHREAD_ONCE_INIT; |
|---|
| | 242 | pthread_once (&once, KillOnce); |
|---|
| | 243 | } |
|---|
| | 244 | |
|---|
| 240 | 245 | #endif |
|---|
| 241 | 246 | |
|---|