| 708 | |
| 709 | |
| 710 | static int write_to_unixsock(str* sockname, int cnt) |
| 711 | { |
| 712 | int e; |
| 713 | struct sockaddr_un dest; |
| 714 | |
| 715 | if (!sockname) { |
| 716 | LM_ERR("invalid parameter\n"); |
| 717 | return E_UNSPEC; |
| 718 | } |
| 719 | |
| 720 | if (sockname->len == 0) { |
| 721 | LM_ERR("empty socket name\n"); |
| 722 | return -1; |
| 723 | } else if (sockname->len > 107) { |
| 724 | LM_ERR("socket name too long\n"); |
| 725 | return -1; |
| 726 | } |
| 727 | |
| 728 | memset(&dest, 0, sizeof(dest)); |
| 729 | dest.sun_family = PF_LOCAL; |
| 730 | memcpy(dest.sun_path, sockname->s, sockname->len); |
| 731 | #ifdef HAVE_SOCKADDR_SA_LEN |
| 732 | dest.sun_len = sockname->len; |
| 733 | #endif |
| 734 | |
| 735 | e = connect(sock, (struct sockaddr*)&dest, SUN_LEN(&dest)); |
| 736 | #ifdef HAVE_CONNECT_ECONNRESET_BUG |
| 737 | /* |
| 738 | * Workaround for a nasty bug in BSD kernels dated back |
| 739 | * to the Berkeley days, so that can be found in many modern |
| 740 | * BSD-derived kernels. Workaround should be pretty harmless since |
| 741 | * in normal conditions connect(2) can never return ECONNRESET. |
| 742 | */ |
| 743 | if ((e == -1) && (errno == ECONNRESET)) |
| 744 | e = 0; |
| 745 | #endif |
| 746 | if (e == -1) { |
| 747 | LM_ERR("failed to connect: %s\n", strerror(errno)); |
| 748 | return -1; |
| 749 | } |
| 750 | |
| 751 | if (tsend_dgram_ev(sock, (struct iovec*)(void*)lines_eol, 2 * cnt, |
| 752 | tm_unix_tx_timeout * 1000) < 0) { |
| 753 | LM_ERR("writev failed: %s\n", strerror(errno)); |
| 754 | return -1; |
| 755 | } |
| 756 | |
| 757 | return 0; |
| 758 | } |
| 759 | |
| 760 | |
| 761 | int t_write_req(struct sip_msg* msg, struct tw_info* info, str* vm_fifo) |
no test coverage detected