### Description
It seems there is a problem with the sending of the DPA from the cdp module to the
diameter peer.
When we receive the DPR the `Snd_DPA()` and `I_Disc()` are executed from
peerstatemachine.c (I_Open/I_Rcv_DPR branch).
Since the socket is closed from `I_Disc()` the `select()` in the `receive_loop` exits with
a failure and the send pipe (which holds the DPA) is never sent to the other side.
### Troubleshooting
#### Reproduction
```
1. Send DPR from diameter peer to Kamailio
2. DPA is never received on the other end
```
#### Log Messages
```
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
```
### Possible Solutions
<!--
Send pipe should be flushed in I_Disc() ?
-->
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
```
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
```
* **Operating System**:
```
Linux 5.10.69-flatcar #1 SMP Wed Sep 29 20:48:40 -00 2021 x86_64 x86_64 x86_64 GNU/Linux
```
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/3092
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/issues/3092(a)github.com>