Skip to content

Commit

Permalink
fix windows compatability (#556)
Browse files Browse the repository at this point in the history
* fix windows compatability
  • Loading branch information
henryzhx8 committed Dec 8, 2022
1 parent f91ff3b commit 2900354
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/common/MachineInfoUtil.cpp
Expand Up @@ -418,7 +418,7 @@ bool IsDigitsDotsHostname(const char* hostname) {
int16_t digits = 32;
while (*cp != '\0' && digits > 0) {
char* endp;
u_int64_t sum = strtoul(cp, &endp, 0);
uint64_t sum = strtoul(cp, &endp, 0);
if ((sum == ULONG_MAX && errno == ERANGE) || sum >= (1UL << digits)) {
break;
}
Expand Down
1 change: 0 additions & 1 deletion core/common/util.cpp
Expand Up @@ -25,7 +25,6 @@
#include <execinfo.h>
#elif defined(_MSC_VER)
#include <Rpc.h>
#include "WinUuid.h"
#endif
#include "logger/Logger.h"
#include "StringTools.h"
Expand Down
1 change: 1 addition & 0 deletions core/monitor/Monitor.cpp
Expand Up @@ -30,6 +30,7 @@
#include "common/DevInode.h"
#include "common/GlobalPara.h"
#include "common/version.h"
#include "common/MachineInfoUtil.h"
#include "log_pb/sls_logs.pb.h"
#include "logger/Logger.h"
#include "sender/Sender.h"
Expand Down
1 change: 1 addition & 0 deletions core/plugin/LogtailPlugin.h
Expand Up @@ -18,6 +18,7 @@
#include <cstdint>
#include <cstdlib>
#include <ostream>
#include <numeric>
#include <json/json.h>
#include "config/Config.h"
#if defined(_MSC_VER)
Expand Down
2 changes: 1 addition & 1 deletion core/sdk/CurlAsynInstance.cpp
Expand Up @@ -147,7 +147,7 @@ namespace sdk {
ErrorCheck(httpMsg.content, requestId, httpMsg.statusCode);
} catch (LOGException& e) {
const auto& errCode = e.GetErrorCode();
const auto& errMsg = e.GetMessage();
const auto& errMsg = e.GetMessage_();
if (AppConfig::GetInstance()->EnableLogTimeAutoAdjust() && sdk::LOGE_REQUEST_TIME_EXPIRED == errCode) {
time_t serverTime = httpMsg.GetServerTimeFromHeader();
if (serverTime > 0) {
Expand Down
1 change: 1 addition & 0 deletions core/sdk/Exception.h
Expand Up @@ -48,6 +48,7 @@ namespace sdk {
* @return Error message string.
*/
std::string GetMessage(void) const { return mMessage; }
// for windows compatability, to avoid conflict with the same function defined in windows.h
std::string GetMessage_() const { return mMessage; }
/** Function that return request id.
* @param void None.
Expand Down
11 changes: 9 additions & 2 deletions core/sls_control/SLSControl.cpp
Expand Up @@ -12,14 +12,21 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "SLSControl.h"
#include <thread>
#include <curl/curl.h>
#if defined(__linux__)
#include <sys/utsname.h>
#include "SLSControl.h"
#endif
#include "app_config/AppConfig.h"
#include "common/LogtailCommonFlags.h"
#include "common/version.h"
#include "logger/Logger.h"
#include "profiler/LogFileProfiler.h"
// for windows compatability, to avoid conflict with the same function defined in windows.h
#ifdef SetPort
#undef SetPort
#endif

DEFINE_FLAG_STRING(custom_user_agent, "custom user agent appended at the end of the exsiting ones", "");

Expand Down Expand Up @@ -119,7 +126,7 @@ bool SLSControl::TryCurlEndpoint(const std::string& endpoint) {
if (curl) {
break;
}
sleep(1);
std::this_thread::sleep_for(std::chrono::seconds(1));
}

if (curl) {
Expand Down

0 comments on commit 2900354

Please sign in to comment.