MCPcopy Create free account
hub / github.com/acl-dev/acl / put

Method put

lib_acl_cpp/src/connpool/connect_pool.cpp:324–380  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

322}
323
324void connect_pool::put(connect_client* conn, bool keep /* = true */,
325 cpool_put_oper_t oper /* cpool_put_check_idle */)
326{
327 if (conn == NULL) {
328 return;
329 }
330
331 time_t now = time(NULL);
332
333 lock_.lock();
334
335 // ����Ƿ������������ٱ�־λ
336 if (delay_destroy_) {
337 if (conn->get_pool() == this) {
338 count_dec(false);
339 }
340 delete conn;
341
342 if (refers_ <= 0) {
343 // ������ü���Ϊ 0 ��������
344 lock_.unlock();
345 delete this;
346 } else {
347 lock_.unlock();
348 }
349 return;
350 }
351
352 if (keep && alive_) {
353 conn->set_when(now);
354
355 // ���黹�����ӷ��������ײ��������ڵ����ͷŹ�������
356 // ʱ�ȽϷ��㣬�����ھ��콫��æ�����ݿ����ӹر�
357 pool_.push_front(conn);
358 } else {
359 acl_assert(count_ > 0);
360 if (conn->get_pool() == this) {
361 count_dec(false);
362 }
363 delete conn;
364 }
365
366 if (check_inter_ >= 0 && now - last_check_ >= check_inter_) {
367 lock_.unlock();
368 if (oper & cpool_put_check_idle) {
369 (void) check_idle(idle_ttl_, true);
370 }
371 if (oper & cpool_put_check_dead) {
372 (void) check_dead();
373 }
374 if (oper & cpool_put_keep_conns) {
375 keep_conns();
376 }
377 } else {
378 lock_.unlock();
379 }
380}
381

Callers 2

sendMethod · 0.45
sendMethod · 0.45

Calls 4

set_whenMethod · 0.80
push_frontMethod · 0.80
lockMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected