Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolves meetecho/janus-gateway#2624 jansson double referencing #2634

Merged
merged 6 commits into from
Apr 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions events/janus_gelfevh.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ static int janus_gelfevh_send(char *message) {
int n = send(sockfd, head, bytesToSend + 12, 0);
if(n < 0) {
JANUS_LOG(LOG_WARN, "Sending UDP message failed: %d (%s)\n", errno, g_strerror(errno));
g_free(rnd);
return -1;
}
offset += bytesToSend;
Expand Down Expand Up @@ -589,25 +590,27 @@ static void *janus_gelfevh_handler(void *data) {
json_t *microtimestamp = json_object_get(event, "timestamp");
if(microtimestamp && json_is_integer(microtimestamp)) {
double created_timestamp = (double)json_integer_value(microtimestamp) / 1000000;
json_object_set(output, "timestamp", json_real(created_timestamp));
json_object_set_new(output, "timestamp", json_real(created_timestamp));
} else {
json_object_set(output, "timestamp", json_real(janus_get_real_time()));
json_object_set_new(output, "timestamp", json_real(janus_get_real_time()));
}
json_object_set(output, "host", json_object_get(event, "emitter"));
json_object_set(output, "version", json_string("1.1"));
json_object_set_new(output, "version", json_string("1.1"));
json_object_set(output, "level", json_object_get(event, "type"));
json_object_set(output, "short_message", json_string(short_message));
json_object_set_new(output, "short_message", json_string(short_message));
json_object_set(output, "full_message", event);

if(janus_gelfevh_send(json_dumps(output, json_format)) < 0) {
JANUS_LOG(LOG_WARN, "Couldn't send event to GELF, reconnect?, or event was null: %s\n",
json_dumps(output, json_format));
char *message = json_dumps(output, json_format);
if(janus_gelfevh_send(message) < 0) {
JANUS_LOG(LOG_WARN, "Couldn't send event to GELF, reconnect?, or event was null: %s\n", message);
}
json_decref(output);
free(message);
mirkobrankovic marked this conversation as resolved.
Show resolved Hide resolved
output = NULL;

break;
}
json_decref(event);
}
JANUS_LOG(LOG_VERB, "Leaving GELF Event handler thread\n");
return NULL;
Expand Down