// File: /workspace/github_cpp_makefile_star2_O2/enbock[P]Warp10Server/warp10server/src/Network/WebListener.cpp
// Function: Warp10::Network::WebListener::listenSocket(u::Object*)
void WebListener::listenSocket(Object* arg)
{
	lock();
	Socket* listener = _socket;
	unlock();

	if(!valid(listener)) return;
	trace(className() + "::listenSocket: Wait for connection...");
	Socket* newSocket = listener->accept();

	lock();
	if(newSocket == null)
	{
		// listening interrupted...socket closed?
		if(valid(_socket) && _socket->isConnected())
		{
			error(className()+"::listenSocket: Error on getting connection.");
		}
		else
		{
			trace(className() + "::listenSocket: Stop listening.");
			unlock();
			checkClosed();
			return;
		}
	}
	else
	{
		trace(className()+"::listenSocket: Incomming connection.");
		IConnection* newConnection = _builder->createConnection(newSocket);
		if(newConnection != null && _isClosed == false)
		{
			_connections.push(newConnection);

			newConnection->addEventListener(
				u::Network::Event::CLOSED
				, Callback(
					this, cb_cast(&WebListener::onConnectionClosed)
				)
			);

			WebEvent connectionCreated(
				WebEvent::INCOMMING_CONNECTION
				, (WebConnection*)newConnection
			);
			unlock();
			dispatchEvent(&connectionCreated);
			lock();
		}
		else
		{
			error(
				className()
				+ "::listenSocket: Can not etablish incomming conection"
			);
			newSocket->destroy();
		}
	}
	unlock();

	//self start ;)
	Callback cb(this, cb_cast(&WebListener::listenSocket));
	ThreadSystem::create(&cb);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x210, %rsp            # imm = 0x210
movq %rdi, %rbx
callq 0x40c442
movq 0x90(%rbx), %r14
movq %rbx, %rdi
callq 0x40c3fe
movq %r14, %rdi
callq 0x40d1b6
testb %al, %al
je 0x40882b
movq $0x64ec20, %rdi         # imm = 0x64EC20
leaq 0x1bebda(%rip), %rsi    # 0x5c7091
callq 0x489b70
movq %rax, %r15
movq (%rbx), %rax
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
callq *0x8(%rax)
leaq 0x60(%rsp), %rsi
leaq 0x1bf0f9(%rip), %rdx    # 0x5c75d2
leaq 0x8(%rsp), %rdi
callq 0x405349
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x49c3f0
leaq 0x1bebb4(%rip), %rsi    # 0x5c70ab
movq %rax, %rdi
callq 0x489b70
movq %rax, %rdi
callq 0x489450
leaq 0x8(%rsp), %rdi
callq 0x499a70
leaq 0x28(%rsp), %rdi
callq 0x4050e8
movq %r14, %rdi
callq 0x40e86c
movq %rax, %r14
movq %rbx, %rdi
callq 0x40c442
testq %r14, %r14
je 0x40865b
movq $0x64ec20, %rdi         # imm = 0x64EC20
leaq 0x1beb4c(%rip), %rsi    # 0x5c7091
callq 0x489b70
movq %rax, %r15
movq (%rbx), %rax
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
callq *0x8(%rax)
leaq 0x60(%rsp), %rsi
leaq 0x1bf0df(%rip), %rdx    # 0x5c7646
leaq 0x8(%rsp), %rdi
callq 0x405349
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x49c3f0
leaq 0x1beb26(%rip), %rsi    # 0x5c70ab
movq %rax, %rdi
callq 0x489b70
movq %rax, %rdi
callq 0x489450
leaq 0x8(%rsp), %rdi
callq 0x499a70
leaq 0x28(%rsp), %rdi
callq 0x4050e8
movq 0x88(%rbx), %rdi
movq (%rdi), %rax
movq %r14, %rsi
callq *0x28(%rax)
testq %rax, %rax
je 0x4086f7
cmpb $0x0, 0xe8(%rbx)
jne 0x4086f7
movq %rax, %r15
leaq 0x98(%rbx), %rdi
movq %rax, %rsi
callq 0x408a66
leaq 0x1b8(%rsp), %r14
pushq $0x49
popq %rdx
movq %r14, %rdi
movq %rbx, %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x409b80
movq $0x64dc40, %rsi         # imm = 0x64DC40
movq %r15, %rdi
movq %r14, %rdx
callq 0x40abb6
leaq 0x1b8(%rsp), %rdi
callq 0x40c544
movq $0x64d748, %rsi         # imm = 0x64D748
leaq 0x28(%rsp), %rdi
movq %r15, %rdx
callq 0x407b10
movq %rbx, %rdi
callq 0x40c3fe
leaq 0x28(%rsp), %rsi
movq %rbx, %rdi
callq 0x40ad2c
movq %rbx, %rdi
callq 0x40c442
leaq 0x28(%rsp), %rdi
callq 0x407b88
jmp 0x408771
movq 0x90(%rbx), %rdi
callq 0x40d1b6
testb %al, %al
je 0x4087a8
movq 0x90(%rbx), %rdi
callq 0x40dc34
testb %al, %al
je 0x4087a8
movq $0x64eb00, %rdi         # imm = 0x64EB00
leaq 0x1beac2(%rip), %rsi    # 0x5c7153
callq 0x489b70
movq %rax, %r14
movq (%rbx), %rax
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
callq *0x8(%rax)
leaq 0x60(%rsp), %rsi
leaq 0x1bef46(%rip), %rdx    # 0x5c75f9
leaq 0x8(%rsp), %rdi
callq 0x405349
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x49c3f0
leaq 0x1be9da(%rip), %rsi    # 0x5c70ab
movq %rax, %rdi
callq 0x489b70
movq %rax, %rdi
callq 0x489450
leaq 0x8(%rsp), %rdi
callq 0x499a70
leaq 0x28(%rsp), %rdi
callq 0x4050e8
jmp 0x408771
movq $0x64eb00, %rdi         # imm = 0x64EB00
leaq 0x1bea4e(%rip), %rsi    # 0x5c7153
callq 0x489b70
movq %rax, %r15
movq (%rbx), %rax
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
callq *0x8(%rax)
leaq 0x60(%rsp), %rsi
leaq 0x1bef45(%rip), %rdx    # 0x5c766c
leaq 0x8(%rsp), %rdi
callq 0x405349
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x49c3f0
leaq 0x1be966(%rip), %rsi    # 0x5c70ab
movq %rax, %rdi
callq 0x489b70
movq %rax, %rdi
callq 0x489450
leaq 0x8(%rsp), %rdi
callq 0x499a70
leaq 0x28(%rsp), %rdi
callq 0x4050e8
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
movq %rbx, %rdi
callq 0x40c3fe
leaq 0x28(%rsp), %r14
pushq $0x41
popq %rdx
movq %r14, %rdi
movq %rbx, %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x409b80
movq %r14, %rdi
callq 0x40edd0
leaq 0x28(%rsp), %rdi
callq 0x40c544
jmp 0x40882b
movq $0x64ec20, %rdi         # imm = 0x64EC20
leaq 0x1be8db(%rip), %rsi    # 0x5c7091
callq 0x489b70
movq %rax, %r14
movq (%rbx), %rax
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
callq *0x8(%rax)
leaq 0x60(%rsp), %rsi
leaq 0x1bee4e(%rip), %rdx    # 0x5c7626
leaq 0x8(%rsp), %rdi
callq 0x405349
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x49c3f0
leaq 0x1be8b5(%rip), %rsi    # 0x5c70ab
movq %rax, %rdi
callq 0x489b70
movq %rax, %rdi
callq 0x489450
leaq 0x8(%rsp), %rdi
callq 0x499a70
leaq 0x28(%rsp), %rdi
callq 0x4050e8
movq %rbx, %rdi
callq 0x40c3fe
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x28(%rax)
addq $0x210, %rsp            # imm = 0x210
popq %rbx
popq %r14
popq %r15
retq
jmp 0x408871
jmp 0x408878
jmp 0x408871
movq %rax, %rbx
leaq 0x1b8(%rsp), %rdi
jmp 0x408857
jmp 0x408871
jmp 0x408871
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x40c544
jmp 0x40888f
jmp 0x408878
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x407b88
jmp 0x40888f
jmp 0x408878
movq %rax, %rbx
jmp 0x408885
jmp 0x408878
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x499a70
leaq 0x28(%rsp), %rdi
callq 0x4050e8
movq %rbx, %rdi
callq 0x4ca950
nop