// File: /workspace/github_cpp_makefile_star2_O2/QZzcoder[P]LiveChat/server.cpp
// Function: oneLoop()
void oneLoop(){
    while(1){
        char recv_buff[255];
        int sock = bq.take();
        if(sock == -404){
            break;
        }else if(sock == socket_fd){
            cout<<getTime()<<"User sign up：";
            int client_fd = accept(socket_fd,(struct sockaddr*)&client,&len);
            if (client_fd == -1)
            {
                cout << "accept错误\n" << endl;
                exit(-1);
            }
            char signMsg[255];

            ssize_t recv_size = read(client_fd,signMsg,255);
            vector<string> vec = splitString(signMsg,'@');
            ::memset(signMsg,0,255);

            if(vec.size() != 2 ||!userCheck(vec[0],vec[1])){//登录失败
                send(client_fd,"N",1,0);
                cout<<" fail\n";
                close(client_fd);
            }else{
                cout<<vec[0]<<endl;
                cout<<"old msg to "<<vec[0]<<endl;
                vector<string> oldMsg = getOldMsg(vec[0]);
                for(string s:oldMsg){
                    cout<<"    "<<s;
                    send(client_fd,s.c_str(),s.size(),0);
                }
                clientSelectSet.insert(client_fd);
                name2sock[vec[0]] = client_fd;
            }
        }else if(clientSelectSet.count(sock) == 1){
            int activeClient = sock;
            string oriName;
            for(auto it:name2sock){
                if(it.second == activeClient){
                    oriName = it.first;
                    break;
                }
            }
            ssize_t recv_size = read(activeClient,recv_buff,255);
            if(recv_size<=0){//客户端退出
                updateTime(oriName);
                clientSelectSet.erase(name2sock[oriName]);
                name2sock.erase(oriName);
                continue;
            }
            vector<string> msg = splitString(recv_buff,'>');
            if(msg.size() != 0){
                storeMessage(oriName,msg[0],msg[1]);
                msg[1] = oriName + ":" + msg[1];
                send(name2sock[msg[0]],msg[1].c_str(),msg[1].size(),0);
            }
            cout<<getTime();
            ::printf("message:%s",recv_buff);
            ::memset(recv_buff,0,sizeof(recv_buff));
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x388, %rsp            # imm = 0x388
leaq -0x2b0(%rbp), %r14
movq 0x6d47(%rip), %r15      # 0xafd8
leaq -0x88(%rbp), %r12
leaq 0x6ff1(%rip), %rdi      # 0xb290
callq 0x50da
movl %eax, -0x30(%rbp)
cmpl $0xfffffe6c, %eax       # imm = 0xFFFFFE6C
je 0x4758
cmpl 0x7080(%rip), %eax      # 0xb338
jne 0x4484
movq %r14, %rdi
callq 0x6999
movq %r15, %rdi
movq %r14, %rsi
callq 0x3260
movq %rax, %rdi
leaq 0x2e7d(%rip), %rsi      # 0x7158
callq 0x32b0
movq %r14, %rdi
callq 0x3110
movl 0x704a(%rip), %edi      # 0xb338
leaq 0x7047(%rip), %rsi      # 0xb33c
leaq 0x7194(%rip), %rdx      # 0xb490
callq 0x30c0
movl %eax, -0x2c(%rbp)
cmpl $-0x1, %eax
je 0x476a
movl $0xff, %edx
movl %eax, %edi
movq %r14, %rsi
callq 0x33a0
leaq -0x1a8(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x30e0
leaq -0x68(%rbp), %rdi
movq %rbx, %rsi
pushq $0x40
popq %rdx
callq 0x6bd1
movq %rbx, %rdi
callq 0x3110
movl $0xff, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x31b0
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rax
subq %rsi, %rax
cmpq $0x40, %rax
jne 0x44f7
leaq -0x128(%rbp), %rbx
movq %rbx, %rdi
callq 0x3380
movq %r12, %r13
movq %r14, %r12
movq %r15, %r14
movq -0x68(%rbp), %rsi
addq $0x20, %rsi
leaq -0x188(%rbp), %r15
movq %r15, %rdi
callq 0x3380
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3efb
movl %eax, %ebx
movq %r15, %rdi
callq 0x3110
leaq -0x128(%rbp), %rdi
callq 0x3110
testb %bl, %bl
movq %r14, %r15
movq %r12, %r14
movq %r13, %r12
je 0x44f7
movq -0x68(%rbp), %rsi
movq %r15, %rdi
callq 0x3260
movq %rax, %rdi
callq 0x3140
movq %r15, %rdi
leaq 0x2d94(%rip), %rsi      # 0x717f
callq 0x32b0
movq -0x68(%rbp), %rsi
movq %rax, %rdi
callq 0x3260
movq %rax, %rdi
callq 0x3140
movq -0x68(%rbp), %rsi
leaq -0x168(%rbp), %rbx
movq %rbx, %rdi
callq 0x3380
leaq -0x48(%rbp), %rdi
movq %rbx, %rsi
callq 0x374c
movq %rbx, %rdi
callq 0x3110
movq -0x48(%rbp), %r13
movq -0x40(%rbp), %rbx
cmpq %rbx, %r13
je 0x4524
movq %r12, %rdi
movq %r13, %rsi
callq 0x3380
movq %r15, %rdi
leaq 0x2d3a(%rip), %rsi      # 0x718b
callq 0x32b0
movq %rax, %rdi
movq %r12, %rsi
callq 0x3260
movl -0x2c(%rbp), %edi
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rdx
xorl %ecx, %ecx
callq 0x3160
movq %r12, %rdi
callq 0x3110
addq $0x20, %r13
jmp 0x4433
leaq 0x6fa5(%rip), %rdi      # 0xb430
leaq -0x30(%rbp), %rsi
callq 0x51ac
cmpq $0x1, %rax
jne 0x4298
leaq -0x78(%rbp), %rax
movq %rax, -0x88(%rbp)
andq $0x0, -0x80(%rbp)
movl -0x30(%rbp), %r13d
movb $0x0, -0x78(%rbp)
movq 0x6f2b(%rip), %rbx      # 0xb3e8
leaq 0x6f14(%rip), %rax      # 0xb3d8
cmpq %rax, %rbx
je 0x4573
leaq 0x20(%rbx), %rsi
movq %r14, %rdi
callq 0x51d0
cmpl %r13d, -0x290(%rbp)
je 0x4560
movq %r14, %rdi
callq 0x3110
movq %rbx, %rdi
callq 0x31f0
movq %rax, %rbx
jmp 0x44bd
movl -0x2c(%rbp), %edi
leaq 0x2c75(%rip), %rsi      # 0x7176
pushq $0x1
popq %rdx
xorl %ecx, %ecx
callq 0x3160
movq %r15, %rdi
leaq 0x2c63(%rip), %rsi      # 0x7178
callq 0x32b0
movl -0x2c(%rbp), %edi
callq 0x34b0
jmp 0x4552
leaq 0x6f05(%rip), %rdi      # 0xb430
leaq -0x2c(%rbp), %rsi
callq 0x5d1c
movl -0x2c(%rbp), %ebx
movq -0x68(%rbp), %rsi
leaq 0x6e8e(%rip), %rdi      # 0xb3d0
callq 0x5142
movl %ebx, (%rax)
leaq -0x48(%rbp), %rdi
callq 0x5020
leaq -0x68(%rbp), %rdi
callq 0x5020
jmp 0x4298
movq %r12, %rdi
movq %r14, %rsi
callq 0x31a0
movq %r14, %rdi
callq 0x3110
movl $0xff, %edx
movl %r13d, %edi
leaq -0x3b0(%rbp), %rsi
callq 0x33a0
testq %rax, %rax
jle 0x46f8
leaq -0x148(%rbp), %rbx
movq %rbx, %rdi
leaq -0x3b0(%rbp), %rsi
movq %r14, %rdx
callq 0x30e0
leaq -0x48(%rbp), %rdi
movq %rbx, %rsi
pushq $0x3e
popq %rdx
callq 0x6bd1
movq %rbx, %rdi
callq 0x3110
movq -0x40(%rbp), %rax
cmpq -0x48(%rbp), %rax
je 0x46ab
leaq -0xe8(%rbp), %rdi
movq %r12, %rsi
callq 0x3380
movq -0x48(%rbp), %rsi
leaq -0xc8(%rbp), %rdi
callq 0x3380
movq -0x48(%rbp), %rsi
addq $0x20, %rsi
leaq -0xa8(%rbp), %rdi
callq 0x3380
leaq -0xe8(%rbp), %rbx
movq %rbx, %rdi
leaq -0xc8(%rbp), %r13
movq %r13, %rsi
leaq -0xa8(%rbp), %rdx
callq 0x3b22
leaq -0xa8(%rbp), %rdi
callq 0x3110
movq %r13, %rdi
callq 0x3110
movq %rbx, %rdi
callq 0x3110
leaq -0x68(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
leaq 0x2bd2(%rip), %rdx      # 0x7220
callq 0x4fe8
movq -0x48(%rbp), %rdx
addq $0x20, %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4f5f
movq -0x48(%rbp), %rdi
addq $0x20, %rdi
movq %r14, %rsi
callq 0x3350
movq %r14, %rdi
callq 0x3110
movq %rbx, %rdi
callq 0x3110
movq -0x48(%rbp), %rsi
leaq 0x6d3f(%rip), %rdi      # 0xb3d0
callq 0x5142
movl (%rax), %edi
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rsi
movq 0x28(%rax), %rdx
xorl %ecx, %ecx
callq 0x3160
movq %r14, %rdi
callq 0x6999
movq %r15, %rdi
movq %r14, %rsi
callq 0x3260
movq %r14, %rdi
callq 0x3110
leaq 0x2ac3(%rip), %rdi      # 0x7190
leaq -0x3b0(%rbp), %rbx
movq %rbx, %rsi
xorl %eax, %eax
callq 0x3040
movl $0xff, %edx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x31b0
leaq -0x48(%rbp), %rdi
callq 0x5020
jmp 0x474b
leaq -0x108(%rbp), %rdi
movq %r12, %rsi
callq 0x3380
leaq -0x108(%rbp), %rbx
movq %rbx, %rdi
callq 0x3d81
movq %rbx, %rdi
callq 0x3110
leaq 0x6cab(%rip), %rdi      # 0xb3d0
movq %r12, %rsi
callq 0x5142
leaq 0x6cfc(%rip), %rdi      # 0xb430
movq %rax, %rsi
callq 0x6288
leaq 0x6c8d(%rip), %rdi      # 0xb3d0
movq %r12, %rsi
callq 0x644e
movq %r12, %rdi
callq 0x3110
jmp 0x4298
addq $0x388, %rsp            # imm = 0x388
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x6867(%rip), %rdi      # 0xafd8
leaq 0x29f0(%rip), %rsi      # 0x7168
callq 0x32b0
movq %rax, %rdi
callq 0x3140
pushq $-0x1
popq %rdi
callq 0x3340
movq %rax, %rbx
leaq -0x108(%rbp), %rdi
jmp 0x47f9
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
jmp 0x480c
jmp 0x4839
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x3110
jmp 0x47bb
movq %rax, %rbx
leaq -0xc8(%rbp), %rdi
callq 0x3110
jmp 0x47cc
movq %rax, %rbx
leaq -0xe8(%rbp), %rdi
jmp 0x480c
movq %rax, %rbx
leaq -0x2b0(%rbp), %rdi
jmp 0x47f9
movq %rax, %rbx
leaq -0x168(%rbp), %rdi
jmp 0x4832
jmp 0x4866
movq %rax, %rbx
leaq -0x148(%rbp), %rdi
callq 0x3110
jmp 0x4873
jmp 0x4870
movq %rax, %rbx
leaq -0x2b0(%rbp), %rdi
callq 0x3110
jmp 0x483c
jmp 0x4839
jmp 0x486b
movq %rax, %rbx
leaq -0x188(%rbp), %rdi
callq 0x3110
jmp 0x482b
movq %rax, %rbx
leaq -0x128(%rbp), %rdi
callq 0x3110
jmp 0x4899
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x5020
jmp 0x4873
movq %rax, %rbx
jmp 0x48a2
movq %rax, %rbx
leaq -0x1a8(%rbp), %rdi
jmp 0x487a
jmp 0x4870
movq %rax, %rbx
leaq -0x2b0(%rbp), %rdi
jmp 0x487a
movq %rax, %rbx
jmp 0x4899
movq %rax, %rbx
jmp 0x4890
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
callq 0x3110
jmp 0x48a2
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
callq 0x3110
leaq -0x48(%rbp), %rdi
callq 0x5020
leaq -0x68(%rbp), %rdi
callq 0x5020
movq %rbx, %rdi
callq 0x3440