guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: crypt mutex


From: Kevin Ryde
Subject: Re: crypt mutex
Date: Sat, 24 Jul 2004 09:53:11 +1000
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3 (gnu/linux)

It took a while but I made the change below to protect crypt,
introducing a new scm_i_misc_mutex intended for miscellaneous uses,
like this one, which don't rate highly enough to deserve their own
personal mutex.

        * threads.c, threads.h (scm_i_misc_mutex): New SCM_GLOBAL_MUTEX.
        * posix.c (scm_crypt): Use it to protect static data in crypt().

Thread trouble in the old code can be provoked fairly easily with
something like the following.  It's not the sort of thing that can be
added to a test suite, but at least it shows the change has an effect
:-).


(use-modules (ice-9 threads))

(define k1 "blahblah")
(define s1 "99")
(define e1 (crypt k1 s1))

(define k2 "foobar")
(define s2 "77")
(define e2 (crypt k2 s2))

(begin-thread
 (while #t
   (display "-")
   (let ((e (crypt k1 s1)))
     (if (not (string=? e1 e))
         (begin
           (format #t "oops, wrong e1, got ~s want ~s\n" e e1)
           (exit 1))))))

(while #t
  (display ".")
  (let ((e (crypt k2 s2)))
    (if (not (string=? e2 e))
        (begin
          (format #t "oops, wrong e2, got ~s want ~s\n" e e2)
          (exit 1)))))


Attachment: posix.c.crypt.diff
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]