Memory leak fix in threadutil
Put thread in a detached state when calling pthread_create otherwise in
some circumstances, thread can end before the call to pthread_detach.
(cherry picked from commit dc4eda529f
)
This commit is contained in:
parent
b58ee1930c
commit
3d46251c4e
@ -332,6 +332,15 @@ Version 1.8.0
|
|||||||
Version 1.6.17
|
Version 1.6.17
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
|
|
||||||
|
2012-04-02 Fabrice Fontaine <fabrice.fontaine(at)orange.com>
|
||||||
|
|
||||||
|
SF Bug Tracker id 3514145 - Memory leak fix in threadutil
|
||||||
|
|
||||||
|
Submitted: Fabrice Fontaine ( ffontaine ) - 2012-04-02 06:49:20 PDT
|
||||||
|
|
||||||
|
Put thread in a detached state when calling ithread_create otherwise in
|
||||||
|
some circumstances, thread can end before the call to ithread_detach.
|
||||||
|
|
||||||
2012-03-30 Fabrice Fontaine <fabrice.fontaine(at)orange.com>
|
2012-03-30 Fabrice Fontaine <fabrice.fontaine(at)orange.com>
|
||||||
|
|
||||||
Add --enable-unspecified_server
|
Add --enable-unspecified_server
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
* Copyright (c) 2012 France Telecom All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@ -76,7 +77,8 @@ extern "C" {
|
|||||||
|
|
||||||
|
|
||||||
#define ITHREAD_STACK_MIN PTHREAD_STACK_MIN
|
#define ITHREAD_STACK_MIN PTHREAD_STACK_MIN
|
||||||
|
#define ITHREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED
|
||||||
|
#define ITHREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Name: ithread_t
|
* Name: ithread_t
|
||||||
@ -778,6 +780,22 @@ static UPNP_INLINE int ithread_cleanup_thread(void) {
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#define ithread_attr_setstacksize pthread_attr_setstacksize
|
#define ithread_attr_setstacksize pthread_attr_setstacksize
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Function: ithread_attr_setdetachstate
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Sets detach state of a thread attribute object.
|
||||||
|
* Parameters:
|
||||||
|
* ithread_attr_t *attr (must be valid non NULL pointer to
|
||||||
|
* ithread_attr_t)
|
||||||
|
* int detachstate (value of detachstate must be ITHREAD_CREATE_DETACHED
|
||||||
|
* or ITHREAD_CREATE_JOINABLE)
|
||||||
|
* Returns:
|
||||||
|
* 0 on success. Nonzero on failure.
|
||||||
|
* See man page for pthread_attr_setdetachstate
|
||||||
|
***************************************************************************/
|
||||||
|
#define ithread_attr_setdetachstate pthread_attr_setdetachstate
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ithread_create
|
* Function: ithread_create
|
||||||
*
|
*
|
||||||
|
@ -647,10 +647,15 @@ static int CreateWorker(
|
|||||||
}
|
}
|
||||||
ithread_attr_init(&attr);
|
ithread_attr_init(&attr);
|
||||||
ithread_attr_setstacksize(&attr, tp->attr.stackSize);
|
ithread_attr_setstacksize(&attr, tp->attr.stackSize);
|
||||||
|
ithread_attr_setdetachstate(&attr, ITHREAD_CREATE_DETACHED);
|
||||||
rc = ithread_create(&temp, &attr, WorkerThread, tp);
|
rc = ithread_create(&temp, &attr, WorkerThread, tp);
|
||||||
ithread_attr_destroy(&attr);
|
ithread_attr_destroy(&attr);
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
rc = ithread_detach(temp);
|
rc = ithread_detach(temp);
|
||||||
|
/* ithread_detach will return EINVAL if thread has been
|
||||||
|
successfully detached by ithread_create */
|
||||||
|
if (rc == EINVAL)
|
||||||
|
rc = 0;
|
||||||
tp->pendingWorkerThreadStart = 1;
|
tp->pendingWorkerThreadStart = 1;
|
||||||
/* wait until the new worker thread starts */
|
/* wait until the new worker thread starts */
|
||||||
while (tp->pendingWorkerThreadStart) {
|
while (tp->pendingWorkerThreadStart) {
|
||||||
|
Loading…
Reference in New Issue
Block a user