Fix build on windows

pull/517/head
Michael 5 years ago
parent 9bc501bbf7
commit afa058c4ee

@ -1,6 +1,7 @@
#ifndef LLARP_HPP #ifndef LLARP_HPP
#define LLARP_HPP #define LLARP_HPP
#include <util/fs.hpp>
#include <util/types.hpp> #include <util/types.hpp>
#include <ev/ev.hpp> #include <ev/ev.hpp>
@ -49,7 +50,7 @@ namespace llarp
bool singleThreaded = false; bool singleThreaded = false;
bool disableMetrics = false; bool disableMetrics = false;
bool disableMetricLogs = false; bool disableMetricLogs = false;
std::string jsonMetricsPath; fs::path jsonMetricsPath;
std::string metricTankHost; std::string metricTankHost;
std::map< std::string, std::string > metricTags; std::map< std::string, std::string > metricTags;

@ -12,7 +12,9 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/types.h> #include <sys/types.h>
#else #else
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h> #include <windows.h>
#include <winsock2.h> #include <winsock2.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
@ -85,6 +87,7 @@ namespace llarp
} }
break; break;
} }
assert(false && "Invalid publication type");
} }
std::string std::string
@ -198,21 +201,21 @@ namespace llarp
publishData(const std::vector< std::string > &toSend, publishData(const std::vector< std::string > &toSend,
const std::string &host, short port) const std::string &host, short port)
{ {
struct addrinfo *result = NULL, hints; struct addrinfo *addrs = NULL, hints;
bzero(&hints, sizeof(hints)); ZeroMemory(&hints, sizeof(hints));
hints.ai_family = AF_UNSPEC; hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP; hints.ai_protocol = IPPROTO_TCP;
const std::string portAsStr = std::to_string(port); const std::string portAsStr = std::to_string(port);
if(getaddrinfo(host.c_str(), portAsStr.c_str(), &hints, &result) != 0) if(getaddrinfo(host.c_str(), portAsStr.c_str(), &hints, &addrs) != 0)
{ {
LogError("Failed to get address info"); LogError("Failed to get address info");
return; return;
} }
int sock = SOCKET sock =
::socket(addrs->ai_family, addrs->ai_socktype, addrs->ai_protocol); ::socket(addrs->ai_family, addrs->ai_socktype, addrs->ai_protocol);
if(sock == INVALID_SOCKET) if(sock == INVALID_SOCKET)
@ -248,7 +251,7 @@ namespace llarp
&& (static_cast< size_t >(sentLen) < val.size())); && (static_cast< size_t >(sentLen) < val.size()));
} }
shutdown(sock, SHUT_RDWR); shutdown(sock, SD_SEND);
closesocket(sock); closesocket(sock);
} }
#endif #endif

@ -280,7 +280,7 @@ namespace llarp
void void
JsonPublisher::directoryPublisher(const nlohmann::json &result, JsonPublisher::directoryPublisher(const nlohmann::json &result,
fs::path path) const fs::path& path)
{ {
std::ofstream fstream(path.string(), std::ios_base::app); std::ofstream fstream(path.string(), std::ios_base::app);
if(!fstream) if(!fstream)

@ -50,7 +50,7 @@ namespace llarp
publish(const Sample& values) override; publish(const Sample& values) override;
static void static void
directoryPublisher(const nlohmann::json& result, fs::path path); directoryPublisher(const nlohmann::json& result, const fs::path& path);
}; };
} // namespace metrics } // namespace metrics

Loading…
Cancel
Save