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

out_gelf: Port the random seed generation to Windows #2614

Merged
merged 1 commit into from
Sep 30, 2020
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: 2 additions & 15 deletions plugins/out_gelf/gelf.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <fluent-bit/flb_gzip.h>
#include <fluent-bit/flb_utils.h>
#include <fluent-bit/flb_network.h>
#include <fluent-bit/flb_random.h>
#include <msgpack.h>

#include <stdio.h>
Expand Down Expand Up @@ -321,8 +322,6 @@ static void cb_gelf_flush(const void *data, size_t bytes,
static int cb_gelf_init(struct flb_output_instance *ins, struct flb_config *config,
void *data)
{
int ret;
int fd;
const char *tmp;
struct flb_out_gelf_config *ctx = NULL;

Expand Down Expand Up @@ -408,21 +407,9 @@ static int cb_gelf_init(struct flb_output_instance *ins, struct flb_config *conf
}

/* init random seed */
fd = open("/dev/urandom", O_RDONLY);
if (fd == -1) {
if (flb_random_bytes((unsigned char *) &ctx->seed, sizeof(int))) {
ctx->seed = time(NULL);
}
else {
unsigned int val;
ret = read(fd, &val, sizeof(val));
if (ret > 0) {
ctx->seed = val;
}
else {
ctx->seed = time(NULL);
}
close(fd);
}
srand(ctx->seed);

ctx->fd = -1;
Expand Down