On Tue, 2016-02-02 at 11:23 +0100, Mathieu Chouquet-Stringer wrote:
>       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

Could it be that you are resuming a previously interrupted send? If the
previous send was interrupted and returned GNUTLS_E_AGAIN or
GNUTLS_E_INTERRUPTED then it will be resumed on the next call, unless
you call gnutls_record_discard_queued().

regards,
Nikos



_______________________________________________
Gnutls-help mailing list
[email protected]
http://lists.gnupg.org/mailman/listinfo/gnutls-help

Reply via email to