[gnutls-devel] Question regarding gnutls_record_set_timeout()

Tim Ruehsen tim.ruehsen at gmx.de
Wed Sep 16 16:57:14 CEST 2015


Hi,

I would like to use gnutls_record_set_timeout() instead of using my own 
timeout code.

I see no way to specify an 'indefinite' timeout, e.g. by using a negative 
value. Should I set the fd to blocking or what is the best 'gnutls' way ?


BTW, looking at the code in system_recv_timeout(), with high timeout values, 
there might be unexpected CPU usage due to this loop:

	tv.tv_sec = 0;
	tv.tv_usec = ms * 1000;

	while (tv.tv_usec >= 1000000) {
		tv.tv_usec -= 1000000;
		tv.tv_sec++;
	}

IMHO, it could be replaced by
	tv.tv_sec = ms / 1000;
	tv.tv_usec = (ms % 1000) * 1000;


Regards, Tim




More information about the Gnutls-devel mailing list