Esempio n. 1
0
// Stop all links
void StopAllLink(HUB *h)
{
	LINK **link_list;
	UINT num_link;
	UINT i;
	// Validate arguments
	if (h == NULL)
	{
		return;
	}

	LockList(h->LinkList);
	{
		link_list = ToArray(h->LinkList);
		num_link = LIST_NUM(h->LinkList);
		for (i = 0;i < num_link;i++)
		{
			AddRef(link_list[i]->ref);
		}
	}
	UnlockList(h->LinkList);

	for (i = 0;i < num_link;i++)
	{
		StopLink(link_list[i]);
		ReleaseLink(link_list[i]);
	}

	Free(link_list);
}
Esempio n. 2
0
BOOL CNetSock::AttachSocket(SOCKET hSocket, SOCKADDR_IN *pClientAddress)
{
	StopLink();
	
	m_hSocket = hSocket;
	m_Addr = *pClientAddress;
	
	m_bAttached = TRUE;
	
	m_Thread.SetName(_T("NetSock_AttachSocket"));
	return m_Thread.Create(this, THREAD_ID_SOCK);
}
Esempio n. 3
0
// リンクをオフラインにする
void SetLinkOffline(LINK *k)
{
	// 引数チェック
	if (k == NULL)
	{
		return;
	}

	if (k->Offline)
	{
		return;
	}

	StopLink(k);
	k->Offline = true;
}
Esempio n. 4
0
// Make the link off-line
void SetLinkOffline(LINK *k)
{
	// Validate arguments
	if (k == NULL)
	{
		return;
	}

	if (k->Offline)
	{
		return;
	}

	StopLink(k);
	k->Offline = true;
}
Esempio n. 5
0
BOOL CNetSock::CreateLink(LPCTSTR ServerName, int ServerPort)
{
	StopLink();
	
	m_hSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
	if(m_hSocket == INVALID_SOCKET)
		return FALSE;

//	int flag = 1;
//	setsockopt(m_hSocket,
//							IPPROTO_TCP,
//							TCP_NODELAY,
//							(char *) &flag,
//							sizeof(int));

	m_bEncryption = FALSE;
	m_ServerName = ServerName;
	m_ServerPort = ServerPort;
	
	m_Thread.SetName(_T("NetSock_CreateLink"));
	return m_Thread.Create(this, THREAD_ID_SOCK);
}
Esempio n. 6
0
	/* \fn  DetachProcessor
	  \brief Delete device from link,
	         but device object is not delete in function
	  \return void
	*/
	virtual bool DetachProcessor()
	{
		if (StopLink())
		{
			bool rtVal = true;
			if (m_section.try_lock())
			{
				p_Processor = 0;
				//p_Producer->p_LinkOn = NULL_POINTER;
				m_section.unlock();
			}
			else
			{
				rtVal = false;
				WRITE_LOG(severity_level::warning, "");
			}
			return rtVal;
		}
		else
		{
			WRITE_LOG(severity_level::error, "");
		}
		return false;
	}
Esempio n. 7
0
	/* \fn  DetachConsumer
	  \brief Delete device from link,
	         but device object is not delete in function
	  \return void
	*/
	virtual bool DetachConsumer()
	{
		if (StopLink())
		{
			bool rtVal = true;
			if (m_section.try_lock())
			{
				p_Consumer = 0;
				//p_Producer->linkInPool.Del((void*)this);
				m_section.unlock();
			}
			else
			{
				rtVal = false;
				WRITE_LOG(severity_level::warning, "");
			}
			return rtVal;
		}
		else
		{
			WRITE_LOG(severity_level::error, "");
		}
		return false;
	}
Esempio n. 8
0
	/* \fn  AttachProcessor
	  \brief Add device to link
	  \param[in] IProcessor<T1, T2>* pProcessor = (IProcessor<T1, T2>*)&processorObj;
	  \return bool
	*/
	virtual bool AttachProcessor(IProcessor<T1, T2>* pProcessor)
	{
		if (StopLink())
		{
			bool rtVal = true;
			if (m_section.try_lock())
			{
				p_Processor = pProcessor;
				//p_Producer->p_LinkOn = (void*)this;
				m_section.unlock();
			}
			else
			{
				rtVal = false;
				WRITE_LOG(severity_level::warning, "");
			}
			return rtVal;
		}
		else
		{
			WRITE_LOG(severity_level::error, "");
		}
		return false;
	}
Esempio n. 9
0
	/* \fn  AttachProducer
	  \brief Add producer to link
	  \param[in] IProducer<T1>* pProducer = (IProducer<T1>*)&producerObj;
	  \return bool
	*/
	virtual bool AttachProducer(IProducer<T1>* pProducer) 
	{
		if (StopLink())
		{
			bool rtVal = true;
			if (m_section.try_lock())
			{
				p_Producer = pProducer;
				//p_Producer->linkOutPool.Add((void*)this);
				m_section.unlock();
			}
			else
			{
				rtVal = false;
				WRITE_LOG(severity_level::warning, "");
			}
			return rtVal;
		}
		else
		{
			WRITE_LOG(severity_level::error, "");
		}
		return false;
	}
Esempio n. 10
0
	/* \fn  Unitial
	  \brief Unitial Link
	*/
	virtual void Unitial()
	{
		try
		{
			if (m_handle != INVALID_HANDLE)
			{
				//Do something here
				//...
				StopLink();
				DetachProducer();
				DetachConsumer();
				DetachProcessor();
				ForceEnd();
				m_handle = INVALID_HANDLE;
			}
			m_status = LK_UNITIALED;
		}
		catch (...)
		{
			WRITE_LOG(severity_level::error, "");
			return;
		}
		return;
	}
Esempio n. 11
0
CNetSock::~CNetSock()
{
	StopLink();
	delete []m_pTempBuf;
}