set's the query_list that will be used for inserts * on the provided db connection * * also takes care of initialisation of this is the first process * attempting to execute this type of query */
| 468 | * also takes care of initialisation of this is the first process |
| 469 | * attempting to execute this type of query */ |
| 470 | int con_set_inslist(db_func_t *dbf,db_con_t *con,query_list_t **list, |
| 471 | db_key_t *cols,int col_no) |
| 472 | { |
| 473 | query_list_t *entry; |
| 474 | |
| 475 | /* if buffering not enabled, ignore */ |
| 476 | if (query_buffer_size <= 1) |
| 477 | return 0; |
| 478 | |
| 479 | /* if buffering is enabled, but user is using a module |
| 480 | * that does not support multiple inserts, |
| 481 | * also ignore */ |
| 482 | if (!DB_CAPABILITY(*dbf,DB_CAP_MULTIPLE_INSERT)) |
| 483 | return 0; |
| 484 | |
| 485 | if (list == NULL) |
| 486 | return 0; |
| 487 | |
| 488 | /* first time we are being called from this process */ |
| 489 | if (*list == NULL) |
| 490 | { |
| 491 | LM_DBG("first inslist call. searching for query list \n"); |
| 492 | lock_get(ql_lock); |
| 493 | entry = find_query_list_unsafe(con->table,cols,col_no); |
| 494 | if (entry == NULL) |
| 495 | { |
| 496 | LM_DBG("couldn't find entry for this query\n"); |
| 497 | /* first query of this type is done from this process, |
| 498 | * it's my job to initialize the query list |
| 499 | * and save for later use */ |
| 500 | entry = ql_init(con,cols,col_no); |
| 501 | if (entry == NULL) |
| 502 | { |
| 503 | LM_ERR("failed to initialize ins queue\n"); |
| 504 | lock_release(ql_lock); |
| 505 | return -1; |
| 506 | } |
| 507 | |
| 508 | ql_add_unsafe(entry); |
| 509 | con->ins_list = entry; |
| 510 | *list = entry; |
| 511 | } |
| 512 | else |
| 513 | { |
| 514 | LM_DBG("query list already exists - attaching\n"); |
| 515 | /* another process has done a query of this type, |
| 516 | * just attach to the con and save for later use */ |
| 517 | con->ins_list = entry; |
| 518 | *list = entry; |
| 519 | } |
| 520 | |
| 521 | lock_release(ql_lock); |
| 522 | return 0; |
| 523 | } |
| 524 | else |
| 525 | { |
| 526 | /* we've previously found our query list */ |
| 527 | LM_DBG("process already found it's query list\n"); |
no test coverage detected