#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
+#include <pthread.h>
#include <netinet/in.h>
#include <event.h>
static char *nmsg_output_filename;
static int nmsg_output_fd = -1;
+static pthread_mutex_t outmtx = PTHREAD_MUTEX_INITIALIZER;
+
static void
ssm_nmsg_reload(void)
{
+ pthread_mutex_lock(&outmtx);
+
+ if (nmsg_out) nmsg_output_close(&nmsg_out);
+
if (nmsg_output_fd >= 0)
close(nmsg_output_fd);
nmsg_output_fd = open(nmsg_output_filename,
O_CREAT|O_WRONLY|O_APPEND, 0644);
- if (nmsg_out) nmsg_output_close(&nmsg_out);
nmsg_out = nmsg_output_open_file(nmsg_output_fd, 4096);
nmsg_output_set_buffered(nmsg_out, 0);
+
+ pthread_mutex_unlock(&outmtx);
}
static void
{
struct ssm_nmsg_state *nms = ssm_getpriv(&ss_module, c);
if (nms && nms->msg && nmsg_out) {
+ pthread_mutex_lock(&outmtx);
nmsg_output_write(nmsg_out, nms->msg);
+ pthread_mutex_unlock(&outmtx);
}
ssm_nmsg_cleanup(c);
return SSM_PASS;