void NBCmdQueueDestroy(struct NBCmdQueue *queue) { TRACE(": queue %p\n", queue); if (queue) { NBCmdQueueCancelAll(queue); DeleteCriticalSection(&queue->cs); HeapFree(queue->heap, 0, queue); } }
static void nbShutdownAdapter(NetBIOSAdapter *adapter) { if (adapter) { adapter->shuttingDown = TRUE; NBCmdQueueCancelAll(adapter->cmdQueue); if (adapter->transport->cleanupAdapter) adapter->transport->cleanupAdapter(adapter->impl.data); NBCmdQueueDestroy(adapter->cmdQueue); DeleteCriticalSection(&adapter->cs); memset(adapter, 0, sizeof(NetBIOSAdapter)); } }
static UCHAR nbReset(NetBIOSAdapter *adapter, PNCB ncb) { UCHAR ret; TRACE(": adapter %p, ncb %p\n", adapter, ncb); if (!adapter) return NRC_BRIDGE; if (!ncb) return NRC_INVADDRESS; if (InterlockedIncrement(&adapter->resetting) == 1) { UCHAR i, resizeTo; NBCmdQueueCancelAll(adapter->cmdQueue); EnterCriticalSection(&adapter->cs); for (i = 0; i < adapter->sessionsLen; i++) if (adapter->sessions[i].inUse) nbInternalHangup(adapter, &adapter->sessions[i]); if (!ncb->ncb_lsn) resizeTo = ncb->ncb_callname[0] == 0 ? DEFAULT_NUM_SESSIONS : ncb->ncb_callname[0]; else if (adapter->sessionsLen == 0) resizeTo = DEFAULT_NUM_SESSIONS; else resizeTo = 0; if (resizeTo > 0) ret = nbResizeAdapter(adapter, resizeTo); else ret = NRC_GOODRET; LeaveCriticalSection(&adapter->cs); } else ret = NRC_TOOMANY; InterlockedDecrement(&adapter->resetting); TRACE("returning 0x%02x\n", ret); return ret; }