<p></p>
<h3 dir="auto">Description</h3>
<p dir="auto">It seems there is a problem with the sending of the DPA from the cdp module to the diameter peer.<br>
When we receive the DPR the <code>Snd_DPA()</code> and <code>I_Disc()</code> are executed from peerstatemachine.c (I_Open/I_Rcv_DPR branch).<br>
Since the socket is closed from <code>I_Disc()</code> the <code>select()</code> in the <code>receive_loop</code> exits with a failure and the send pipe (which holds the DPA) is never sent to the other side.</p>
<h3 dir="auto">Troubleshooting</h3>
<h4 dir="auto">Reproduction</h4>
<pre><code>1. Send DPR from diameter peer to Kamailio
2. DPA is never received on the other end
</code></pre>
<h4 dir="auto">Log Messages</h4>
<pre><code>    Apr 24, 2022 @ 20:43:58.854 +0200    pcscf   44(138) DEBUG: cdp [peerstatemachine.c:89]: sm_process(): sm_process(): Peer chordlet State I_Open Event I_Rcv_DPR
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: <core> [core/mem/q_malloc.c:373]: qm_malloc(): qm_malloc(0x7f54a05dc000, 120) called from cdp: diameter_msg.c: AAANewMessage(192)
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: <core> [core/mem/q_malloc.c:416]: qm_malloc(): qm_malloc(0x7f54a05dc000, 120) returns address 0x7f54a1005888 frag. 0x7f54a1005850 (size=120) on 1 -th hit
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: <core> [core/mem/q_malloc.c:373]: qm_malloc(): qm_malloc(0x7f54a05dc000, 56) called from cdp: diameter_avp.c: AAACreateAVP(142)
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: <core> [core/mem/q_malloc.c:416]: qm_malloc(): qm_malloc(0x7f54a05dc000, 56) returns address 0x7f54d53ae668 frag. 0x7f54d53ae630 (size=56) on 1 -th hit
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: <core> [core/mem/q_malloc.c:373]: qm_malloc(): qm_malloc(0x7f54a05dc000, 41) called from cdp: diameter_avp.c: AAACreateAVP(157)
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: <core> [core/mem/q_malloc.c:416]: qm_malloc(): qm_malloc(0x7f54a05dc000, 48) returns address 0x7f54d68446e8 frag. 0x7f54d68446b0 (size=48) on 1 -th hit
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: <core> [core/mem/q_malloc.c:373]: qm_malloc(): qm_malloc(0x7f54a05dc000, 56) called from cdp: diameter_avp.c: AAACreateAVP(142)
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: <core> [core/mem/q_malloc.c:416]: qm_malloc(): qm_malloc(0x7f54a05dc000, 56) returns address 0x7f54d2c2e888 frag. 0x7f54d2c2e850 (size=56) on 1 -th hit
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: <core> [core/mem/q_malloc.c:373]: qm_malloc(): qm_malloc(0x7f54a05dc000, 29) called from cdp: diameter_avp.c: AAACreateAVP(157)
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: <core> [core/mem/q_malloc.c:416]: qm_malloc(): qm_malloc(0x7f54a05dc000, 32) returns address 0x7f54d4eef830 frag. 0x7f54d4eef7f8 (size=40) on 1 -th hit
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: cdp [diameter_msg.c:82]: AAABuildMsgBuffer(): AAABuildMsgBuffer(): len=112
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: <core> [core/mem/q_malloc.c:373]: qm_malloc(): qm_malloc(0x7f54a05dc000, 112) called from cdp: diameter_msg.c: AAABuildMsgBuffer(84)
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: <core> [core/mem/q_malloc.c:416]: qm_malloc(): qm_malloc(0x7f54a05dc000, 112) returns address 0x7f54d1242b00 frag. 0x7f54d1242ac8 (size=112) on 1 -th hit
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: cdp [receiver.c:1013]: peer_send_msg(): peer_send_msg(): Pipe push [0x7f54a1005888]
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: cdp [diameter_msg.c:411]: AAAFreeMessage(): AAAFreeMessage: Freeing message (0x7f54d75aeb50) 282
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: <core> [core/mem/q_malloc.c:482]: qm_free(): qm_free(0x7f54a05dc000, 0x7f54d52aff78), called from cdp: diameter_avp.c: AAAFreeAVP(365)
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: <core> [core/mem/q_malloc.c:525]: qm_free(): freeing frag. 0x7f54d52aff40 alloc'ed from cdp: diameter_avp.c: AAACreateAVP(142)
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: <core> [core/mem/q_malloc.c:482]: qm_free(): qm_free(0x7f54a05dc000, 0x7f54c170eff0), called from cdp: diameter_avp.c: AAAFreeAVP(365)
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: <core> [core/mem/q_malloc.c:525]: qm_free(): freeing frag. 0x7f54c170efb8 alloc'ed from cdp: diameter_avp.c: AAACreateAVP(142)
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: <core> [core/mem/q_malloc.c:482]: qm_free(): qm_free(0x7f54a05dc000, 0x7f54d31942a0), called from cdp: diameter_avp.c: AAAFreeAVP(365)
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: <core> [core/mem/q_malloc.c:525]: qm_free(): freeing frag. 0x7f54d3194268 alloc'ed from cdp: diameter_avp.c: AAACreateAVP(142)
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: <core> [core/mem/q_malloc.c:482]: qm_free(): qm_free(0x7f54a05dc000, 0x7f54d70d3508), called from cdp: diameter_avp.c: AAAFreeAVP(365)
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: <core> [core/mem/q_malloc.c:525]: qm_free(): freeing frag. 0x7f54d70d34d0 alloc'ed from cdp: diameter_avp.c: AAACreateAVP(142)
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: <core> [core/mem/q_malloc.c:482]: qm_free(): qm_free(0x7f54a05dc000, 0x7f54d5febb38), called from cdp: diameter_avp.c: AAAFreeAVP(365)
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: <core> [core/mem/q_malloc.c:525]: qm_free(): freeing frag. 0x7f54d5febb00 alloc'ed from cdp: diameter_avp.c: AAACreateAVP(142)
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: <core> [core/mem/q_malloc.c:482]: qm_free(): qm_free(0x7f54a05dc000, 0x7f54d1e24700), called from cdp: diameter_msg.c: AAAFreeMessage(421)
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: <core> [core/mem/q_malloc.c:525]: qm_free(): freeing frag. 0x7f54d1e246c8 alloc'ed from cdp: receiver.c: do_receive(580)
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: <core> [core/mem/q_malloc.c:482]: qm_free(): qm_free(0x7f54a05dc000, 0x7f54d75aeb50), called from cdp: diameter_msg.c: AAAFreeMessage(424)
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) DEBUG: <core> [core/mem/q_malloc.c:525]: qm_free(): freeing frag. 0x7f54d75aeb18 alloc'ed from cdp: diameter_msg.c: AAATranslateMessage(485)
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) ERROR: cdp [receiver.c:688]: receive_loop(): select_recv(): Bad file descriptor
        Apr 24, 2022 @ 20:43:58.854 +0200       pcscf   44(138) INFO: cdp [receiver.c:222]: disconnect_serviced_peer(): drop_serviced_peer(): [chordlet] Disconnecting from peer 
</code></pre>
<h3 dir="auto">Possible Solutions</h3>

<h3 dir="auto">Additional Information</h3>
<ul dir="auto">
<li><strong>Kamailio Version</strong> - output of <code>kamailio -v</code></li>
</ul>
<pre><code>version: kamailio 5.4.4 (x86_64/linux)
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: unknown
compiled with gcc 10.2.1
</code></pre>
<ul dir="auto">
<li><strong>Operating System</strong>:</li>
</ul>
<pre><code>Linux 5.10.69-flatcar #1 SMP Wed Sep 29 20:48:40 -00 2021 x86_64 x86_64 x86_64 GNU/Linux
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/3092">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZISWOKJIY5JJXPWEFDVGZ22JANCNFSM5UIFPLBQ">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/ABO7UZI42J7366B2TZUUJITVGZ22JA5CNFSM5UIFPLB2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4SDBFMEA.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><kamailio/kamailio/issues/3092</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/3092",
"url": "https://github.com/kamailio/kamailio/issues/3092",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>