Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Unified Diff: nspr/pr/src/threads/prtpd.c

Issue 407383002: Update to NSPR 4.10.7 Beta 3. (Closed) Base URL: http://src.chromium.org/svn/trunk/deps/third_party/nss
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « nspr/pr/src/pthreads/ptsynch.c ('k') | patches/prcpucfg.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: nspr/pr/src/threads/prtpd.c
diff --git a/nspr/pr/src/threads/prtpd.c b/nspr/pr/src/threads/prtpd.c
index decbc1ccad30864a93e90150c45516a961292877..0eb2a011c62ab3a2fbd16bebf425cb0b6a49e13a 100644
--- a/nspr/pr/src/threads/prtpd.c
+++ b/nspr/pr/src/threads/prtpd.c
@@ -130,8 +130,9 @@ PR_IMPLEMENT(PRStatus) PR_NewThreadPrivateIndex(
** destructor function and a non-NULL per-thread-private data value,
** the destructor function is invoked.
**
-** This can return PR_FAILURE if index is invalid (ie., beyond the current
-** high water mark) or memory is insufficient to allocate an exanded vector.
+** This can return PR_FAILURE if index is invalid (ie., beyond the limit
+** on the TPD slots) or memory is insufficient to allocate an expanded
+** vector.
*/
PR_IMPLEMENT(PRStatus) PR_SetThreadPrivate(PRUintn index, void *priv)
@@ -139,11 +140,10 @@ PR_IMPLEMENT(PRStatus) PR_SetThreadPrivate(PRUintn index, void *priv)
PRThread *self = PR_GetCurrentThread();
/*
- ** The index being set might not have a sufficient vector in this
- ** thread. But if the index has been allocated, it's okay to go
- ** ahead and extend this one now.
+ ** To improve performance, we don't check if the index has been
+ ** allocated.
*/
- if ((index >= _PR_TPD_LIMIT) || (index >= _pr_tpd_highwater))
+ if (index >= _PR_TPD_LIMIT)
{
PR_SetError(PR_TPD_RANGE_ERROR, 0);
return PR_FAILURE;
@@ -152,6 +152,10 @@ PR_IMPLEMENT(PRStatus) PR_SetThreadPrivate(PRUintn index, void *priv)
PR_ASSERT(((NULL == self->privateData) && (0 == self->tpdLength))
|| ((NULL != self->privateData) && (0 != self->tpdLength)));
+ /*
+ ** If this thread does not have a sufficient vector for the index
+ ** being set, go ahead and extend this vector now.
+ */
if ((NULL == self->privateData) || (self->tpdLength <= index))
{
void *extension = PR_CALLOC(_pr_tpd_length * sizeof(void*));
« no previous file with comments | « nspr/pr/src/pthreads/ptsynch.c ('k') | patches/prcpucfg.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698