From: Pete Zaitcev <zaitcev@redhat.com>
To: Jeff Garzik <jeff@garzik.org>
Cc: Project Hail List <hail-devel@vger.kernel.org>
Subject: [Patch 3/4] libcldc: add cldc_init
Date: Sat, 8 Aug 2009 00:28:00 -0600 [thread overview]
Message-ID: <20090808002800.087aba2e@redhat.com> (raw)
A missing call to srand() was causing us trouble since libcldc relies
on rand(). Since rand() is a rather ugly function and we may want to
change the implementation later, create a way to initialize the library.
Signed-Off-By: Pete Zaitcev <zaitcev@redhat.com>
diff --git a/include/cldc.h b/include/cldc.h
index 491ec36..f625d5e 100644
--- a/include/cldc.h
+++ b/include/cldc.h
@@ -156,11 +156,11 @@ struct cld_dirent_cur {
* @param buflen Length of received packet
* @return Zero for success, non-zero on error
*/
-
extern int cldc_receive_pkt(struct cldc_session *sess,
const void *net_addr, size_t net_addrlen,
const void *buf, size_t buflen);
+extern void cldc_init(void);
extern int cldc_new_sess(const struct cldc_ops *ops,
const struct cldc_call_opts *copts,
const void *addr, size_t addr_len,
diff --git a/lib/cldc.c b/lib/cldc.c
index 420c2be..5cccc63 100644
--- a/lib/cldc.c
+++ b/lib/cldc.c
@@ -1359,3 +1359,13 @@ char *cldc_dirent_name(struct cld_dirent_cur *dc)
return s;
}
+/*
+ * For extra safety, call cldc_init after g_thread_init, if present.
+ * Currently we just call srand(), but since we use GLib, we may need
+ * to add some Glib stuff here and that must come after g_thread_init.
+ */
+void cldc_init()
+{
+ srand(time(NULL) ^ getpid()); // for __cld_rand64 et.al.
+}
+
reply other threads:[~2009-08-08 6:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20090808002800.087aba2e@redhat.com \
--to=zaitcev@redhat.com \
--cc=hail-devel@vger.kernel.org \
--cc=jeff@garzik.org \
/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.
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.