| 620 | |
| 621 | |
| 622 | void dm_peer_loop(int _) |
| 623 | { |
| 624 | struct dm_message *msg; |
| 625 | |
| 626 | LM_INFO("freeDiameter dedicated process starting...\n"); |
| 627 | |
| 628 | if (freeDiameter_init() != 0) { |
| 629 | LM_ERR("failed to init freeDiameter library\n"); |
| 630 | return; |
| 631 | } |
| 632 | |
| 633 | __FD_CHECK(dm_register_osips_avps(), 0, ); |
| 634 | __FD_CHECK(dm_init_sip_application(), 0, ); |
| 635 | __FD_CHECK(dm_prepare_globals(), 0, ); |
| 636 | __FD_CHECK(parse_extra_avps(extra_avps_file), 0, ); |
| 637 | |
| 638 | __FD_CHECK(dm_register_callbacks(), 0, ); |
| 639 | __FD_CHECK(fd_core_start(), 0, ); |
| 640 | |
| 641 | if (dm_init_reply_cond(-2) != 0) { |
| 642 | LM_ERR("failed to init cond\n"); |
| 643 | return; |
| 644 | } |
| 645 | |
| 646 | pthread_mutex_lock(msg_send_lk); |
| 647 | |
| 648 | for (;;) { |
| 649 | LM_DBG("waiting to send new messages...\n"); |
| 650 | pthread_cond_wait(msg_send_cond, msg_send_lk); |
| 651 | |
| 652 | if (list_empty(msg_send_queue)) { |
| 653 | LM_BUG("pthread cond signal on empty queue"); |
| 654 | continue; |
| 655 | } |
| 656 | |
| 657 | LM_DBG("have new message to send -- processing...\n"); |
| 658 | msg = list_entry(msg_send_queue->next, struct dm_message, list); |
| 659 | list_del(&msg->list); |
| 660 | |
| 661 | if (dm_peer_send_msg(msg) != 0) |
| 662 | LM_ERR("failed to send message\n"); |
| 663 | else |
| 664 | LM_DBG("successfully sent\n"); |
| 665 | |
| 666 | _dm_destroy_message(msg->am); |
| 667 | } |
| 668 | |
| 669 | pthread_mutex_unlock(msg_send_lk); |
| 670 | |
| 671 | __FD_CHECK(fd_core_wait_shutdown_complete(), 0, ); |
| 672 | } |
nothing calls this directly
no test coverage detected