src/Cedar/Listener.c
// Thread that processes the accepted TCP connection

Thread that processes the accepted TCP connection
Thread that processes the accepted TCP connection
void TCPAcceptedThread(THREAD *t, void *param)
{
	TCP_ACCEPTED_PARAM *data;
	LISTENER *r;
	SOCK *s;
	CONNECTION *c;
	bool flag1;
	char tmp[128];
	if (t == NULL || param == NULL)
	{
		return;
	}
	data = (TCP_ACCEPTED_PARAM *)param;
	r = data->r;
	s = data->s;
	AddRef(r->ref);
	AddRef(s->ref);
	c = NewServerConnection(r->Cedar, s, t);
	AddRef(r->ref);
	c->Listener = r;
	AddConnection(c->Cedar, c);
	NoticeThreadInit(t);
	AcceptInit(s);
	StrCpy(c->ClientHostname, sizeof(c->ClientHostname), s->RemoteHostname);
	IPToStr(tmp, sizeof(tmp), &s->RemoteIP);
	if (IS_SPECIAL_PORT(s->RemotePort) == false)
	{
		SLog(r->Cedar, "LS_LISTENER_ACCEPT", r->Port, tmp, s->RemoteHostname, s->RemotePort);
	}
	ConnectionAccept(c);
	flag1 = c->flag1;
	SLog(r->Cedar, "LS_CONNECTION_END_1", c->Name);
	ReleaseListener(c->Listener);
	c->Listener = NULL;
	ReleaseConnection(c);
	if (flag1 == false)
	{
		Debug("%s %u flag1 == false\n", __FILE__, __LINE__);
		IPToStr(tmp, sizeof(tmp), &s->RemoteIP);
		if (IS_SPECIAL_PORT(s->RemotePort) == false)
		{
			SLog(r->Cedar, "LS_LISTENER_DISCONNECT", tmp, s->RemotePort);
		}
		Disconnect(s);
	}
	ReleaseSock(s);
	ReleaseListener(r);
}
void TCPAcceptedThread ( THREAD * t , void * param ) { TCP_ACCEPTED_PARAM * data ; LISTENER * r ; SOCK * s ; CONNECTION * c ; bool flag1 ; char tmp [ 128 ] ; if ( t == NULL || param == NULL ) { return ; } data = ( TCP_ACCEPTED_PARAM * ) param ; r = data -> r ; s = data -> s ; AddRef ( r -> ref ) ; AddRef ( s -> ref ) ; c = NewServerConnection ( r -> Cedar , s , t ) ; AddRef ( r -> ref ) ; c -> Listener = r ; AddConnection ( c -> Cedar , c ) ; NoticeThreadInit ( t ) ; AcceptInit ( s ) ; StrCpy ( c -> ClientHostname , sizeof ( c -> ClientHostname ) , s -> RemoteHostname ) ; IPToStr ( tmp , sizeof ( tmp ) , & s -> RemoteIP ) ; if ( IS_SPECIAL_PORT ( s -> RemotePort ) == false ) { SLog ( r -> Cedar , " " , r -> Port , tmp , s -> RemoteHostname , s -> RemotePort ) ; } ConnectionAccept ( c ) ; flag1 = c -> flag1 ; SLog ( r -> Cedar , " " , c -> Name ) ; ReleaseListener ( c -> Listener ) ; c -> Listener = NULL ; ReleaseConnection ( c ) ; if ( flag1 == false ) { Debug ( " \n " , __FILE__ , __LINE__ ) ; IPToStr ( tmp , sizeof ( tmp ) , & s -> RemoteIP ) ; if ( IS_SPECIAL_PORT ( s -> RemotePort ) == false ) { SLog ( r -> Cedar , " " , tmp , s -> RemotePort ) ; } Disconnect ( s ) ; } ReleaseSock ( s ) ; ReleaseListener ( r ) ; }
Thread that processes the accepted TCP connection
Thread that processes the accepted TCP connection
// Validate arguments
 // Initialize
 // Create a connection
 // Register to Cedar as a transient connection
 // Reception
 // Release
 // Release
