DTHREAD::~DTHREAD() /*++ Routine Description: DTHREAD object destructor. This procedure has the responsibility to perform any required shutdown operations for the DTHREAD object before the object memory is deallocated. The caller is reponsible for removing the object from its list in the DPROCESS object before destroying the DTHREAD object. This procedure takes care of removing the DTHREAD object from thread-local storage. Arguments: None Return Value: None --*/ { BOOL bresult; DEBUGF( DBG_TRACE, ("Freeing dthread %X\n", this)); assert(sm_tls_index != TLS_OUT_OF_INDEXES); m_blocking_hook = NULL; delete m_hostent_buffer; delete m_servent_buffer; delete m_proto_info; bresult = TlsSetValue( sm_tls_index, // dwTlsIndex (LPVOID) NULL // lpvTlsValue ); if (! bresult) { DEBUGF( DBG_WARN, ("Resetting Thread-local storage for this thread\n")); } WahCloseThread( m_wah_helper_handle, & m_wah_thread_id); m_wah_helper_handle = NULL; m_process = NULL; } //~DTHREAD
VOID WSAAPI WsThreadDelete(IN PWSTHREAD Thread) { /* Remove the blocking hook */ Thread->BlockingHook = NULL; /* Free our buffers */ if (Thread->Hostent) HeapFree(WsSockHeap, 0, Thread->Hostent); if (Thread->Servent) HeapFree(WsSockHeap, 0, Thread->Servent); if (Thread->ProtocolInfo) HeapFree(WsSockHeap, 0, Thread->ProtocolInfo); /* Clear the TLS */ TlsSetValue(TlsIndex, NULL); /* Close the WAH Handle */ WahCloseThread(Thread->AsyncHelper, &Thread->WahThreadId); /* Unlink the process and free us */ Thread->Process = NULL; HeapFree(WsSockHeap, 0, Thread); }