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

Method load_dat_hosts

lib_acl_cpp/app/ndb/ctl_server/db_ctl.cpp:361–408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

359}
360
361int db_ctl::load_dat_hosts(void)
362{
363 const char* sql = "select id, addr, count, priority from tbl_host_dat";
364 if (ctl_conn_->sql_select(sql) == false)
365 {
366 logger_error("sql(%s) invalid", sql);
367 return -1;
368 }
369
370 const std::vector<acl::db_row*>* rows = ctl_conn_->get_rows();
371 if (rows == NULL)
372 {
373 logger_warn("tbl_host_dat empty");
374 return 0;
375 }
376
377 unsigned int id;
378 const char* addr;
379 acl_int64 count;
380 int priority;
381
382 size_t i;
383 for (i = 0; i < rows->size(); i++)
384 {
385 const acl::db_row* row = (*rows)[i];
386 if ((id = row->field_int("id", -1)) == (unsigned int) -1)
387 {
388 logger_warn("id(-1) invalid");
389 continue;
390 }
391 else if ((addr = row->field_string("addr")) == NULL)
392 {
393 logger_warn("addr null");
394 continue;
395 }
396 else if ((count = row->field_int64("count", -1)) == -1)
397 {
398 logger_warn("count(-1) invalid");
399 continue;
400 }
401 priority = row->field_int("priority", 0);
402 dat_host* host = new dat_host(id, addr, count, priority);
403 dat_hosts_.push_back(host);
404 }
405
406 ctl_conn_->free_result();
407 return (int) i;
408}
409
410int db_ctl::load_db_hosts(void)
411{

Callers

nothing calls this directly

Calls 8

get_rowsMethod · 0.80
field_intMethod · 0.80
field_stringMethod · 0.80
field_int64Method · 0.80
free_resultMethod · 0.80
sql_selectMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected