void TvCtrlPointVerifyTimeouts(int incr) { struct TvDeviceNode *prevdevnode; struct TvDeviceNode *curdevnode; int ret; ithread_mutex_lock(&DeviceListMutex); prevdevnode = NULL; curdevnode = GlobalDeviceList; while (curdevnode) { curdevnode->device.AdvrTimeOut -= incr; /*SampleUtil_Print("Advertisement Timeout: %d\n", curdevnode->device.AdvrTimeOut); */ if (curdevnode->device.AdvrTimeOut <= 0) { /* This advertisement has expired, so we should remove the device * from the list */ if (GlobalDeviceList == curdevnode) GlobalDeviceList = curdevnode->next; else prevdevnode->next = curdevnode->next; TvCtrlPointDeleteNode(curdevnode); if (prevdevnode) curdevnode = prevdevnode->next; else curdevnode = GlobalDeviceList; } else { if (curdevnode->device.AdvrTimeOut < 2 * incr) { /* This advertisement is about to expire, so * send out a search request for this device * UDN to try to renew */ ret = UpnpSearchAsync(ctrlpt_handle, incr, curdevnode->device.UDN, NULL); if (ret != UPNP_E_SUCCESS) SampleUtil_Print ("Error sending search request for Device UDN: %s -- err = %d\n", curdevnode->device.UDN, ret); } prevdevnode = curdevnode; curdevnode = curdevnode->next; } } ithread_mutex_unlock(&DeviceListMutex); }
/******************************************************************************** * TvCtrlPointRemoveAll * * Description: * Remove all devices from the global device list. * * Parameters: * None * ********************************************************************************/ int TvCtrlPointRemoveAll(void) { struct TvDeviceNode *curdevnode, *next; ithread_mutex_lock(&DeviceListMutex); curdevnode = GlobalDeviceList; GlobalDeviceList = NULL; while (curdevnode) { next = curdevnode->next; TvCtrlPointDeleteNode(curdevnode); curdevnode = next; } ithread_mutex_unlock(&DeviceListMutex); return TV_SUCCESS; }