Mercurial > cpython-lru_cache-weakref
comparison Python/thread.c @ 47665:71cb7ea4f110
Merged revisions 64212 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r64212 | benjamin.peterson | 2008-06-12 19:09:47 -0500 (Thu, 12 Jun 2008) | 3 lines
#1683 prevent forking from interfering in threading storage
This should prevent some test_multiprocessing failures
........
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Fri, 13 Jun 2008 00:26:50 +0000 |
| parents | fb5a6330f71b |
| children | 7779af388aec |
comparison
equal
deleted
inserted
replaced
| 47663:92b79b6d1a3b | 47665:71cb7ea4f110 |
|---|---|
| 375 q = &p->next; | 375 q = &p->next; |
| 376 } | 376 } |
| 377 PyThread_release_lock(keymutex); | 377 PyThread_release_lock(keymutex); |
| 378 } | 378 } |
| 379 | 379 |
| 380 /* Forget everything not associated with the current thread id. | |
| 381 * This function is called from PyOS_AfterFork(). It is necessary | |
| 382 * because other thread ids which were in use at the time of the fork | |
| 383 * may be reused for new threads created in the forked process. | |
| 384 */ | |
| 385 void | |
| 386 PyThread_ReInitTLS(void) | |
| 387 { | |
| 388 long id = PyThread_get_thread_ident(); | |
| 389 struct key *p, **q; | |
| 390 | |
| 391 if (!keymutex) | |
| 392 return; | |
| 393 | |
| 394 /* As with interpreter_lock in PyEval_ReInitThreads() | |
| 395 we just create a new lock without freeing the old one */ | |
| 396 keymutex = PyThread_allocate_lock(); | |
| 397 | |
| 398 /* Delete all keys which do not match the current thread id */ | |
| 399 q = &keyhead; | |
| 400 while ((p = *q) != NULL) { | |
| 401 if (p->id != id) { | |
| 402 *q = p->next; | |
| 403 free((void *)p); | |
| 404 /* NB This does *not* free p->value! */ | |
| 405 } | |
| 406 else | |
| 407 q = &p->next; | |
| 408 } | |
| 409 } | |
| 410 | |
| 380 #endif /* Py_HAVE_NATIVE_TLS */ | 411 #endif /* Py_HAVE_NATIVE_TLS */ |
