Skip to content

Commit

Permalink
Merge pull request #16 from alibaba/develop
Browse files Browse the repository at this point in the history
fix : may crash during log dump, because new logs may be written at the same time.
  • Loading branch information
zhi1ong authored Dec 21, 2021
2 parents 8c0c828 + 7945119 commit 85e7dc3
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
mavenCentral()
}
dependencies {
implementation 'com.alibaba:patrons:1.0.6.3'
implementation 'com.alibaba:patrons:1.0.6.4'
}
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ ext {
ndkVersion = "20.1.5948944"
cmakeVersion = "3.10.2"
abiFilters = "armeabi-v7a"
versionName = "1.0.6.3"
versionName = "1.0.6.4"
}
2 changes: 1 addition & 1 deletion patrons/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ POM_NAME=Patrons SDK
POM_ARTIFACT_ID=patrons
POM_PACKAGING=aar
POM_DESCRIPTION=Patrons SDK for android.
VERSION_NAME=1.0.6.3
VERSION_NAME=1.0.6.4
16 changes: 10 additions & 6 deletions patrons/src/main/cpp/patrons_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,20 +336,24 @@ Java_com_alibaba_android_patronus__1Patrons_getCurrentRegionSpaceSize(__unused J

JNIEXPORT jstring JNICALL
Java_com_alibaba_android_patronus__1Patrons_dumpLogs(JNIEnv *env, jclass clazz, jboolean cleanAfterDump) {
if (dump_cursor <= 0) {
char current_cursor = dump_cursor;

if (current_cursor <= 0) {
return (*env)->NewStringUTF(env, "the native log buffer is empty");
}

char *tmp = malloc(dump_cursor * 256 * sizeof(char));
memset(tmp, 0, dump_cursor * 256 * sizeof(char));
char *tmp = malloc(current_cursor * 256 * sizeof(char));
memset(tmp, 0, current_cursor * 256 * sizeof(char));
strcat(tmp, "\nPatrons Core Dump: ");
strcat(tmp, __PATRONS_API_VERSION);
strcat(tmp, "↵\n");

// 按行拼接日志
for (int i = 0; i < dump_cursor; i++) {
strcat(tmp, dump_logs[i]);
strcat(tmp, "↵\n");
for (int i = 0; i < current_cursor; i++) {
if (dump_logs[i] != NULL) {
strcat(tmp, dump_logs[i]);
strcat(tmp, "↵\n");
}
}

strcat(tmp, "\n");
Expand Down
2 changes: 1 addition & 1 deletion patrons/src/main/cpp/patrons_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#define __ANDROID_API_S__ 31

// patrons version 定义
#define __PATRONS_API_VERSION "1.0.6.3"
#define __PATRONS_API_VERSION "1.0.6.4"

char *dump_logs[128] = {0};
char dump_cursor = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public static class PatronsConfig {
/**
* 是否记录初始化结果
*/
public boolean recordInitResult = true;
public boolean recordInitResult = false;

@Override
public String toString() {
Expand Down

0 comments on commit 85e7dc3

Please sign in to comment.