[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gnutls_record_check_pending() broken?

From: Simon Josefsson
Subject: Re: gnutls_record_check_pending() broken?
Date: Thu, 28 May 2009 20:28:34 +0200
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.94 (gnu/linux)

Peter Hendrickson <address@hidden> writes:

> Simon writes:
>> Simon Josefsson <address@hidden> writes:
>> > Peter Hendrickson <address@hidden> writes:
>> >
>> >> gnutls_record_check_pending() doesn't work for me.  It always returns
>> >> 0, even when data is pending.
>> >
>> > How did you test this?  A small code demonstrating the problem would
>> > help.  I'll see if I can get something to work too...
>> Indeed, the patch below against mini.c demonstrate it working.  For me
>> it prints:
> It prints for me, too.
> What happens if you put the record_check_pending() call before you do
> the gnutls_record_recv()?  For me, it reports no bytes pending, even
> if I do a sleep(10).

That won't work: the purpose of gnutls_record_check_pending() is to
check if there is data stored in buffers within GnuTLS.  Before you call
gnutls_record_recv, there won't be any data in the buffers.  After a
call to gnutls_record_recv, the data that was not returned to the caller
of the function will be stored in an internal buffer.  The purpose of
the function is to find out if there is such data pending.

So I don't see a problem here actually.  It sounds as if you should use
poll/select to check if there is data pending to be read from the
socket.  When that is true, you should call gnutls_record_recv.  Of that
returns a complete buffer, you can call gnutls_record_check_pending how
much data is stored in a buffer -- that amount of data can be read
without a blocking socket read, again by calling gnutls_record_recv.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]