gnutls_record_check_pending() issue in GNUTLS 3.0.3 ??

frank.krout at eurorscg.com frank.krout at eurorscg.com
Mon Nov 7 23:37:55 CET 2011


Hello,

Using gnutls_record_check_pending() to check for received data in a 
function that sleeps a few times if no data present:

ie.
                if (esmtpInfo.gnutls.ringBuffer.currentIndex == 
0){//ringbuffer empty, look for more data
                        int count = 0;
                        int loop   = 0;
                        do { //add sleep function call here
                                loop++;
                                sleep( INTERNET_DEFAULT_TIMEOUT_SECONDS );
                                count = gnutls_record_check_pending( 
esmtpInfo.gnutls.session );
                                //count = 
esmtpInfo.gnutls.session->internals.record_buffer.byte_length;
                   }while ( count <= 0 && loop < 3 );
                   if (count > 0)  return NMQ_SUCCESS;
                   if ( count == 0)  return NMQ_NET_TIMEOUT;
                  }

Using this in multi-threaded mailer... problem is 
gnutls_record_check_pending() fails EVERY time.
That is, it never indicates any data has been received.

If I remove the check completely and just go to the receive logic after 
sending an ESMTP command and call gnutls_record_recv()
all works fine. I successfully deliver complete emails.

Looking at gnutls_record_check_pending()'s use in cli.c I see it's really 
inconclusive... the select might detect the incoming data...
static int check_net_or_keyboard_input(socket_st* hd)
{
  int maxfd;
  fd_set rset;
  int err;
  struct timeval tv;

  do
    {
      FD_ZERO (&rset);
      FD_SET (fileno (stdin), &rset);
      FD_SET (hd->fd, &rset);

      maxfd = MAX (fileno (stdin), hd->fd);
      tv.tv_sec = 0;
      tv.tv_usec = 500 * 1000;

      if (hd->secure == 1)
        if (gnutls_record_check_pending(hd->session))
          return IN_NET;

      err = select (maxfd + 1, &rset, NULL, NULL, &tv);
      if (err < 0)
        continue;

      if (FD_ISSET (hd->fd, &rset))
        return IN_NET;


      if (FD_ISSET (fileno (stdin), &rset))
        return IN_KEYBOARD;
    }
  while(err == 0);
 
  return IN_NONE;
}

FYI, I'm linking in all of these  -lgnutls -lgnutlsxx -lgnutls-extra
I'm going to need to implement a timeout so threads don't hang, 
I suppose I could do it on the gnutls_record_recv() call, but  will that 
block on no data received?

Any  thoughts?
Regards,
Frank

System info:
c01z0047:~/projects/MassMailer/MassMailer_Linux_Release_4_0_0/MassMailer> 
gcc -v
Using built-in specs.
Target: s390x-suse-linux
Configured with: ../configure --enable-threads=posix --prefix=/usr 
--with-local-prefix=/usr/local --infodir=/usr/share/info 
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 
--enable-languages=c,c++,objc,fortran,obj-c++,java 
--enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.1.2 
--enable-ssp --disable-libssp --disable-libgcj --with-slibdir=/lib64 
--with-system-zlib --enable-shared --enable-__cxa_atexit 
--enable-libstdcxx-allocator=new --program-suffix= 
--enable-version-specific-runtime-libs --without-system-libunwind 
--with-tune=z9-109 --with-arch=z900 --with-long-double-128 
--host=s390x-suse-linux
Thread model: posix
gcc version 4.1.2 20070115 (SUSE Linux)


Frank Krout Senior Software Engineer
Office Euro RSCG 4D, 372 Danbury Rd, Wilton, Connecticut 06897
Tel 203.563.3314  Fax 203.563.3434  Web 
eurorscg.com

 
     
________________________________________________________________________________
____________________________________
The views and opinions expressed in this e-mail and any accompanying 
attachment, are those of the author and do not 
necessarily represent the views or opinion of Euro RSCG Worldwide, Inc.
To learn more about Euro RSCG, please visit our website at www.eurorscg.com

Please consider the environment before printing this email. 
________________________________________________________________________________
_____________________

-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/attachments/20111107/a616bb23/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 2098 bytes
Desc: not available
URL: </pipermail/attachments/20111107/a616bb23/attachment.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 1491 bytes
Desc: not available
URL: </pipermail/attachments/20111107/a616bb23/attachment-0001.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 1287 bytes
Desc: not available
URL: </pipermail/attachments/20111107/a616bb23/attachment-0002.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 1472 bytes
Desc: not available
URL: </pipermail/attachments/20111107/a616bb23/attachment-0003.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 1131 bytes
Desc: not available
URL: </pipermail/attachments/20111107/a616bb23/attachment-0004.gif>


More information about the Gnutls-help mailing list