]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Added gnutls_record_is_async()
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Tue, 27 Jan 2015 12:06:10 +0000 (13:06 +0100)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Tue, 27 Jan 2015 12:09:18 +0000 (13:09 +0100)
That function indicates whether gnutls_record_recv() and
gnutls_record_send() can be used independently and in
parallel.

lib/gnutls_record.c
lib/includes/gnutls/gnutls.h.in
lib/libgnutls.map

index 4058fa843b16a16f6b0fb81d3a15f4a3d4a57dfd..931e97fdc82fcdddda3e50cb11eea53ee1fa16d2 100644 (file)
@@ -1512,6 +1512,29 @@ gnutls_record_discard_queued(gnutls_session_t session)
        return ret;
 }
 
+/**
+ * gnutls_record_is_async:
+ * @session: is a #gnutls_session_t structure.
+ *
+ * This will indicate whether the DTLS session is in asynchronous mode,
+ * i.e., handshake data may still be received and retransmitted. During
+ * that time gnutls_record_send() and gnutls_record_recv() must be only be
+ * used in the same process or thread (see gnutls_record_send() for more information).
+ *
+ * In a TLS session this function always returns zero.
+ *
+ * Returns: Non-zero if the session is in async mode, or zero otherwise.
+ *
+ * Since: 3.4.0
+ **/
+unsigned
+gnutls_record_is_async(gnutls_session_t session)
+{
+       if (IS_DTLS(session) && _dtls_is_async(session) && _dtls_async_timer_active(session))
+               return 1;
+       return 0;
+}
+
 /**
  * gnutls_record_recv_packet:
  * @session: is a #gnutls_session_t structure.
@@ -1570,6 +1593,12 @@ gnutls_record_recv_packet(gnutls_session_t session,
  * mode, and will refuse to send data over the MTU size by returning
  * %GNUTLS_E_LARGE_PACKET.
  *
+ * This function can be used in parallel with gnutls_record_recv() in a
+ * multi-thread or multi-process scenario if TLS is in use, or in DTLS
+ * when gnutls_record_is_async() returns zero (that will happen few seconds after
+ * the handshake is terminated). In all cases, each process or thread must
+ * be restricted to use one of the send or recv functions.
+ *
  * Returns: The number of bytes sent, or a negative error code.  The
  *   number of bytes sent might be less than @data_size.  The maximum
  *   number of bytes this function can send in a single call depends
index c8e3fc26b0f502ab3db262a965df45690d442b20..4cd84638094973686fd8a993d7917885c7d7e3eb 100644 (file)
@@ -933,6 +933,7 @@ void gnutls_record_cork(gnutls_session_t session);
 #define GNUTLS_RECORD_WAIT 1
 int gnutls_record_uncork(gnutls_session_t session, unsigned int flags);
 size_t gnutls_record_discard_queued(gnutls_session_t session);
+unsigned gnutls_record_is_async(gnutls_session_t session);
 
 typedef struct {
        size_t low;
index 57da7f7329a84f8e9efa526a3c7c4ae606c2cefd..fbf34b159d286f9e14809b0042f4427850e3e44a 100644 (file)
@@ -1016,6 +1016,7 @@ GNUTLS_3_4
        gnutls_pkcs11_get_raw_issuer_by_dn;
        gnutls_x509_trust_list_get_issuer_by_dn;
        gnutls_system_recv_timeout;
+       gnutls_record_is_async;
   local:
        *;
 };