From: Lars Ingebrigtsen <larsi@gnus.org>
To: Vasilij Schneidermann <mail@vasilij.de>
Cc: 42998@debbugs.gnu.org
Subject: bug#42998: 27.1; gnutls-symmetric-encrypt slow when providing cipher as symbol
Date: Mon, 24 Aug 2020 15:01:01 +0200 [thread overview]
Message-ID: <87y2m4ci5u.fsf@gnus.org> (raw)
In-Reply-To: <20200823164330.GA72308@odonien.localdomain> (Vasilij Schneidermann's message of "Sun, 23 Aug 2020 18:43:30 +0200")
Vasilij Schneidermann <mail@vasilij.de> writes:
> I'd consider either to
> document this behavior or making the mapping more efficient, for example
> by caching the cipher list instead of recomputing it over and over
> again.
The following fixes the problem, but I'm not quite sure whether it's
correct... Is initialising a Lisp_Object to NULL something that's
allowed over all platforms? I can't initialise it to the more natural
Qnil, since that's not a constant, C-wise.
diff --git a/src/gnutls.c b/src/gnutls.c
index 416fb15470..75bc7d970f 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -2303,6 +2303,8 @@ gnutls_symmetric (bool encrypting, Lisp_Object cipher,
Lisp_Object key, Lisp_Object iv,
Lisp_Object input, Lisp_Object aead_auth)
{
+ static Lisp_Object cipher_cache = NULL;
+
if (BUFFERP (key) || STRINGP (key))
key = list1 (key);
@@ -2329,7 +2331,12 @@ gnutls_symmetric (bool encrypting, Lisp_Object cipher,
if (SYMBOLP (cipher))
{
- info = Fassq (cipher, Fgnutls_ciphers ());
+ if (! cipher_cache)
+ {
+ cipher_cache = Fgnutls_ciphers ();
+ staticpro (&cipher_cache);
+ }
+ info = Fassq (cipher, cipher_cache);
if (!CONSP (info))
xsignal2 (Qerror,
build_string ("GnuTLS cipher is invalid or not found"),
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
next prev parent reply other threads:[~2020-08-24 13:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-23 16:43 bug#42998: 27.1; gnutls-symmetric-encrypt slow when providing cipher as symbol Vasilij Schneidermann
2020-08-24 13:01 ` Lars Ingebrigtsen [this message]
2020-08-24 13:31 ` Eli Zaretskii
2020-08-24 14:22 ` Lars Ingebrigtsen
2020-08-24 14:33 ` Eli Zaretskii
2020-08-24 14:28 ` Lars Ingebrigtsen
2020-08-24 14:36 ` Eli Zaretskii
2020-08-24 14:45 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y2m4ci5u.fsf@gnus.org \
--to=larsi@gnus.org \
--cc=42998@debbugs.gnu.org \
--cc=mail@vasilij.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.