{
if (output_ctx != NULL) {
LogFileCtx *logfile_ctx = (LogFileCtx *)output_ctx->data;
+ OutputUnregisterFileRotationFlag(&logfile_ctx->rotation_flag);
if (logfile_ctx != NULL) {
LogFileFreeCtx(logfile_ctx);
}
static void AlertFastLogDeInitCtx(OutputCtx *output_ctx)
{
LogFileCtx *logfile_ctx = (LogFileCtx *)output_ctx->data;
+ OutputUnregisterFileRotationFlag(&logfile_ctx->rotation_flag);
LogFileFreeCtx(logfile_ctx);
SCFree(output_ctx);
}
SCPerfClubTMInst *temp = NULL;
pctmi = sc_perf_op_ctx->pctmi;
+ OutputUnregisterFileRotationFlag(&sc_perf_op_ctx->rotation_flag);
+
if (sc_perf_op_ctx->fp != NULL)
fclose(sc_perf_op_ctx->fp);
static void LogDnsLogDeInitCtx(OutputCtx *output_ctx)
{
LogDnsFileCtx *dnslog_ctx = (LogDnsFileCtx *)output_ctx->data;
+ OutputUnregisterFileRotationFlag(&dnslog_ctx->file_ctx->rotation_flag);
LogFileFreeCtx(dnslog_ctx->file_ctx);
SCFree(dnslog_ctx);
SCFree(output_ctx);
if (output_ctx != NULL) {
LogFileCtx *logfile_ctx = (LogFileCtx *)output_ctx->data;
if (logfile_ctx != NULL) {
+ OutputUnregisterFileRotationFlag(&logfile_ctx->rotation_flag);
LogFileFreeCtx(logfile_ctx);
}
SCFree(output_ctx);
static void LogFileLogDeInitCtx(OutputCtx *output_ctx)
{
LogFileCtx *logfile_ctx = (LogFileCtx *)output_ctx->data;
+ OutputUnregisterFileRotationFlag(&logfile_ctx->rotation_flag);
LogFileFreeCtx(logfile_ctx);
free(output_ctx);
}
for (i = 0; i < httplog_ctx->cf_n; i++) {
SCFree(httplog_ctx->cf_nodes[i]);
}
+ OutputUnregisterFileRotationFlag(&httplog_ctx->file_ctx->rotation_flag);
LogFileFreeCtx(httplog_ctx->file_ctx);
SCFree(httplog_ctx);
SCFree(output_ctx);
OutputTlsLoggerDisable();
LogTlsFileCtx *tlslog_ctx = (LogTlsFileCtx *) output_ctx->data;
+ OutputUnregisterFileRotationFlag(&tlslog_ctx->file_ctx->rotation_flag);
LogFileFreeCtx(tlslog_ctx->file_ctx);
SCFree(tlslog_ctx);
SCFree(output_ctx);
{
OutputJsonCtx *json_ctx = (OutputJsonCtx *)output_ctx->data;
LogFileCtx *logfile_ctx = json_ctx->file_ctx;
+ OutputUnregisterFileRotationFlag(&logfile_ctx->rotation_flag);
LogFileFreeCtx(logfile_ctx);
SCFree(json_ctx);
SCFree(output_ctx);
ssh_loggers--;
}
-void OutputRegisterFileRotationFlag(int *flag)
-{
+/**
+ * \brief Register a flag for file rotation notification.
+ *
+ * \param flag A pointer that will be set to 1 when file rotation is
+ * requested.
+ */
+void OutputRegisterFileRotationFlag(int *flag) {
OutputFileRolloverFlag *flag_entry = SCCalloc(1, sizeof(*flag_entry));
if (unlikely(flag_entry == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC,
TAILQ_INSERT_TAIL(&output_file_rotation_flags, flag_entry, entries);
}
-void OutputNotifyFileRotation(void)
-{
+/**
+ * \brief Unregister a file rotation flag.
+ *
+ * Note that it is safe to call this function with a flag that may not
+ * have been registered, in which case this function won't do
+ * anything.
+ *
+ * \param flag A pointer that has been previously registered for file
+ * rotation notifications.
+ */
+void OutputUnregisterFileRotationFlag(int *flag) {
+ OutputFileRolloverFlag *entry, *next;
+ for (entry = TAILQ_FIRST(&output_file_rotation_flags); entry != NULL;
+ entry = next) {
+ next = TAILQ_NEXT(entry, entries);
+ if (entry->flag == flag) {
+ TAILQ_REMOVE(&output_file_rotation_flags, entry, entries);
+ SCFree(entry);
+ break;
+ }
+ }
+}
+
+/**
+ * \brief Notifies all registered file rotation notification flags.
+ */
+void OutputNotifyFileRotation(void) {
OutputFileRolloverFlag *flag;
TAILQ_FOREACH(flag, &output_file_rotation_flags, entries) {
*(flag->flag) = 1;
void OutputSshLoggerDisable(void);
void OutputRegisterFileRotationFlag(int *flag);
+void OutputUnregisterFileRotationFlag(int *flag);
void OutputNotifyFileRotation(void);
#endif /* ! __OUTPUT_H__ */