Skip to content

Commit 358466a

Browse files
committed
v1.0.4: Fix potential threaded issues (fix #18, PR #39) and a socket leak (fix #38)
1 parent d294df4 commit 358466a

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
sole <a href="https://travis-ci.org/r-lyeh/sole"><img src="https://api.travis-ci.org/r-lyeh/sole.svg?branch=master" align="right" /></a>
1+
sole <a href="https://travis-ci.org/r-lyeh/sole"><img src="https://api.travis-ci.org/r-lyeh-archived/sole.svg?branch=master" align="right" /></a>
22
====
33

44
- Sole is a lightweight C++11 library to generate universally unique identificators (UUID).
@@ -73,6 +73,7 @@ uuid v4 rebuilt : bdd55e2f-6f6b-4088-8703-ddedba9456a2 -> version=4,randbits=bdd
7373
- clang/g++ users: both `-std=c++11` and `-lrt` may be required when compiling `sole.cpp`
7474

7575
### Changelog
76+
- v1.0.4 (2022/04/09): Fix potential threaded issues (fix #18, PR #39) and a socket leak (fix #38)
7677
- v1.0.3 (2022/01/17): Merge fixes by @jasonwinterpixel(emscripten) + @jj-tetraquark(get_any_mac)
7778
- v1.0.2 (2021/03/16): Merge speed improvements by @vihangm
7879
- v1.0.1 (2017/05/16): Improve UUID4 and base62 performance; Fix warnings

sole.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@
5454

5555
// public API
5656

57-
#define SOLE_VERSION "1.0.3" /* (2022/01/17): Merge fixes by @jasonwinterpixel(emscripten) + @jj-tetraquark(get_any_mac)
57+
#define SOLE_VERSION "1.0.4" /* (2022/04/09): Fix potential threaded issues (fix #18, PR #39) and a socket leak (fix #38)
58+
#define SOLE_VERSION "1.0.3" // (2022/01/17): Merge fixes by @jasonwinterpixel(emscripten) + @jj-tetraquark(get_any_mac)
5859
#define SOLE_VERSION "1.0.2" // (2021/03/16): Merge speed improvements by @vihangm
5960
#define SOLE_VERSION "1.0.1" // (2017/05/16): Improve UUID4 and base62 performance; fix warnings
6061
#define SOLE_VERSION "1.0.0" // (2016/02/03): Initial semver adherence; Switch to header-only; Remove warnings */
@@ -601,7 +602,7 @@ namespace sole {
601602
int s = socket(PF_INET, SOCK_DGRAM, 0);
602603
if (s == -1) continue;
603604

604-
if (std::strcmp("lo", ifap->ifa_name) == 0) continue; // loopback address is zero
605+
if (std::strcmp("lo", ifap->ifa_name) == 0) { close(s); continue;} // loopback address is zero
605606

606607
std::strcpy(ifr.ifr_name, ifap->ifa_name);
607608
int rc = ioctl(s, SIOCGIFHWADDR, &ifr);
@@ -664,8 +665,8 @@ namespace sole {
664665
// UUID implementations
665666

666667
inline uuid uuid4() {
667-
static std::random_device rd;
668-
static std::uniform_int_distribution<uint64_t> dist(0, (uint64_t)(~0));
668+
static $msvc(__declspec(thread)) $melse(__thread) std::random_device rd;
669+
static $msvc(__declspec(thread)) $melse(__thread) std::uniform_int_distribution<uint64_t> dist(0, (uint64_t)(~0));
669670

670671
uuid my;
671672

0 commit comments

Comments
 (0)