SF Bug Tracker [ 2392166 ] ithread_detach not called for finished worker thread
Submitted: Ulrik ( ulsv_enea ) - 2008-12-05 08:24 Valgrind reports a memory leak due to that the function ithread_detach is not called for finished worker threads in ThreadPool.c. ==21137== 2,176 bytes in 8 blocks are possibly lost in loss record 5 of 5 ==21137== at 0x4C20F3F: calloc (vg_replace_malloc.c:279) ==21137== by 0x4010F58: _dl_allocate_tls (in /lib/ld-2.6.1.so) ==21137== by 0x544BA92: pthread_create@@GLIBC_2.2.5 (in /lib/libpthread-2.6.1.so) ==21137== by 0x5F94592: CreateWorker (ThreadPool.c:639) ==21137== by 0x5F95079: ThreadPoolInit (ThreadPool.c:784) I'm using libupnp 1.6.6 For more info on pthread_detach, see: http://gelorakan.wordpress.com/2007/11/26/pthead_create-valgrind-memory-lea k-solved/ git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@520 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
parent
712ed6d2ff
commit
6aa2419cfd
21
ChangeLog
21
ChangeLog
@ -2,6 +2,27 @@
|
|||||||
Version 1.6.7
|
Version 1.6.7
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
|
|
||||||
|
2010-03-21 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* SF Bug Tracker [ 2392166 ] ithread_detach not called for finished worker thread
|
||||||
|
Submitted: Ulrik ( ulsv_enea ) - 2008-12-05 08:24
|
||||||
|
|
||||||
|
Valgrind reports a memory leak due to that the function ithread_detach is
|
||||||
|
not called for finished worker threads in ThreadPool.c.
|
||||||
|
|
||||||
|
==21137== 2,176 bytes in 8 blocks are possibly lost in loss record 5 of 5
|
||||||
|
==21137== at 0x4C20F3F: calloc (vg_replace_malloc.c:279)
|
||||||
|
==21137== by 0x4010F58: _dl_allocate_tls (in /lib/ld-2.6.1.so)
|
||||||
|
==21137== by 0x544BA92: pthread_create@@GLIBC_2.2.5 (in
|
||||||
|
/lib/libpthread-2.6.1.so)
|
||||||
|
==21137== by 0x5F94592: CreateWorker (ThreadPool.c:639)
|
||||||
|
==21137== by 0x5F95079: ThreadPoolInit (ThreadPool.c:784)
|
||||||
|
|
||||||
|
I'm using libupnp 1.6.6
|
||||||
|
|
||||||
|
For more info on pthread_detach, see:
|
||||||
|
http://gelorakan.wordpress.com/2007/11/26/pthead_create-valgrind-memory-lea
|
||||||
|
k-solved/
|
||||||
|
|
||||||
2010-03-21 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
2010-03-21 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
* SF Bug Tracker [ 2392304 ] Memory leak in SSDP AdvertiseAndReply
|
* SF Bug Tracker [ 2392304 ] Memory leak in SSDP AdvertiseAndReply
|
||||||
Submitted: Ulrik ( ulsv_enea ) - 2008-12-05 08:24
|
Submitted: Ulrik ( ulsv_enea ) - 2008-12-05 08:24
|
||||||
|
@ -1,33 +1,33 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* 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:
|
||||||
//
|
*
|
||||||
// * Redistributions of source code must retain the above copyright notice,
|
* - Redistributions of source code must retain the above copyright notice,
|
||||||
// this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
// * Neither name of Intel Corporation nor the names of its contributors
|
* - Neither name of Intel Corporation nor the names of its contributors
|
||||||
// may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "sample_util.h"
|
#include "sample_util.h"
|
||||||
|
@ -1,33 +1,33 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* 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:
|
||||||
//
|
*
|
||||||
// * Redistributions of source code must retain the above copyright notice,
|
* - Redistributions of source code must retain the above copyright notice,
|
||||||
// this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
// * Neither name of Intel Corporation nor the names of its contributors
|
* - Neither name of Intel Corporation nor the names of its contributors
|
||||||
// may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
******************************************************************************/
|
||||||
|
|
||||||
#include "upnp_tv_ctrlpt.h"
|
#include "upnp_tv_ctrlpt.h"
|
||||||
|
|
||||||
@ -1320,12 +1320,12 @@ TvCtrlPointVerifyTimeouts( int incr )
|
|||||||
* None
|
* None
|
||||||
*
|
*
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
void *
|
static int TvCtrlPointTimerLoopRun = 1;
|
||||||
TvCtrlPointTimerLoop( void *args )
|
void *TvCtrlPointTimerLoop(void *args)
|
||||||
{
|
{
|
||||||
int incr = 30; // how often to verify the timeouts, in seconds
|
int incr = 30; // how often to verify the timeouts, in seconds
|
||||||
|
|
||||||
while( 1 ) {
|
while (TvCtrlPointTimerLoopRun) {
|
||||||
isleep( incr );
|
isleep( incr );
|
||||||
TvCtrlPointVerifyTimeouts( incr );
|
TvCtrlPointVerifyTimeouts( incr );
|
||||||
}
|
}
|
||||||
@ -1348,70 +1348,72 @@ TvCtrlPointTimerLoop( void *args )
|
|||||||
* TV_SUCCESS if everything went well, else TV_ERROR
|
* TV_SUCCESS if everything went well, else TV_ERROR
|
||||||
*
|
*
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
int
|
int TvCtrlPointStart(print_string printFunctionPtr, state_update updateFunctionPtr)
|
||||||
TvCtrlPointStart( print_string printFunctionPtr,
|
|
||||||
state_update updateFunctionPtr )
|
|
||||||
{
|
{
|
||||||
ithread_t timer_thread;
|
ithread_t timer_thread;
|
||||||
int rc;
|
int rc;
|
||||||
unsigned short port = 0;
|
unsigned short port = 0;
|
||||||
char *ip_address = NULL;
|
char *ip_address = NULL;
|
||||||
|
|
||||||
SampleUtil_Initialize( printFunctionPtr );
|
SampleUtil_Initialize(printFunctionPtr);
|
||||||
SampleUtil_RegisterUpdateFunction( updateFunctionPtr );
|
SampleUtil_RegisterUpdateFunction(updateFunctionPtr);
|
||||||
|
|
||||||
ithread_mutex_init( &DeviceListMutex, 0 );
|
ithread_mutex_init(&DeviceListMutex, 0);
|
||||||
|
|
||||||
SampleUtil_Print(
|
SampleUtil_Print(
|
||||||
"Initializing UPnP Sdk with\n"
|
"Initializing UPnP Sdk with\n"
|
||||||
"\tipaddress = %s port = %u\n",
|
"\tipaddress = %s port = %u\n",
|
||||||
ip_address, port );
|
ip_address, port);
|
||||||
|
|
||||||
rc = UpnpInit( ip_address, port );
|
rc = UpnpInit(ip_address, port);
|
||||||
if( UPNP_E_SUCCESS != rc ) {
|
if (rc != UPNP_E_SUCCESS) {
|
||||||
SampleUtil_Print( "WinCEStart: UpnpInit() Error: %d", rc );
|
SampleUtil_Print("WinCEStart: UpnpInit() Error: %d", rc);
|
||||||
//UpnpFinish();
|
/*
|
||||||
//return TV_ERROR;
|
UpnpFinish();
|
||||||
}
|
return TV_ERROR;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
if (!ip_address) {
|
||||||
|
ip_address = UpnpGetServerIpAddress();
|
||||||
|
}
|
||||||
|
if (!port) {
|
||||||
|
port = UpnpGetServerPort();
|
||||||
|
}
|
||||||
|
|
||||||
if( NULL == ip_address ) {
|
SampleUtil_Print(
|
||||||
ip_address = UpnpGetServerIpAddress();
|
"UPnP Initialized\n"
|
||||||
}
|
"\tipaddress= %s port = %u\n",
|
||||||
if( 0 == port ) {
|
ip_address, port);
|
||||||
port = UpnpGetServerPort();
|
|
||||||
}
|
|
||||||
|
|
||||||
SampleUtil_Print(
|
SampleUtil_Print("Registering Control Point");
|
||||||
"UPnP Initialized\n"
|
rc = UpnpRegisterClient(TvCtrlPointCallbackEventHandler,
|
||||||
"\tipaddress= %s port = %u\n",
|
&ctrlpt_handle, &ctrlpt_handle);
|
||||||
ip_address, port );
|
if (rc != UPNP_E_SUCCESS) {
|
||||||
|
SampleUtil_Print( "Error registering CP: %d", rc );
|
||||||
|
UpnpFinish();
|
||||||
|
|
||||||
SampleUtil_Print( "Registering Control Point" );
|
return TV_ERROR;
|
||||||
rc = UpnpRegisterClient( TvCtrlPointCallbackEventHandler,
|
}
|
||||||
&ctrlpt_handle, &ctrlpt_handle );
|
|
||||||
if( UPNP_E_SUCCESS != rc ) {
|
|
||||||
SampleUtil_Print( "Error registering CP: %d", rc );
|
|
||||||
UpnpFinish();
|
|
||||||
return TV_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
SampleUtil_Print( "Control Point Registered" );
|
SampleUtil_Print("Control Point Registered");
|
||||||
|
|
||||||
TvCtrlPointRefresh();
|
TvCtrlPointRefresh();
|
||||||
|
|
||||||
// start a timer thread
|
/* start a timer thread */
|
||||||
ithread_create( &timer_thread, NULL, TvCtrlPointTimerLoop, NULL );
|
ithread_create(&timer_thread, NULL, TvCtrlPointTimerLoop, NULL);
|
||||||
|
ithread_detach(timer_thread);
|
||||||
|
|
||||||
return TV_SUCCESS;
|
return TV_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int TvCtrlPointStop(void)
|
||||||
TvCtrlPointStop( void )
|
|
||||||
{
|
{
|
||||||
TvCtrlPointRemoveAll();
|
TvCtrlPointTimerLoopRun = 0;
|
||||||
UpnpUnRegisterClient( ctrlpt_handle );
|
TvCtrlPointRemoveAll();
|
||||||
UpnpFinish();
|
UpnpUnRegisterClient( ctrlpt_handle );
|
||||||
SampleUtil_Finish();
|
UpnpFinish();
|
||||||
|
SampleUtil_Finish();
|
||||||
|
|
||||||
return TV_SUCCESS;
|
return TV_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,33 +1,33 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* 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:
|
||||||
//
|
*
|
||||||
// * Redistributions of source code must retain the above copyright notice,
|
* - Redistributions of source code must retain the above copyright notice,
|
||||||
// this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
// * Neither name of Intel Corporation nor the names of its contributors
|
* - Neither name of Intel Corporation nor the names of its contributors
|
||||||
// may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "sample_util.h"
|
#include "sample_util.h"
|
||||||
@ -401,9 +401,7 @@ TvCtrlPointProcessCommand( char *cmdline )
|
|||||||
return TV_SUCCESS;
|
return TV_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int main( int argc, char **argv )
|
||||||
main( int argc,
|
|
||||||
char **argv )
|
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
ithread_t cmdloop_thread;
|
ithread_t cmdloop_thread;
|
||||||
@ -413,15 +411,14 @@ main( int argc,
|
|||||||
#endif
|
#endif
|
||||||
int code;
|
int code;
|
||||||
|
|
||||||
|
|
||||||
rc = TvCtrlPointStart( linux_print, NULL );
|
rc = TvCtrlPointStart( linux_print, NULL );
|
||||||
if( rc != TV_SUCCESS ) {
|
if( rc != TV_SUCCESS ) {
|
||||||
SampleUtil_Print( "Error starting UPnP TV Control Point" );
|
SampleUtil_Print( "Error starting UPnP TV Control Point" );
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
// start a command loop thread
|
/* start a command loop thread */
|
||||||
code =
|
code = ithread_create( &cmdloop_thread, NULL, TvCtrlPointCommandLoop, NULL );
|
||||||
ithread_create( &cmdloop_thread, NULL, TvCtrlPointCommandLoop,
|
|
||||||
NULL );
|
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
/*
|
/*
|
||||||
@ -437,5 +434,7 @@ main( int argc,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
rc = TvCtrlPointStop();
|
rc = TvCtrlPointStop();
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,33 +1,33 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* 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:
|
||||||
//
|
*
|
||||||
// * Redistributions of source code must retain the above copyright notice,
|
* - Redistributions of source code must retain the above copyright notice,
|
||||||
// this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
// * Neither name of Intel Corporation nor the names of its contributors
|
* - Neither name of Intel Corporation nor the names of its contributors
|
||||||
// may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
******************************************************************************/
|
||||||
|
|
||||||
#include "upnp_tv_ctrlpt.h"
|
#include "upnp_tv_ctrlpt.h"
|
||||||
|
|
||||||
@ -1320,12 +1320,12 @@ TvCtrlPointVerifyTimeouts( int incr )
|
|||||||
* None
|
* None
|
||||||
*
|
*
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
void *
|
static int TvCtrlPointTimerLoopRun = 1;
|
||||||
TvCtrlPointTimerLoop( void *args )
|
void *TvCtrlPointTimerLoop(void *args)
|
||||||
{
|
{
|
||||||
int incr = 30; // how often to verify the timeouts, in seconds
|
int incr = 30; // how often to verify the timeouts, in seconds
|
||||||
|
|
||||||
while( 1 ) {
|
while (TvCtrlPointTimerLoopRun) {
|
||||||
isleep( incr );
|
isleep( incr );
|
||||||
TvCtrlPointVerifyTimeouts( incr );
|
TvCtrlPointVerifyTimeouts( incr );
|
||||||
}
|
}
|
||||||
@ -1348,70 +1348,70 @@ TvCtrlPointTimerLoop( void *args )
|
|||||||
* TV_SUCCESS if everything went well, else TV_ERROR
|
* TV_SUCCESS if everything went well, else TV_ERROR
|
||||||
*
|
*
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
int
|
int TvCtrlPointStart(print_string printFunctionPtr, state_update updateFunctionPtr)
|
||||||
TvCtrlPointStart( print_string printFunctionPtr,
|
|
||||||
state_update updateFunctionPtr )
|
|
||||||
{
|
{
|
||||||
ithread_t timer_thread;
|
ithread_t timer_thread;
|
||||||
int rc;
|
int rc;
|
||||||
unsigned short port = 0;
|
unsigned short port = 0;
|
||||||
char *ip_address = NULL;
|
char *ip_address = NULL;
|
||||||
|
|
||||||
SampleUtil_Initialize( printFunctionPtr );
|
SampleUtil_Initialize(printFunctionPtr);
|
||||||
SampleUtil_RegisterUpdateFunction( updateFunctionPtr );
|
SampleUtil_RegisterUpdateFunction(updateFunctionPtr);
|
||||||
|
|
||||||
ithread_mutex_init( &DeviceListMutex, 0 );
|
ithread_mutex_init(&DeviceListMutex, 0);
|
||||||
|
|
||||||
SampleUtil_Print(
|
SampleUtil_Print(
|
||||||
"Initializing UPnP Sdk with\n"
|
"Initializing UPnP Sdk with\n"
|
||||||
"\tipaddress = %s port = %u\n",
|
"\tipaddress = %s port = %u\n",
|
||||||
ip_address, port );
|
ip_address, port);
|
||||||
|
|
||||||
rc = UpnpInit( ip_address, port );
|
rc = UpnpInit(ip_address, port);
|
||||||
if( UPNP_E_SUCCESS != rc ) {
|
if (rc != UPNP_E_SUCCESS) {
|
||||||
SampleUtil_Print( "WinCEStart: UpnpInit() Error: %d", rc );
|
SampleUtil_Print("WinCEStart: UpnpInit() Error: %d", rc);
|
||||||
UpnpFinish();
|
UpnpFinish();
|
||||||
return TV_ERROR;
|
return TV_ERROR;
|
||||||
}
|
}
|
||||||
|
if (!ip_address) {
|
||||||
|
ip_address = UpnpGetServerIpAddress();
|
||||||
|
}
|
||||||
|
if (!port) {
|
||||||
|
port = UpnpGetServerPort();
|
||||||
|
}
|
||||||
|
|
||||||
if( NULL == ip_address ) {
|
SampleUtil_Print(
|
||||||
ip_address = UpnpGetServerIpAddress();
|
"UPnP Initialized\n"
|
||||||
}
|
"\tipaddress= %s port = %u\n",
|
||||||
if( 0 == port ) {
|
ip_address, port);
|
||||||
port = UpnpGetServerPort();
|
|
||||||
}
|
|
||||||
|
|
||||||
SampleUtil_Print(
|
SampleUtil_Print("Registering Control Point");
|
||||||
"UPnP Initialized\n"
|
rc = UpnpRegisterClient(TvCtrlPointCallbackEventHandler,
|
||||||
"\tipaddress= %s port = %u\n",
|
&ctrlpt_handle, &ctrlpt_handle);
|
||||||
ip_address, port );
|
if (rc != UPNP_E_SUCCESS) {
|
||||||
|
SampleUtil_Print( "Error registering CP: %d", rc );
|
||||||
|
UpnpFinish();
|
||||||
|
|
||||||
SampleUtil_Print( "Registering Control Point" );
|
return TV_ERROR;
|
||||||
rc = UpnpRegisterClient( TvCtrlPointCallbackEventHandler,
|
}
|
||||||
&ctrlpt_handle, &ctrlpt_handle );
|
|
||||||
if( UPNP_E_SUCCESS != rc ) {
|
|
||||||
SampleUtil_Print( "Error registering CP: %d", rc );
|
|
||||||
UpnpFinish();
|
|
||||||
return TV_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
SampleUtil_Print( "Control Point Registered" );
|
SampleUtil_Print("Control Point Registered");
|
||||||
|
|
||||||
TvCtrlPointRefresh();
|
TvCtrlPointRefresh();
|
||||||
|
|
||||||
// start a timer thread
|
/* start a timer thread */
|
||||||
ithread_create( &timer_thread, NULL, TvCtrlPointTimerLoop, NULL );
|
ithread_create(&timer_thread, NULL, TvCtrlPointTimerLoop, NULL);
|
||||||
|
ithread_detach(timer_thread);
|
||||||
|
|
||||||
return TV_SUCCESS;
|
return TV_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int TvCtrlPointStop(void)
|
||||||
TvCtrlPointStop( void )
|
|
||||||
{
|
{
|
||||||
TvCtrlPointRemoveAll();
|
TvCtrlPointTimerLoopRun = 0;
|
||||||
UpnpUnRegisterClient( ctrlpt_handle );
|
TvCtrlPointRemoveAll();
|
||||||
UpnpFinish();
|
UpnpUnRegisterClient( ctrlpt_handle );
|
||||||
SampleUtil_Finish();
|
UpnpFinish();
|
||||||
|
SampleUtil_Finish();
|
||||||
|
|
||||||
return TV_SUCCESS;
|
return TV_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,33 +1,33 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* 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:
|
||||||
//
|
*
|
||||||
// * Redistributions of source code must retain the above copyright notice,
|
* - Redistributions of source code must retain the above copyright notice,
|
||||||
// this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
// * Neither name of Intel Corporation nor the names of its contributors
|
* - Neither name of Intel Corporation nor the names of its contributors
|
||||||
// may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "sample_util.h"
|
#include "sample_util.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user