Example #1
0
void my_mutex_init()
{
  /* Initialize mutex attributes */
#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
  /*
    Set mutex type to "fast" a.k.a "adaptive"

    In this case the thread may steal the mutex from some other thread
    that is waiting for the same mutex.  This will save us some
    context switches but may cause a thread to 'starve forever' while
    waiting for the mutex (not likely if the code within the mutex is
    short).
  */
  pthread_mutexattr_init(&my_fast_mutexattr);
  pthread_mutexattr_settype(&my_fast_mutexattr,
                            PTHREAD_MUTEX_ADAPTIVE_NP);
#endif
#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
  /*
    Set mutex type to "errorcheck"
  */
  pthread_mutexattr_init(&my_errorcheck_mutexattr);
  pthread_mutexattr_settype(&my_errorcheck_mutexattr,
                            PTHREAD_MUTEX_ERRORCHECK);
#endif

#if defined(SAFE_MUTEX_DEFINED)
  safe_mutex_global_init();
#elif defined(MY_PTHREAD_FASTMUTEX)
  fastmutex_global_init();
#endif
}
Example #2
0
my_bool my_init(void)
{
  char * str;
  if (my_init_done)
    return 0;
  my_init_done=1;
  mysys_usage_id++;
  my_umask= 0660;                       /* Default umask for new files */
  my_umask_dir= 0700;                   /* Default umask for new directories */
  init_glob_errs();
#if defined(THREAD)
  if (my_thread_global_init())
    return 1;
#  if defined(SAFE_MUTEX)
  safe_mutex_global_init();		/* Must be called early */
#  endif
#endif
#if defined(THREAD) && defined(MY_PTHREAD_FASTMUTEX) && !defined(SAFE_MUTEX)
  fastmutex_global_init();              /* Must be called early */
#endif
  netware_init();
#ifdef THREAD
#if defined(HAVE_PTHREAD_INIT)
  pthread_init();			/* Must be called before DBUG_ENTER */
#endif
#if !defined( __WIN__) && !defined(__NETWARE__)
  sigfillset(&my_signals);		/* signals blocked by mf_brkhant */
#endif
#endif /* THREAD */
  {
    DBUG_ENTER("my_init");
    DBUG_PROCESS((char*) (my_progname ? my_progname : "unknown"));
    if (!home_dir)
    {					/* Don't initialize twice */
      my_win_init();
      if ((home_dir=getenv("HOME")) != 0)
	home_dir=intern_filename(home_dir_buff,home_dir);
#ifndef VMS
      /* Default creation of new files */
      if ((str=getenv("UMASK")) != 0)
	my_umask=(int) (atoi_octal(str) | 0600);
	/* Default creation of new dir's */
      if ((str=getenv("UMASK_DIR")) != 0)
	my_umask_dir=(int) (atoi_octal(str) | 0700);
#endif
#ifdef VMS
      init_ctype();			/* Stupid linker don't link _ctype.c */
#endif
      DBUG_PRINT("exit",("home: '%s'",home_dir));
    }
#ifdef __WIN__
    win32_init_tcp_ip();
#endif
    DBUG_RETURN(0);
  }
} /* my_init */
Example #3
0
/**
  Initialize my_sys functions, resources and variables

  @return Initialization result
    @retval 0 Success
    @retval 1 Error. Couldn't initialize environment
*/
my_bool my_init(void)
{
  char *str;

  if (my_init_done)
    return 0;

  my_init_done= 1;

  mysys_usage_id++;
  my_umask= 0660;                       /* Default umask for new files */
  my_umask_dir= 0700;                   /* Default umask for new directories */

  /* Default creation of new files */
  if ((str= getenv("UMASK")) != 0)
    my_umask= (int) (atoi_octal(str) | 0600);
  /* Default creation of new dir's */
  if ((str= getenv("UMASK_DIR")) != 0)
    my_umask_dir= (int) (atoi_octal(str) | 0700);

  init_glob_errs();

  instrumented_stdin.m_file= stdin;
  instrumented_stdin.m_psi= NULL;       /* not yet instrumented */
  mysql_stdin= & instrumented_stdin;

  if (my_thread_global_init())
    return 1;

#if defined(SAFE_MUTEX)
  safe_mutex_global_init();		/* Must be called early */
#endif

#if defined(MY_PTHREAD_FASTMUTEX) && !defined(SAFE_MUTEX)
  fastmutex_global_init();              /* Must be called early */
#endif

#if defined(HAVE_PTHREAD_INIT)
  pthread_init();			/* Must be called before DBUG_ENTER */
#endif

  /* $HOME is needed early to parse configuration files located in ~/ */
  if ((home_dir= getenv("HOME")) != 0)
    home_dir= intern_filename(home_dir_buff, home_dir);

  {
    DBUG_ENTER("my_init");
    DBUG_PROCESS((char*) (my_progname ? my_progname : "unknown"));
    my_win_init();
    DBUG_PRINT("exit", ("home: '%s'", home_dir));
#ifdef __WIN__
    win32_init_tcp_ip();
#endif
    DBUG_RETURN(0);
  }
} /* my_init */
Example #4
0
void my_init(void)
{
    my_string str;
    if (my_init_done)
        return;
    my_init_done=1;
#if defined(THREAD) && defined(SAFE_MUTEX)
    safe_mutex_global_init();		/* Must be called early */
#endif
    netware_init();
#ifdef THREAD
#if defined(HAVE_PTHREAD_INIT)
    pthread_init();			/* Must be called before DBUG_ENTER */
#endif
    my_thread_global_init();
#if !defined( __WIN__) && !defined(OS2) && !defined(__NETWARE__)
    sigfillset(&my_signals);		/* signals blocked by mf_brkhant */
#endif
#endif /* THREAD */
#ifdef UNIXWARE_7
    (void) isatty(0);			/* Go around connect() bug in UW7 */
#endif
    {
        DBUG_ENTER("my_init");
        DBUG_PROCESS(my_progname ? my_progname : (char*) "unknown");
        if (!home_dir)
        {   /* Don't initialize twice */
            my_win_init();
            if ((home_dir=getenv("HOME")) != 0)
                home_dir=intern_filename(home_dir_buff,home_dir);
#ifndef VMS
            /* Default creation of new files */
            if ((str=getenv("UMASK")) != 0)
                my_umask=(int) (atoi_octal(str) | 0600);
            /* Default creation of new dir's */
            if ((str=getenv("UMASK_DIR")) != 0)
                my_umask_dir=(int) (atoi_octal(str) | 0700);
#endif
#ifdef VMS
            init_ctype();			/* Stupid linker don't link _ctype.c */
#endif
            DBUG_PRINT("exit",("home: '%s'",home_dir));
        }
#ifdef __WIN__
        win32_init_tcp_ip();
#endif
        DBUG_VOID_RETURN;
    }
} /* my_init */
Example #5
0
/**
  Perform a limited initialisation of mysys.
  This initialisation is sufficient to:
  - allocate memory,
  - read configuration files,
  - parse command lines arguments.
  To complete the mysys initialisation,
  call my_init().
  @return 0 on success
*/
my_bool my_basic_init(void)
{
  char * str;

  if (my_basic_init_done)
    return 0;
  my_basic_init_done= 1;

  mysys_usage_id++;
  my_umask= 0660;                       /* Default umask for new files */
  my_umask_dir= 0700;                   /* Default umask for new directories */

  /* Default creation of new files */
  if ((str= getenv("UMASK")) != 0)
    my_umask= (int) (atoi_octal(str) | 0600);
  /* Default creation of new dir's */
  if ((str= getenv("UMASK_DIR")) != 0)
    my_umask_dir= (int) (atoi_octal(str) | 0700);

  init_glob_errs();

  instrumented_stdin.m_file= stdin;
  instrumented_stdin.m_psi= NULL;       /* not yet instrumented */
  mysql_stdin= & instrumented_stdin;

  if (my_thread_global_init())
    return 1;

#if defined(SAFE_MUTEX)
  safe_mutex_global_init();		/* Must be called early */
#endif

#if defined(MY_PTHREAD_FASTMUTEX) && !defined(SAFE_MUTEX)
  fastmutex_global_init();              /* Must be called early */
#endif

#if defined(HAVE_PTHREAD_INIT)
  pthread_init();			/* Must be called before DBUG_ENTER */
#endif
  if (my_thread_basic_global_init())
    return 1;

  /* $HOME is needed early to parse configuration files located in ~/ */
  if ((home_dir= getenv("HOME")) != 0)
    home_dir= intern_filename(home_dir_buff, home_dir);

  return 0;
}