Skip to content

Commit

Permalink
better endpointIDs on Windows when compiling without OpenSSL
Browse files Browse the repository at this point in the history
  • Loading branch information
willamowius committed Mar 11, 2021
1 parent bc4fb03 commit ade1b6f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions changes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Changes from 5.7 to 5.8
=======================
- BUGFIX(job.cxx) better endpointIDs on Windows when compiling without OpenSSL


Changes from 5.6 to 5.7
Expand Down
7 changes: 6 additions & 1 deletion job.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Abstraction of threads' jobs
//
// Copyright (c) Citron Network Inc. 2002-2003
// Copyright (c) 2006-2015, Jan Willamowius
// Copyright (c) 2006-2021, Jan Willamowius
//
// This work is published under the GNU Public License version 2 (GPLv2)
// see file COPYING for details.
Expand Down Expand Up @@ -141,6 +141,11 @@ Worker::Worker(
m_idleTimeout(idleTimeout*1000), m_closed(false), m_job(NULL), m_id(0),
m_agent(agent)
{
#ifdef _WIN32
// on Windows srand() is thread-local, thus we must initialized every thread to make them at least slightly better
// only used as fallback when OpenSSL isn't available, eg. for endpointIDs
srand((unsigned int)time(NULL) * GetThreadId());
#endif
// resume suspended thread (and run Main)
Resume();
}
Expand Down

0 comments on commit ade1b6f

Please sign in to comment.