added work-around for infinite loop if the UDP descriptor becomes invalid

This commit is contained in:
Nikos Mavrogiannopoulos
2014-08-23 17:54:01 +02:00
parent 817f757577
commit 6f4f60db5a
+11
View File
@@ -1071,9 +1071,20 @@ static int dtls_mainloop(worker_st * ws, struct timespec *tnow)
{
int ret, l;
#if GNUTLS_VERSION_NUMBER <= 0x030210
/* work-around an infinite loop caused by gnutls_record_recv()
* always succeeding by counting every error as a discarded packet.
*/
ret = gnutls_record_get_discarded(ws->dtls_session);
if (ret > 1000) {
ws->udp_state = UP_DISABLED;
break;
}
#endif
switch (ws->udp_state) {
case UP_ACTIVE:
case UP_INACTIVE:
ret =
tls_recv_nb(ws->dtls_session, ws->buffer, ws->buffer_size);
oclog(ws, LOG_TRANSFER_DEBUG,