diff --git a/src/sipsess/listen.c b/src/sipsess/listen.c index f50e37289..f41b07345 100644 --- a/src/sipsess/listen.c +++ b/src/sipsess/listen.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "sipsess.h" @@ -250,11 +251,18 @@ static void target_refresh_handler(struct sipsess_sock *sock, if ((is_invite && sess->st) || (sdp && sess->neg_state == SDP_NEG_LOCAL_OFFER)) { - (void)sip_treplyf(NULL, NULL, sip, msg, false, - 500, "Server Internal Error", - "Retry-After: 5\r\n" - "Content-Length: 0\r\n" - "\r\n"); + if (!sess->established) { + uint32_t wait = rand_u16() % 11; + (void)sip_treplyf(NULL, NULL, sip, msg, false, + 500, "Server Internal Error", + "Retry-After: %u\r\n" + "Content-Length: 0\r\n" + "\r\n", wait); + } + else { + (void)sip_treply(NULL, sip, msg, 491, + "Request Pending"); + } return; }