Commit 0e6ad3de authored by Simon Morlat's avatar Simon Morlat

Fix a possible infinite loop with keepalive timer in flexisip, when EWOULDBLOCK happens.

parent bb3143dd
......@@ -11,7 +11,7 @@ dnl information on the package
dnl ---------------------------
dnl update both the version for AC_INIT and the LIBSOFIA_SIP_UA_MAJOR_MINOR
AC_INIT([sofia-sip], [1.13.35bc])
AC_INIT([sofia-sip], [1.13.36bc])
AC_CONFIG_SRCDIR([libsofia-sip-ua/sip/sofia-sip/sip.h])
AC_CONFIG_MACRO_DIR([m4])
AC_SUBST(VER_LIBSOFIA_SIP_UA_MAJOR_MINOR, [1.13])
......
......@@ -840,24 +840,26 @@ static int tport_tls_ping(tport_t *self, su_time_t now)
if (tport_has_queued(self))
return 0;
if (tls_events(tlstp->tlstp_context, SU_WAIT_OUT) != 0){
/* We had an EWOULDBLOCK on write which is pending poll() to notify when it's ready to write again.
* In this situation there is no need and this is dangerous to write a keepalive. */
return 0;
}
if (tls_events(tlstp->tlstp_context, SU_WAIT_OUT) == 0){
n = tls_write(tlstp->tlstp_context, "\r\n\r\n", 4);
if (n == -1) {
int error = su_errno();
n = tls_write(tlstp->tlstp_context, "\r\n\r\n", 4);
if (n == -1) {
int error = su_errno();
why = " failed";
why = " failed";
if (!su_is_blocking(error))
tport_error_report(self, error, NULL);
else
why = " blocking";
if (!su_is_blocking(error))
tport_error_report(self, error, NULL);
else
why = " blocking";
return -1;
return -1;
}
}else{
/* We had an EWOULDBLOCK on write which is pending poll() to notify when it's ready to write again.
* In this situation there is no need and this is dangerous to write a keepalive.
* We do the stuff below as if the the keepalive was sent, otherwise the timer will be set again by the upper layer,
* causing an infinite loop.*/
n = 4;
}
if (n > 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment