static void update_file_path()

in plugin/server_audit/server_audit.cc [2235:2278]


static void update_file_path(MYSQL_THD thd,
              struct SYS_VAR *var  __attribute__((unused)),
              void *var_ptr  __attribute__((unused)), const void *save)
{
   const char *new_name= (*(const char * const*)(save)) ? *(const char * const*)(save) : empty_str;

  ADD_ATOMIC(internal_stop_logging, 1);
  error_header();
  fprintf(stderr, "Log file name was changed to '%s'.\n", new_name);

  mysql_prlock_wrlock(&lock_operations);

  if (logging)
    log_current_query(thd);

  if (logging && output_type == OUTPUT_FILE)
  {
    char *sav_path= file_path;

    file_path= const_cast<char*>(new_name);
    stop_logging();
    if (start_logging())
    {
      file_path= sav_path;
      error_header();
      fprintf(stderr, "Reverting log filename back to '%s'.\n", file_path);
      logging= (start_logging() == 0);
      if (!logging)
      {
        error_header();
        fprintf(stderr, "Logging was disabled..\n");
        CLIENT_ERROR(1, "Logging was disabled.", MYF(ME_WARNING));
      }
      goto exit_func;
    }
  }

  strncpy(path_buffer, new_name, sizeof(path_buffer)-1);
  path_buffer[sizeof(path_buffer)-1]= 0;
  file_path= path_buffer;
exit_func:
  mysql_prlock_unlock(&lock_operations);
  ADD_ATOMIC(internal_stop_logging, -1);
}