Logo Search packages:      
Sourcecode: libupnp4 version File versions  Download package

EXPORT_SPEC int UpnpFinish (  ) 

Terminates the Linux SDK for UPnP Devices.

  • Checks for pending jobs and threads
  • Unregisters either the client or device
  • Shuts down the Timer Thread
  • Stops the Mini Server
  • Uninitializes the Thread Pool
  • For Win32 cleans up Winsock Interface
  • Cleans up mutex objects
This function must be the last API function called. It should be called only once. Subsequent calls to this API return a UPNP_E_FINISH error code.

Returns:
An integer representing one of the following:
  • UPNP_E_SUCCESS: The operation completed successfully.
  • UPNP_E_FINISH: The SDK is already terminated or it is not initialized.

Definition at line 302 of file upnpapi.c.

References GetClientHandleInfo(), GetDeviceHandleInfo(), GlobalHndRWLock, gUUIDMutex, PrintThreadPoolStats(), StopMiniServer(), TimerThreadShutdown(), UPNP_E_FINISH, UPNP_E_SUCCESS, UpnpCloseLog(), UpnpPrintf(), UpnpRemoveAllVirtualDirs(), UpnpSdkInit, UpnpUnRegisterClient(), and UpnpUnRegisterRootDevice().

Referenced by UpnpInitPreamble(), UpnpInitStartServers(), and UpnpInitThreadPools().

{
#ifdef INCLUDE_DEVICE_APIS
      UpnpDevice_Handle device_handle;
#endif
#ifdef INCLUDE_CLIENT_APIS
      UpnpClient_Handle client_handle;
#endif
      struct Handle_Info *temp;

#ifdef WIN32
      //    WSACleanup();
#endif

      if( UpnpSdkInit != 1 ) {
            return UPNP_E_FINISH;
      }

      UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
            "Inside UpnpFinish: UpnpSdkInit is %d\n", UpnpSdkInit);
      if (UpnpSdkInit == 1) {
            UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
            "UpnpFinish: UpnpSdkInit is ONE\n");
      }
      PrintThreadPoolStats(&gSendThreadPool, __FILE__, __LINE__, "Send Thread Pool");
      PrintThreadPoolStats(&gRecvThreadPool, __FILE__, __LINE__, "Recv Thread Pool");
      PrintThreadPoolStats(&gMiniServerThreadPool, __FILE__, __LINE__, "MiniServer Thread Pool");

#ifdef INCLUDE_DEVICE_APIS
      if (GetDeviceHandleInfo(AF_INET, &device_handle, &temp) == HND_DEVICE ) {
            UpnpUnRegisterRootDevice(device_handle);
      }
      if (GetDeviceHandleInfo(AF_INET6, &device_handle, &temp) == HND_DEVICE ) {
            UpnpUnRegisterRootDevice(device_handle);
      }
#endif

#ifdef INCLUDE_CLIENT_APIS
      if (GetClientHandleInfo(&client_handle, &temp) == HND_CLIENT) {
            UpnpUnRegisterClient( client_handle );
      }
#endif

      TimerThreadShutdown(&gTimerThread);
      StopMiniServer();

#if EXCLUDE_WEB_SERVER == 0
      web_server_destroy();
#endif

      ThreadPoolShutdown(&gMiniServerThreadPool);
      PrintThreadPoolStats(&gMiniServerThreadPool, __FILE__, __LINE__, "MiniServer Thread Pool");
      ThreadPoolShutdown(&gRecvThreadPool);
      PrintThreadPoolStats(&gSendThreadPool, __FILE__, __LINE__, "Send Thread Pool");
      ThreadPoolShutdown(&gSendThreadPool);
      PrintThreadPoolStats(&gRecvThreadPool, __FILE__, __LINE__, "Recv Thread Pool");

#ifdef INCLUDE_CLIENT_APIS
      ithread_mutex_destroy(&GlobalClientSubscribeMutex);
#endif
      ithread_rwlock_destroy(&GlobalHndRWLock);
      ithread_mutex_destroy(&gUUIDMutex);

      // remove all virtual dirs
      UpnpRemoveAllVirtualDirs();

      // allow static linking
#ifdef WIN32
#ifdef PTW32_STATIC_LIB
      pthread_win32_thread_detach_np();
#endif
#endif

      UpnpSdkInit = 0;
      UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
      "Exiting UpnpFinish : UpnpSdkInit is :%d:\n", UpnpSdkInit);
      UpnpCloseLog();

      return UPNP_E_SUCCESS;
}


Generated by  Doxygen 1.6.0   Back to index