Esempio n. 1
0
/**
 * Release a previously locked control point mutex.
 * See @ref cg_upnp_controlpoint_lock for a more detailed description on
 * the control point locking mechanism.
 *
 * @param ctrlPoint The control point in question
 */
BOOL cg_upnp_controlpoint_unlock(CgUpnpControlPoint *ctrlPoint)
{
	cg_log_debug_l4("Entering...\n");

	return cg_mutex_unlock(ctrlPoint->mutex);

	cg_log_debug_l4("Leaving...\n");
}
void cg_http_persistentconnection_unlock(void)
{
	cg_log_debug_l4("Entering...\n");

       if (persistent_connection_mutex == NULL) return;
       cg_mutex_unlock(persistent_connection_mutex);

	cg_log_debug_l4("Leaving...\n");
}
Esempio n. 3
0
void cg_upnp_controlpoint_adddevicebyssdppacket(CgUpnpControlPoint *ctrlPoint, CgUpnpSSDPPacket *ssdpPkt)
{
	CgUpnpDevice *dev = NULL;
	const char *usn = NULL;
	char udn[CG_UPNP_UDN_LEN_MAX];
	CG_UPNP_DEVICE_LISTENER listener = NULL;
	CgUpnpDeviceStatus status = 0;

	cg_log_debug_l4("Entering...\n");

	listener = cg_upnp_controlpoint_getdevicelistener(ctrlPoint);
	
	usn = cg_upnp_ssdp_packet_getusn(ssdpPkt);
	cg_upnp_usn_getudn(usn, udn, sizeof(udn));
	
	cg_upnp_controlpoint_lock(ctrlPoint);
	
	dev = cg_upnp_controlpoint_getdevicebyudn(ctrlPoint, udn);
	
	if (dev != NULL)
	{
		/* Device was found from local cache */
		if (cg_upnp_device_updatefromssdppacket(dev, ssdpPkt) == TRUE)
		{
			cg_mutex_lock(ctrlPoint->expMutex);
			cg_cond_signal(ctrlPoint->expCond);
			cg_mutex_unlock(ctrlPoint->expMutex);
			
			/* Device was successfully updated */
			status = CgUpnpDeviceStatusUpdated;
		}
		else
		{	/* Problems occurred in device update */
			status = CgUpnpDeviceStatusInvalid;
		}
	}
	else
	{
		/* This is a new device */
		dev = cg_upnp_controlpoint_createdevicefromssdkpacket(ssdpPkt);
		if (dev == NULL)
		{
			/* Problems occurred in device creation */
			status = CgUpnpDeviceStatusInvalid;
		}
		else
		{
			cg_upnp_controlpoint_adddevice(ctrlPoint, dev);

			/* Device added, wake up expirationhandler thread */
			cg_mutex_lock(ctrlPoint->expMutex);
			cg_cond_signal(ctrlPoint->expCond);
			cg_mutex_unlock(ctrlPoint->expMutex);
			
			status = CgUpnpDeviceStatusAdded;
		}
	}
	
	cg_upnp_controlpoint_unlock(ctrlPoint);
	
	if (listener != NULL)
	{
		listener(ctrlPoint, udn, status);
	}

	cg_log_debug_l4("Leaving...\n");
}