To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.7% of users enabled 2FA.

Commit dfb7e61e authored by john's avatar john
Browse files

code tidying in dacapolog

parent 8bcec28c
...@@ -38,33 +38,6 @@ gzFile gzLogFile; ...@@ -38,33 +38,6 @@ gzFile gzLogFile;
jboolean gzLog = FALSE; jboolean gzLog = FALSE;
#define CLOSE() { \
if (gzLog) gzclose(gzLogFile); \
close(logFile); \
logFile = FILE_IS_CLOSED; \
}
#define OPEN(f) { \
FILE_TYPE tmp = logFile; \
gzFile tmpgz = gzLogFile; \
logFile = open(f,FILE_FLAGS,FILE_MODE); \
if (gzLog) { \
gzFile localtmpgz = gzdopen(logFile,GZ_FILE_MODE); \
gzbuffer(localtmpgz, GZ_BUFFER_SIZE); \
gzLogFile = localtmpgz; \
} \
if (tmp != FILE_IS_CLOSED) { \
if (gzLog) gzclose(tmpgz); \
close(tmp); \
} \
}
#define FLUSH()
#define WRITE(b,e,n) { \
if (gzLog) { logFileSequenceLength += gzwrite(gzLogFile,b,(e)*(n)); } \
else { logFileSequenceLength += write(logFile,b,(e)*(n)); } \
}
jboolean logState = FALSE; jboolean logState = FALSE;
jboolean localInitDone = FALSE; jboolean localInitDone = FALSE;
struct timeval startTime; struct timeval startTime;
...@@ -97,6 +70,40 @@ struct buffer_s { ...@@ -97,6 +70,40 @@ struct buffer_s {
int buffer_pos; int buffer_pos;
} *buffer_head = NULL; } *buffer_head = NULL;
static void log_close() {
if (gzLog)
gzclose(gzLogFile);
close(logFile);
logFile = FILE_IS_CLOSED;
}
static void log_open(const char* f) {
FILE_TYPE tmp = logFile;
gzFile tmpgz = gzLogFile;
logFile = open(f,FILE_FLAGS,FILE_MODE);
if (gzLog) {
gzFile localtmpgz = gzdopen(logFile,GZ_FILE_MODE);
gzbuffer(localtmpgz, GZ_BUFFER_SIZE);
gzLogFile = localtmpgz;
}
if (tmp != FILE_IS_CLOSED) {
if (gzLog) gzclose(tmpgz);
close(tmp);
}
}
static void log_flush() {
return;
}
static void log_write(struct buffer_s* b) {
if (gzLog) {
logFileSequenceLength += gzwrite(gzLogFile,b->buffer,sizeof(char)*(b->buffer_pos));
} else {
logFileSequenceLength += write(logFile,b->buffer,sizeof(char)*(b->buffer_pos));
}
}
static void openLogFile() { static void openLogFile() {
char logFileName[LOG_FILE_NAME_MAX+SEQUENCE_MAX]; char logFileName[LOG_FILE_NAME_MAX+SEQUENCE_MAX];
int fileSeq = fileNameSequence++; int fileSeq = fileNameSequence++;
...@@ -113,7 +120,7 @@ static void openLogFile() { ...@@ -113,7 +120,7 @@ static void openLogFile() {
sprintf(logFileName,"%s-%d.%s",baseLogFileName,fileSeq,baseLogFileExt); sprintf(logFileName,"%s-%d.%s",baseLogFileName,fileSeq,baseLogFileExt);
} }
OPEN(logFileName); log_open(logFileName);
logFileSequenceLength = 0; logFileSequenceLength = 0;
} }
...@@ -124,7 +131,7 @@ _Bool logFileOpen() { ...@@ -124,7 +131,7 @@ _Bool logFileOpen() {
void dacapo_log_stop() { void dacapo_log_stop() {
if (logFile != FILE_IS_CLOSED) if (logFile != FILE_IS_CLOSED)
CLOSE(); log_close();
} }
void setLogFileName(const char* log_file) { void setLogFileName(const char* log_file) {
...@@ -217,12 +224,14 @@ JNIEXPORT void JNICALL Java_org_dacapo_instrument_Agent_internalLocalInit ...@@ -217,12 +224,14 @@ JNIEXPORT void JNICALL Java_org_dacapo_instrument_Agent_internalLocalInit
log_java_class = (*env)->NewGlobalRef(env, klass); log_java_class = (*env)->NewGlobalRef(env, klass);
char tmp[1024]; char* tmp = NULL;
if (isSelected(OPT_INTERVAL,tmp)) { if (isSelected(OPT_INTERVAL,&tmp)) {
int value = atoi(tmp); int value = atoi(tmp);
if (value > 0) if (value > 0)
(*env)->SetStaticLongField(env,log_java_class,agentIntervalTimeID,(jlong)value); (*env)->SetStaticLongField(env,log_java_class,agentIntervalTimeID,(jlong)value);
free(tmp);
} }
localInitDone = !FALSE; localInitDone = !FALSE;
...@@ -597,9 +606,9 @@ void log_eol(void* buffer) { ...@@ -597,9 +606,9 @@ void log_eol(void* buffer) {
b->buffer[b->buffer_pos++] = end_of_line; b->buffer[b->buffer_pos++] = end_of_line;
WRITE(b->buffer,sizeof(char),b->buffer_pos); log_write(b);
first_field = TRUE; first_field = TRUE;
FLUSH(); log_flush();
log_buffer_put(b); log_buffer_put(b);
......
...@@ -71,6 +71,6 @@ public class Harness { ...@@ -71,6 +71,6 @@ public class Harness {
} else } else
urls = new URL[] { harnessJarURL }; urls = new URL[] { harnessJarURL };
return new URLClassLoader(urls); return URLClassLoader.newInstance(urls, classLoader);
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment