[gnutls-help] gnutls_record_send says it sent more than I told it to!?

Mathieu Chouquet-Stringer m+gnutls at thi.eu.com
Tue Feb 2 11:23:20 CET 2016


	Hello,

I've coded an application in C and I use gnutls version 3.4.8 (3.4.8-1
on Fedora 23 x86_64).

My program is just a TLS front end for some of my applications which
don't know how to speak TLS.

I don't use threads but use epoll to manage all active sessions.

I've been trying to diagnose a bug and as such I've added a bunch of
printf all around the code.

I have a function that does the following when epoll says there
something to read:

	received = recv(con->fd, buffer, con->peer->rec_size);

	if (received > 0) {
		wrote = gnutls_record_send(con->peer->session, buffer, received);
		if (wrote == GNUTLS_E_INTERRUPTED || wrote == GNUTLS_E_AGAIN)
			return 1;
		if (wrote > received)
			fprintf(stderr, "BUG at %d: wrote %ld, received: %ld\n",
				__LINE__, wrote, received);
	} else {
		/* do something else here */
	}

rec_size is basically <= 16k and <= to what gnutls_record_get_max_size
returned.

Everyonce in a while, the fprintf shows me this:
BUG at 661: wrote 10380, received: 10364
BUG at 661: wrote 16384, received: 15092
BUG at 661: wrote 16384, received: 11376
BUG at 661: wrote 16384, received: 11400
BUG at 661: wrote 16384, received: 11400
BUG at 661: wrote 6892, received: 6780
BUG at 661: wrote 6892, received: 6780

I haven't managed to understand how to trigger it and I'm really curious
why this could happen...

Any idea or pointer would be welcome?
-- 
Mathieu Chouquet-Stringer                               m+gnutls at thi.eu.com
            The sun itself sees not till heaven clears.
	             -- William Shakespeare --



More information about the Gnutls-help mailing list