To protect your data, the CISO officer has suggested users to enable GitLab 2FA as soon as possible.

Commit a51f9028 authored by john's avatar john
Browse files

moving to buffered logging

parent 0885880d
......@@ -88,6 +88,15 @@ int fileNameSequence = 0;
long logFileSequenceLength = 0;
jboolean check_limit = FALSE;
#define BUFFER_SIZE 16384
struct buffer_s {
struct buffer_s* next;
char* buffer;
int buffer_len;
int buffer_pos;
} *buffer_head = NULL;
static void openLogFile() {
char logFileName[LOG_FILE_NAME_MAX+SEQUENCE_MAX];
int fileSeq = fileNameSequence++;
......@@ -403,6 +412,25 @@ static char end_of_line = '\n';
/* */
void* log_get_buffer() {
struct buffer_s* buffer = NULL;
if (buffer_head == NULL) {
buffer = (struct buffer_s*)malloc(sizeof(struct buffer_s));
buffer->buffer = (char*)malloc(sizeof(char)*BUFFER_SIZE);
buffer->buffer_len = BUFFER_SIZE;
} else {
buffer = buffer_head;
buffer_head = buffer_head->next;
}
buffer->buffer_pos = 0;
return buffer;
}
void log_put_buffer(void* buffer) {
((struct buffer_s*)buffer)->next = buffer_head;
buffer_head = (struct buffer_s*)buffer;
}
static void write_field(const char* text, int text_length, _Bool use_delimiter) {
if (logFile == FILE_IS_CLOSED) {
fprintf(stderr,"LOG_FILE IS CLOSED\n");
......@@ -558,6 +586,35 @@ void log_eol() {
}
}
void log_buffer_ensure_space(struct buffer_s* b, int size) {
if ((b->buffer_len - b->buffer_pos) < 0) {
char* tmp = (char*)malloc(sizeof(char)*(2*b->buffer_len));
memcpy(tmp, b->buffer, sizeof(char)*b->buffer_len);
free(b->buffer);
b->buffer = tmp;
}
}
/*
void log_eol(void* buffer) {
struct buffer_s* b = buffer;
log_buffer_ensure_space(b, 1);
b->buffer[b->buffer_pos++] = end_of_line;
WRITE(b->buffer,sizeof(char),b->buffer_pos);
first_field = TRUE;
FLUSH();
log_put_buffer(b);
if (check_limit && LOG_FILE_LIMIT <= logFileSequenceLength) {
openLogFile();
}
}
*/
/*
* Class: org_dacapo_instrument_Agent
* Method: agentThread
......
......@@ -62,6 +62,7 @@ void callReportHeap(JNIEnv *env);
void setReportHeap(JNIEnv *env, jboolean flag);
void setReportCallChain(JNIEnv *env, jlong frequency, jboolean enable);
void* log_get_buffer();
void log_field_string(const char* text);
void log_field_string_n(const char* text, int text_length);
void log_field_jboolean(jboolean v);
......
......@@ -18,11 +18,12 @@ public class EventAllocation extends Event implements EventHasThread {
private String threadClass;
private String threadName;
private long size;
private int siteId;
public EventAllocation(long time, long objectTag,
long classTag, String className,
long threadTag, long threadClassTag, String threadClassName, String threadName,
long size) {
long size, int siteId) {
super(time);
this.objectTag = objectTag;
this.allocClassTag = classTag;
......@@ -32,6 +33,7 @@ public class EventAllocation extends Event implements EventHasThread {
this.threadClass = threadClassName;
this.threadName = threadName;
this.size = size;
this.siteId = siteId;
}
public String getLogPrefix() {
......@@ -69,6 +71,7 @@ public class EventAllocation extends Event implements EventHasThread {
public void setThreadName(String threadName) { this.threadName = threadName; }
public long getSize() { return size; }
public int getSiteId() { return siteId; }
EventAllocation(CSVInputStream is) throws NoFieldAvailable, ParseError, EventParseException {
super(is);
......@@ -81,6 +84,7 @@ public class EventAllocation extends Event implements EventHasThread {
this.allocClass = is.nextFieldString();
this.size = is.nextFieldLong();
this.siteId = is.nextFieldInt();
if (is.numberOfFieldsLeft()!=0 && this instanceof EventAllocation)
throw new EventParseException("additional field",null);
......
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