Skip to content

Commit

Permalink
v1.0.4: Fix potential threaded issues (fix #18, PR #39) and a socket …
Browse files Browse the repository at this point in the history
…leak (fix #38)
  • Loading branch information
r-lyeh committed Apr 9, 2022
1 parent d294df4 commit 358466a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
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>
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>
====

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

### Changelog
- v1.0.4 (2022/04/09): Fix potential threaded issues (fix #18, PR #39) and a socket leak (fix #38)
- v1.0.3 (2022/01/17): Merge fixes by @jasonwinterpixel(emscripten) + @jj-tetraquark(get_any_mac)
- v1.0.2 (2021/03/16): Merge speed improvements by @vihangm
- v1.0.1 (2017/05/16): Improve UUID4 and base62 performance; Fix warnings
Expand Down
9 changes: 5 additions & 4 deletions sole.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@

// public API

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

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

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

inline uuid uuid4() {
static std::random_device rd;
static std::uniform_int_distribution<uint64_t> dist(0, (uint64_t)(~0));
static $msvc(__declspec(thread)) $melse(__thread) std::random_device rd;
static $msvc(__declspec(thread)) $melse(__thread) std::uniform_int_distribution<uint64_t> dist(0, (uint64_t)(~0));

uuid my;

Expand Down

0 comments on commit 358466a

Please sign in to comment.