// File: JianjiaoSQ[P]MyPoorWebServer/CGImysql/sql_connection_pool.cpp
// Function: connection_pool::init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, int, int)
void connection_pool::init(string url, string User, string PassWord, string DBName, int Port, int MaxConn, int close_log)
{
	m_url = url;
	m_Port = Port;
	m_User = User;
	m_PassWord = PassWord;
	m_DatabaseName = DBName;
	m_close_log = close_log;

	for (int i = 0; i < MaxConn; i++)
	{
		MYSQL *con = NULL;
		con = mysql_init(con);

		if (con == NULL)
		{
			LOG_ERROR("MySQL Error");
			exit(1);
		}
		// mysql_real_connect()尝试与运行在主机上的MySQL数据库引擎建立连接
		con = mysql_real_connect(con, url.c_str(), User.c_str(), PassWord.c_str(), DBName.c_str(), Port, NULL, 0);
		// 连接失败，返回NULL
		if (con == NULL) 
		{
			LOG_ERROR("MySQL Error");
			exit(1);
		}
		connList.push_back(con);
		++m_FreeConn;
	}

	reserve = sem(m_FreeConn);

	m_MaxConn = m_FreeConn;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %r8, -0x68(%rbp)
movq %rcx, -0x70(%rbp)
movq %rdx, -0x78(%rbp)
movq %rsi, -0x80(%rbp)
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x60(%rbp)
addq $0x70, %rdi
callq 0x3050
movq -0x60(%rbp), %rdi
movl -0x2c(%rbp), %eax
addq $0x90, %rdi
movsbl %al, %esi
callq 0x36d0
movq -0x78(%rbp), %rsi
movq -0x60(%rbp), %rdi
addq $0xb0, %rdi
callq 0x3050
movq -0x70(%rbp), %rsi
movq -0x60(%rbp), %rdi
addq $0xd0, %rdi
callq 0x3050
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdi
addq $0xf0, %rdi
callq 0x3050
movq -0x60(%rbp), %rax
movl 0x18(%rbp), %ecx
movl %ecx, 0x110(%rax)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl 0x10(%rbp), %eax
jge 0xa0de
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x31e0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x9fe8
movq -0x60(%rbp), %rcx
xorl %eax, %eax
cmpl 0x110(%rcx), %eax
jne 0x9fde
callq 0x6df0
movq %rax, %rdi
movl $0x3, %esi
leaq 0x448d(%rip), %rdx      # 0xe457
movb $0x0, %al
callq 0x9300
callq 0x6df0
movq %rax, %rdi
callq 0x9870
movl $0x1, %edi
callq 0x3580
movq -0x80(%rbp), %rdi
movq -0x38(%rbp), %rax
movq %rax, -0xa0(%rbp)
callq 0x3180
movq -0x78(%rbp), %rdi
movq %rax, -0x98(%rbp)
callq 0x3180
movq -0x70(%rbp), %rdi
movq %rax, -0x90(%rbp)
callq 0x3180
movq -0x68(%rbp), %rdi
movq %rax, -0x88(%rbp)
callq 0x3180
movq -0xa0(%rbp), %rdi
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rdx
movq -0x88(%rbp), %rcx
movq %rax, %r8
movl -0x2c(%rbp), %r9d
xorl %eax, %eax
movq $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0x3220
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0xa0b2
movq -0x60(%rbp), %rcx
xorl %eax, %eax
cmpl 0x110(%rcx), %eax
jne 0xa0a8
callq 0x6df0
movq %rax, %rdi
movl $0x3, %esi
leaq 0x43c3(%rip), %rdx      # 0xe457
movb $0x0, %al
callq 0x9300
callq 0x6df0
movq %rax, %rdi
callq 0x9870
movl $0x1, %edi
callq 0x3580
movq -0x60(%rbp), %rdi
addq $0x38, %rdi
leaq -0x38(%rbp), %rsi
callq 0xa510
movq -0x60(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x9f80
movq -0x60(%rbp), %rax
movl 0x8(%rax), %esi
leaq -0x58(%rbp), %rdi
callq 0xa550
movq -0x60(%rbp), %rax
movq -0x58(%rbp), %rcx
movq %rcx, 0x50(%rax)
movq -0x50(%rbp), %rcx
movq %rcx, 0x58(%rax)
movq -0x48(%rbp), %rcx
movq %rcx, 0x60(%rax)
movq -0x40(%rbp), %rcx
movq %rcx, 0x68(%rax)
leaq -0x58(%rbp), %rdi
callq 0xa5b0
movq -0x60(%rbp), %rax
movl 0x8(%rax), %ecx
movl %ecx, (%rax)
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax)