Пример #1
0
/*
 * boot_compact_stop () - stop database compaction
 *   return: error_code
 */
int
boot_compact_stop (THREAD_ENTRY * thread_p)
{
  int current_tran_index = -1;

  if (csect_enter (thread_p, CSECT_COMPACTDB_ONE_INSTANCE, INF_WAIT) !=
      NO_ERROR)
    {
      return ER_FAILED;
    }

  current_tran_index = LOG_FIND_THREAD_TRAN_INDEX (thread_p);
  if (current_tran_index != last_tran_index && compact_started == true)
    {
      csect_exit (CSECT_COMPACTDB_ONE_INSTANCE);
      return ER_FAILED;
    }

  last_tran_index = -1;
  compact_started = false;

  csect_exit (CSECT_COMPACTDB_ONE_INSTANCE);

  return NO_ERROR;
}
Пример #2
0
/*
 * event_log_end -
 *   return:
 */
void
event_log_end (THREAD_ENTRY * thread_p)
{
  assert (csect_check_own (thread_p, CSECT_EVENT_LOG_FILE) == 1);

  if (event_Fp == NULL)
    {
      return;
    }

  fflush (event_Fp);
  csect_exit (thread_p, CSECT_EVENT_LOG_FILE);
}
Пример #3
0
/*
 * event_log_start -
 *   return: log file pointer
 *   event_name(in):
 */
FILE *
event_log_start (THREAD_ENTRY * thread_p, const char *event_name)
{
  time_t er_time;
  struct tm er_tm;
  struct tm *er_tm_p = &er_tm;
  struct timeval tv;
  char time_array[256];
  const char *log_file_name = event_log_file_path;

  csect_enter (thread_p, CSECT_EVENT_LOG_FILE, INF_WAIT);

  /* If file is not exist, it will recreate *log_fh file. */
  if (event_Fp == NULL || access (log_file_name, F_OK) == -1)
    {
      if (event_Fp != NULL)
	{
	  (void) fclose (event_Fp);
	}

      event_Fp = event_file_open (log_file_name);
      if (event_Fp == NULL)
	{
	  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_GENERIC_ERROR, 0);
	  csect_exit (thread_p, CSECT_EVENT_LOG_FILE);
	  return NULL;
	}
    }
  else if (ftell (event_Fp) > prm_get_integer_value (PRM_ID_ER_LOG_SIZE))
    {
      (void) fflush (event_Fp);

      event_Fp = event_file_backup (event_Fp, log_file_name);
      if (event_Fp == NULL)
	{
	  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_GENERIC_ERROR, 0);
	  csect_exit (thread_p, CSECT_EVENT_LOG_FILE);
	  return NULL;
	}
    }

  er_time = time (NULL);
#if defined (SERVER_MODE) && !defined (WINDOWS)
  er_tm_p = localtime_r (&er_time, &er_tm);
#else /* SERVER_MODE && !WINDOWS */
  er_tm_p = localtime (&er_time);
#endif /* SERVER_MODE && !WINDOWS */

  if (er_tm_p == NULL)
    {
      strcpy (time_array, "00/00/00 00:00:00.000");
    }
  else
    {
      gettimeofday (&tv, NULL);
      snprintf (time_array + strftime (time_array, 128, "%m/%d/%y %H:%M:%S", er_tm_p), 255, ".%03ld",
		tv.tv_usec / 1000);
    }

  fprintf (event_Fp, "%s - %s\n", time_array, event_name);

  return event_Fp;
}