arpadboda commented on a change in pull request #677: MINIFICPP-1065 - Fix UUID
generation uniqueness and thread safety
URL: https://github.com/apache/nifi-minifi-cpp/pull/677#discussion_r344199560
##########
File path: libminifi/src/utils/Id.cpp
##########
@@ -16,25 +16,64 @@
* limitations under the License.
*/
+// This needs to be included first to let uuid.h sort out the system header
collisions
+#ifndef WIN32
+#include "uuid++.hh"
+#endif
+
#include "utils/Id.h"
+
#define __STDC_FORMAT_MACROS 1
#include <inttypes.h>
-#include <uuid/uuid.h>
-
#include <algorithm>
#include <chrono>
#include <cmath>
+#include <cstdio>
#include <memory>
#include <string>
+#include <limits>
#include "core/logging/LoggerConfiguration.h"
#include "utils/StringUtils.h"
+#ifdef WIN32
+#include "Rpc.h"
+#include "Winsock2.h"
+#pragma comment(lib, "Rpcrt4.lib")
+#pragma comment(lib, "Ws2_32.lib")
+#endif
+
namespace org {
namespace apache {
namespace nifi {
namespace minifi {
namespace utils {
+#ifdef WIN32
+namespace {
+ void windows_uuid_to_uuid_field(UUID* uuid, UUID_FIELD out) {
+ uint32_t Data1BE = htonl(uuid->Data1);
+ memcpy(out, &Data1BE, 4);
+ uint16_t Data2BE = htons(uuid->Data2);
+ memcpy(out + 4, &Data2BE, 2);
+ uint16_t Data3BE = htons(uuid->Data3);
+ memcpy(out + 6, &Data3BE, 2);
+ memcpy(out + 8, uuid->Data4, 8);
+ }
+
+ void windows_uuid_generate_time(UUID_FIELD out) {
Review comment:
Most of the function in this file are camelcase.
As we don't have consistent naming within the project files, this is not
going to prevent me from approving this, just a minor sidenote.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services