[Pkg-gnupg-commit] [gnupg2] 75/241: dirmngr: Minor cleanup of the SRV RR code.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Wed Dec 9 20:31:57 UTC 2015
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch master
in repository gnupg2.
commit 949a5cfdabcafab93c1ac092c0459b59318805b9
Author: Werner Koch <wk at gnupg.org>
Date: Wed Oct 28 10:14:07 2015 +0100
dirmngr: Minor cleanup of the SRV RR code.
* dirmngr/dns-stuff.c: Include unistd.h.
(getsrv): Run srand only once.
* dirmngr/t-dns-stuff.c (main): Allow passing another name for --srv
and change output format.
---
dirmngr/dns-stuff.c | 14 +++++++++++---
dirmngr/t-dns-stuff.c | 11 +++++------
2 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/dirmngr/dns-stuff.c b/dirmngr/dns-stuff.c
index 3689d8f..3220d76 100644
--- a/dirmngr/dns-stuff.c
+++ b/dirmngr/dns-stuff.c
@@ -42,6 +42,7 @@
# include <netdb.h>
#endif
#include <string.h>
+#include <unistd.h>
#ifdef USE_ADNS
# include <adns.h>
#endif
@@ -1103,9 +1104,16 @@ getsrv (const char *name,struct srventry **list)
/* Run the RFC-2782 weighting algorithm. We don't need very high
quality randomness for this, so regular libc srand/rand is
- sufficient. Fixme: It is a bit questionaly to reinitalize srand
- - better use a gnupg fucntion for this. */
- srand(time(NULL)*getpid());
+ sufficient. */
+
+ {
+ static int done;
+ if (!done)
+ {
+ done = 1;
+ srand (time (NULL)*getpid());
+ }
+ }
for (i=0; i < srvcount; i++)
{
diff --git a/dirmngr/t-dns-stuff.c b/dirmngr/t-dns-stuff.c
index 4ecbd64..191b581 100644
--- a/dirmngr/t-dns-stuff.c
+++ b/dirmngr/t-dns-stuff.c
@@ -205,15 +205,14 @@ main (int argc, char **argv)
struct srventry *srv;
int rc,i;
- rc=getsrv("_hkp._tcp.wwwkeys.pgp.net",&srv);
- printf("Count=%d\n\n",rc);
+ rc=getsrv (name? name : "_hkp._tcp.wwwkeys.pgp.net", &srv);
+ printf("Count=%d\n",rc);
for(i=0;i<rc;i++)
{
- printf("priority=%hu\n",srv[i].priority);
- printf("weight=%hu\n",srv[i].weight);
- printf("port=%hu\n",srv[i].port);
+ printf("priority=%-8hu ",srv[i].priority);
+ printf("weight=%-8hu ",srv[i].weight);
+ printf("port=%-5hu ",srv[i].port);
printf("target=%s\n",srv[i].target);
- printf("\n");
}
xfree(srv);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git
More information about the Pkg-gnupg-commit
mailing list