Skip to contentSkip to conversation

libuuid: use randutils

PATCH Applied Davidlohr Bueso 3 participants 4 messages Apr 5, 2012 – May 3, 2012 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 libuuid: use randutils

From: Davidlohr Bueso <[email protected]>

---
 libuuid/src/Makefile.am |    3 +-
 libuuid/src/gen_uuid.c  |   99 ++--------------------------------------------
 2 files changed, 7 insertions(+), 95 deletions(-)
libuuid/src/Makefile.am +2 -1
index 66ab2d4..8e87210 100644
@@ -25,7 +25,8 @@ libuuid_la_SOURCES = \
 	uuidd.h \
 	uuidP.h \
 	uuid_time.c \
-	$(uuidinc_HEADERS)
+	$(uuidinc_HEADERS) \
+	$(top_srcdir)/lib/randutils.c
 
 libuuid_la_DEPENDENCIES = uuid.sym
 
libuuid/src/gen_uuid.c +5 -94

141 lines not on this page · raw message

Signature · 1 line
1.7.4.1
maintainer Applied
#1 lore raw
Quoted 3 lines · Davidlohr Bueso
 libuuid/src/Makefile.am |    3 +-
 libuuid/src/gen_uuid.c  |   99 ++--------------------------------------------
 2 files changed, 7 insertions(+), 95 deletions(-)

Applied, thanks.

libuuid/src/gen_uuid.c void uuid_generate_random(uuid_t out) · line 618

Quoted 7 lines
libuuid/src/gen_uuid.c +1 -1
@@ -703,7 +614,7 @@ void uuid_generate_random(uuid_t out)
  */
 void uuid_generate(uuid_t out)
 {
-	if (get_random_fd() >= 0)
+	if (random_get_fd() >= 0)
 		uuid_generate_random(out);

This sucks:

- because we call random_get_fd() in __uuid_generate_random again:

   $ strace -e open ./misc-utils/uuidgen
   open("/dev/urandom", O_RDONLY)          = 3
   open("/dev/urandom", O_RDONLY)          = 4

it would be better to add 'fd' argument to __uuid_generate_random(), use it in uuid_generate() and reuse the file descriptor if >= 0.

We use __uuid_generate_random in the library and in uuidd, so we don't have to care about API there.

- it's file descriptor leak in shared library...

Volunteers? ;-)

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
#2 lore raw
Quoted 26 lines · Karel Zak
Quoted 3 lines · Davidlohr Bueso
 libuuid/src/Makefile.am |    3 +-
 libuuid/src/gen_uuid.c  |   99 ++--------------------------------------------
 2 files changed, 7 insertions(+), 95 deletions(-)

Applied, thanks.

libuuid/src/gen_uuid.c void uuid_generate_random(uuid_t out) · line 618

Quoted 7 lines
libuuid/src/gen_uuid.c +1 -1
@@ -703,7 +614,7 @@ void uuid_generate_random(uuid_t out)
  */
 void uuid_generate(uuid_t out)
 {
-	if (get_random_fd() >= 0)
+	if (random_get_fd() >= 0)
 		uuid_generate_random(out);

This sucks:

- because we call random_get_fd() in __uuid_generate_random again:

   $ strace -e open ./misc-utils/uuidgen
   open("/dev/urandom", O_RDONLY)          = 3
   open("/dev/urandom", O_RDONLY)          = 4

it would be better to add 'fd' argument to __uuid_generate_random(), use it in uuid_generate() and reuse the file descriptor if >= 0.

Quoted 6 lines

We use __uuid_generate_random in the library and in uuidd, so we don't have to care about API there.

- it's file descriptor leak in shared library...

Volunteers? ;-)

If nobody steps out, I can include this in my uuidd systemd-ization series (which I'll hopefully finish this week).

Petr

--
Petr Uzel
IRC: ptr_uzl @ freenode

#3 lore raw
In reply to Karel Zak
Quoted 26 lines · Karel Zak
Quoted 3 lines · Davidlohr Bueso
 libuuid/src/Makefile.am |    3 +-
 libuuid/src/gen_uuid.c  |   99 ++--------------------------------------------
 2 files changed, 7 insertions(+), 95 deletions(-)

Applied, thanks.

libuuid/src/gen_uuid.c void uuid_generate_random(uuid_t out) · line 618

Quoted 7 lines
libuuid/src/gen_uuid.c +1 -1
@@ -703,7 +614,7 @@ void uuid_generate_random(uuid_t out)
  */
 void uuid_generate(uuid_t out)
 {
-	if (get_random_fd() >= 0)
+	if (random_get_fd() >= 0)
 		uuid_generate_random(out);

This sucks:

- because we call random_get_fd() in __uuid_generate_random again:

   $ strace -e open ./misc-utils/uuidgen
   open("/dev/urandom", O_RDONLY)          = 3
   open("/dev/urandom", O_RDONLY)          = 4

it would be better to add 'fd' argument to __uuid_generate_random(), use it in uuid_generate() and reuse the file descriptor if >= 0.

Quoted 6 lines

We use __uuid_generate_random in the library and in uuidd, so we don't have to care about API there.

- it's file descriptor leak in shared library...

Volunteers? ;-)

Patch addressing this is included in the uuidd series I sent shortly before. But please check the note about it in the series cover letter.

Thanks,

Petr

Signature · 2 lines
Petr Uzel
IRC: ptr_uzl @ freenode