| 146 | } |
| 147 | |
| 148 | connect_pool* connect_manager::get(const char* addr, |
| 149 | bool exclusive /* = true */) |
| 150 | { |
| 151 | char key[256]; |
| 152 | lowercase(addr, key, sizeof(key)); |
| 153 | |
| 154 | if (exclusive) |
| 155 | lock_->lock(); |
| 156 | |
| 157 | std::vector<connect_pool*>::iterator it = pools_.begin(); |
| 158 | for (; it != pools_.end(); ++it) |
| 159 | { |
| 160 | if (strcasecmp(key, (*it)->get_addr()) == 0) |
| 161 | { |
| 162 | if (exclusive) |
| 163 | lock_->unlock(); |
| 164 | return *it; |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | if (exclusive) |
| 169 | lock_->unlock(); |
| 170 | |
| 171 | return NULL; |
| 172 | } |
| 173 | |
| 174 | ////////////////////////////////////////////////////////////////////////// |
| 175 | |