Hi Steven,

this patch covers a small corner case where we want to stop logging to file forever.

with the actual implementation it is enough to unset LOG_MODE_OUTPUT_FILE and nothing is written to the file, but the file is still open and the descriptor in use.

this is just one possible way to allow to stop logging to file and close the fd.

could you please consider either applying this one, or make sure to close the fd when we unset LOG_MODE_OUTPUT_FILE.

Thanks
Fabio

--
I'm going to make him an offer he can't refuse.
Index: exec/logsys.c
===================================================================
--- exec/logsys.c       (revision 1552)
+++ exec/logsys.c       (working copy)
@@ -456,6 +456,36 @@
        return (0);
 }
 
+int logsys_config_file_close (char **error_string)
+{
+       static char error_string_response[512];
+       int error;
+
+       pthread_mutex_lock (&logsys_new_log_mutex);
+       pthread_mutex_lock (&logsys_config_mutex);
+
+       if (logsys_file_fp != NULL) {
+               error = fclose (logsys_file_fp);
+               if (error =! 0) {
+                       sprintf (error_string_response,
+                               "Can't close logfile (%s).\n",
+                                       strerror (errno));
+                       *error_string = error_string_response;
+                       pthread_mutex_unlock (&logsys_config_mutex);
+                       pthread_mutex_unlock (&logsys_new_log_mutex);
+                       return (-1);
+               }
+               logsys_file_fp = NULL;
+               if (logsys_mode & LOG_MODE_OUTPUT_FILE) {
+                       logsys_mode &= ~LOG_MODE_OUTPUT_FILE;
+               }
+       }
+
+       pthread_mutex_unlock (&logsys_config_mutex);
+       pthread_mutex_unlock (&logsys_new_log_mutex);
+       return (0);
+}
+
 void logsys_config_facility_set (char *name, unsigned int facility)
 {
        pthread_mutex_lock (&logsys_new_log_mutex);
Index: exec/logsys.h
===================================================================
--- exec/logsys.h       (revision 1552)
+++ exec/logsys.h       (working copy)
@@ -104,6 +104,8 @@
        char **error_string,
        char *file);
 
+extern int logsys_config_file_close (char **error_string);
+
 extern void logsys_config_facility_set (
        char *name,
        unsigned int facility);
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to