Skip to content

Commit

Permalink
fix: 1.7 compile on windows (#1076)
Browse files Browse the repository at this point in the history
* fix: 1.7 compile on windows

Signed-off-by: Tao Yu <[email protected]>

* update release hashes

Signed-off-by: Tao Yu <[email protected]>

---------

Signed-off-by: Tao Yu <[email protected]>
  • Loading branch information
yyuuttaaoo authored Aug 21, 2023
1 parent 091241e commit 41863a8
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 22 deletions.
7 changes: 5 additions & 2 deletions changes/v1.7.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ All issues and pull requests are [here](https://github.com/alibaba/ilogtail/mile

### Features

- [public] [both] [updated] Elasticsearch flusher new features: send batch request by bulk api and format index
- [public] [both] [added] Add new plugin: input_command
- [public] [both] [added] Add new plugin: processor_log_to_sls_metric
- [public] [both] [added] C++ Unit test CI
- [public] [both] [updated] Elasticsearch flusher new features: send batch request by bulk api and format index
- [public] [both] [updated] Service_http_server support raw type on v1
- [public] [both] [updated] Add v2 interface to processor_json
- [public] [both] [updated] Json processor support parsing array
Expand All @@ -18,6 +19,7 @@ All issues and pull requests are [here](https://github.com/alibaba/ilogtail/mile
- [public] [both] [updated] Upgrade go version to 1.19
- [public] [both] [updated] Refactory LogBuffer structure
- [inner] [both] [updated] Logtail containers monitor refine code
- [inner] [both] [updated] Add too long log split alarm

### Fixed

Expand All @@ -32,8 +34,9 @@ All issues and pull requests are [here](https://github.com/alibaba/ilogtail/mile
- [public] [both] [fixed] Update map time after mark container removed
- [public] [both] [fixed] Fix multi-bytes character cut off
- [public] [both] [fixed] Add timeout func when collect disk metrics
- [public] [both] [fixed] Fix too long log split alarm
- [public] [both] [fixed] Fix updating agent config's check_status in heartbeat in config server
- [public] [both] [fixed] Fix otlp flusher does not set Timestamp
- [public] [both] [fixed] Fix snapshot dir not created when apsara_log_conf.json exits
- [inner] [both] [fixed] Fix file name of shennong profile data in container

### Doc
Expand Down
1 change: 0 additions & 1 deletion core/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ if (MSVC)
add_definitions(-DNOMINMAX)
list(REMOVE_ITEM LIB_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/LinuxDaemonUtil.h)
list(REMOVE_ITEM LIB_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/LinuxDaemonUtil.cpp)
set(LIB_SOURCE_FILES ${LIB_SOURCE_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/strptime.c)
elseif (UNIX)
list(REMOVE_ITEM LIB_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/WinUuid.h)
list(REMOVE_ITEM LIB_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/WinUuid.cpp)
Expand Down
9 changes: 9 additions & 0 deletions core/common/StringTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

#include "StringTools.h"
#include <string.h>
#include <boost/algorithm/string.hpp>
#include <boost/xpressive/xpressive.hpp>
#include "logger/Logger.h"
Expand All @@ -29,6 +30,14 @@ std::string ToLowerCaseString(const std::string& orig) {
return copy;
}

int CStringNCaseInsensitiveCmp(const char* s1, const char* s2, size_t n) {
#if defined(_MSC_VER)
return _strnicmp(s1, s2, n);
#else
return strncasecmp(s1, s2, n);
#endif
}

std::string ToString(const std::vector<std::string>& vec) {
if (vec.empty())
return "";
Expand Down
2 changes: 2 additions & 0 deletions core/common/StringTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ inline bool EndWith(const std::string& input, const std::string& pattern) {

std::string ToLowerCaseString(const std::string& orig);

int CStringNCaseInsensitiveCmp(const char* s1, const char* s2, size_t n);

inline std::string LeftTrimString(const std::string& str, const char trimChar = ' ') {
auto s = str;
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [trimChar](int ch) { return trimChar != ch; }));
Expand Down
21 changes: 4 additions & 17 deletions core/common/Strptime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#include "Strptime.h"
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include "Strptime.h"
#include "common/StringTools.h"

namespace logtail {
/*
Expand Down Expand Up @@ -352,7 +353,7 @@ const char* strptime_ns(const char* buf, const char* fmt, struct tm* tm, long* n
continue;

case 'Z':
if (strncasecmp((const char*)bp, gmt, 3) == 0 || strncasecmp((const char *)bp, utc, 3) == 0) {
if (CStringNCaseInsensitiveCmp((const char*)bp, gmt, 3) == 0 || CStringNCaseInsensitiveCmp((const char *)bp, utc, 3) == 0) {
tm->tm_isdst = 0;
#ifdef TM_GMTOFF
tm->TM_GMTOFF = 0;
Expand Down Expand Up @@ -574,20 +575,6 @@ static const unsigned char* conv_nanosecond(const unsigned char* buf, long* dest
return buf;
}

static int strncasecmp(const char* s1, const char* s2, size_t n) {
if (n == 0)
return 0;

while (n-- != 0 && tolower(*s1) == tolower(*s2)) {
if (n == 0 || *s1 == '\0' || *s2 == '\0')
break;
s1++;
s2++;
}

return tolower(*(const unsigned char*)s1) - tolower(*(const unsigned char*)s2);
}

static const unsigned char*
find_string(const unsigned char* bp, int* tgt, const char* const* n1, const char* const* n2, int c) {
int i;
Expand All @@ -597,7 +584,7 @@ find_string(const unsigned char* bp, int* tgt, const char* const* n1, const char
for (; n1 != NULL; n1 = n2, n2 = NULL) {
for (i = 0; i < c; i++, n1++) {
len = strlen(*n1);
if (strncasecmp(*n1, (const char*)bp, len) == 0) {
if (CStringNCaseInsensitiveCmp(*n1, (const char*)bp, len) == 0) {
*tgt = i;
return bp + len;
}
Expand Down
4 changes: 3 additions & 1 deletion core/parser/LogParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ LogParser::ApsaraEasyReadLogTimeParser(const char* buffer, string& timeStr, time
}
struct tm tm;
memset(&tm, 0, sizeof(tm));
if (NULL == strptime(buffer + beg_index + 1, "%Y-%m-%d %H:%M:%S", &tm)) {
long nanosecond = 0;
int nanosecondLength = 0;
if (NULL == strptime_ns(buffer + beg_index + 1, "%Y-%m-%d %H:%M:%S", &tm, &nanosecond, &nanosecondLength)) {
LOG_WARNING(sLogger,
("parse apsara log time", "fail")("string", buffer)("timeformat", "%Y-%m-%d %H:%M:%S"));
return 0;
Expand Down
4 changes: 3 additions & 1 deletion core/reader/LogFileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1453,7 +1453,9 @@ bool LogFileReader::GetLogTimeByOffset(const char* buffer,
const std::string& logPath) {
struct tm t;
memset(&t, 0, sizeof(t));
if (strptime(buffer + pos, timeFormat.c_str(), &t) == NULL) {
long nanosecond = 0;
int nanosecondLength = 0;
if (strptime_ns(buffer + pos, timeFormat.c_str(), &t, &nanosecond, &nanosecondLength) == NULL) {
if (AppConfig::GetInstance()->IsLogParseAlarmValid()) {
if (LogtailAlarm::GetInstance()->IsLowLevelAlarmValid()) {
LOG_WARNING(sLogger,
Expand Down
55 changes: 55 additions & 0 deletions docs/cn/installation/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,60 @@
# 发布历史

## 1.7.1

### 发布记录

发版日期:2023 年 8 月 20 日

新功能

* 新增命令执行结果采集插件 input_command [#925](https://github.com/alibaba/ilogtail/pull/925)
* 新增log转sls metric插件 processor_log_to_sls_metric [#955](https://github.com/alibaba/ilogtail/pull/955)
* 新增log转sls trace插件 processor_otel_trace [#1028](https://github.com/alibaba/ilogtail/pull/1028)
* Elasticsearch flusher支持动态索引 [#979](https://github.com/alibaba/ilogtail/pull/979)
* HTTP Server支持接受原始文本 [#976](https://github.com/alibaba/ilogtail/issues/976)
* Json processor支持解析数组 [#972](https://github.com/alibaba/ilogtail/pull/972)

优化

* Service_prometheus支持K8s中自动伸缩 [#932](https://github.com/alibaba/ilogtail/pull/932)
* containerd容器采集支持自定义rootfs路径和自动发现路径 [#985](https://github.com/alibaba/ilogtail/pull/985)
* 纳秒级高精度时间性能优化和windows支持 [#1026](https://github.com/alibaba/ilogtail/pull/1026)
* 避免文件30天无更新后写入导致的重复采集问题 [#1039](https://github.com/alibaba/ilogtail/pull/1039)
* 添加C++ Core UT流水线 [#951](https://github.com/alibaba/ilogtail/pull/951)

问题修复

* 修复 service_go_profile可能panic的问题 [#1036](https://github.com/alibaba/ilogtail/pull/1036)
* 修复stdout文件路径为软链时无法采集容器stdout的问题 [#1037](https://github.com/alibaba/ilogtail/issues/1037)
* 修复zstd批量发送问题 [#1006](https://github.com/alibaba/ilogtail/pull/1006)
* 修复service_otlp插件无法退出的问题 [#1040](https://github.com/alibaba/ilogtail/pull/1040)
* 修复env创建配置时ttl值非法与空行为不一致的问题 [#1045](https://github.com/alibaba/ilogtail/issues/1045)
* 修复当只有容器删除事件时容器因fd所得无法退出的问题 [#986](https://github.com/alibaba/ilogtail/issues/986)
* 为system_v2插件采集disk metrics增加超时避免卡死 [#933](https://github.com/alibaba/ilogtail/pull/933)
* 修复profile中相同的容器内文件路径数据互相覆盖的问题 [#1034](https://github.com/alibaba/ilogtail/issues/1034)
* 修复apsara_log_conf.json文件存在时不创建snapshot目录的问题 [#944](https://github.com/alibaba/ilogtail/issues/944)
* 修复otlp flusher时间戳总为1970-01-01的问题 [#1031](https://github.com/alibaba/ilogtail/issues/1031)
* 修复config更新后config server下发为删除的问题 [#1023](https://github.com/alibaba/ilogtail/pull/1023)

[详情和源代码](https://github.com/alibaba/ilogtail/blob/main/changes/v1.7.1.md)

### 下载

| 文件名 | 系统 | 架构 | SHA256 校验码 |
| -------------------------------------------------------------------------------------------------------------------------------------------- | ----- | ------ | ---------------------------------------------------------------- |
| [ilogtail-1.7.1.linux-amd64.tar.gz](https://ilogtail-community-edition.oss-cn-shanghai.aliyuncs.com/1.7.1/ilogtail-1.7.1.linux-amd64.tar.gz) | Linux | x86-64 | 13029900e0bdd4f6db858d97b31d30f1659145fc40bfceb97f7946f35c94c232 |
| [ilogtail-1.7.1.linux-arm64.tar.gz](https://ilogtail-community-edition.oss-cn-shanghai.aliyuncs.com/1.7.1/ilogtail-1.7.1.linux-arm64.tar.gz) | Linux | arm64 | fe5e2e2b69cb664ed0fc0578d1fdec95e94ab00711b547c7b90591f0a07853e1 |
| [ilogtail-1.7.1.windows-amd64.zip](https://ilogtail-community-edition.oss-cn-shanghai.aliyuncs.com/1.7.1/ilogtail-1.7.1.windows-amd64.zip) | Windows | x86-64 | 593f734035f4c808654b638492f1e0d79205b2080a8975305f7f86b988841166 |

### Docker 镜像

**Docker Pull 命令**&#x20;

``` bash
docker pull sls-opensource-registry.cn-shanghai.cr.aliyuncs.com/ilogtail-community-edition/ilogtail:1.7.1
```

## 1.7.0

### 发布记录
Expand Down
1 change: 1 addition & 0 deletions scripts/windows64_dist.bat
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ cd %DIST_DIR%
del /f/s/q %PACKAGE_DIR%.windows-%ARCH%.zip
%Z_BIN% a -tzip %PACKAGE_DIR%.windows-%ARCH%.zip %PACKAGE_DIR%
rd /s /q %PACKAGE_DIR%
certUtil -hashfile %PACKAGE_DIR%.windows-%ARCH%.zip SHA256 | findstr /v "SHA256" | findstr /v CertUtil > %PACKAGE_DIR%.windows-%ARCH%.zip.sha256

0 comments on commit 41863a8

Please sign in to comment.