~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_init.c

Removed SCCS references.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
#include "mysys_priv.h"
17
17
#include "my_static.h"
18
 
#include <mysys/mysys_err.h>
19
 
#include <mystrings/m_string.h>
20
 
#include <mystrings/m_ctype.h>
 
18
#include "mysys_err.h"
 
19
#include <m_string.h>
 
20
#include <m_ctype.h>
21
21
#include <signal.h>
22
22
 
23
 
bool my_init_done= 0;
 
23
my_bool my_init_done= 0;
24
24
uint    mysys_usage_id= 0;              /* Incremented for each my_init() */
25
 
uint32_t   my_thread_stack_size= 65536;
 
25
ulong   my_thread_stack_size= 65536;
26
26
 
27
 
static uint32_t atoi_octal(const char *str)
 
27
static ulong atoi_octal(const char *str)
28
28
{
29
29
  long int tmp;
30
 
  while (*str && my_isspace(&my_charset_utf8_general_ci, *str))
 
30
  while (*str && my_isspace(&my_charset_latin1, *str))
31
31
    str++;
32
32
  str2int(str,
33
33
          (*str == '0' ? 8 : 10),       /* Octalt or decimalt */
34
34
          0, INT_MAX, &tmp);
35
 
  return (uint32_t) tmp;
 
35
  return (ulong) tmp;
36
36
}
37
37
 
38
38
 
47
47
    1  Couldn't initialize environment
48
48
*/
49
49
 
50
 
bool my_init(void)
 
50
my_bool my_init(void)
51
51
{
52
52
  char * str;
53
53
  if (my_init_done)
57
57
  my_umask= 0660;                       /* Default umask for new files */
58
58
  my_umask_dir= 0700;                   /* Default umask for new directories */
59
59
  init_glob_errs();
60
 
#if defined(SAFE_MUTEX)
 
60
#if defined(THREAD) && defined(SAFE_MUTEX)
61
61
  safe_mutex_global_init();             /* Must be called early */
62
62
#endif
63
 
#if defined(MY_PTHREAD_FASTMUTEX) && !defined(SAFE_MUTEX)
 
63
#if defined(THREAD) && defined(MY_PTHREAD_FASTMUTEX) && !defined(SAFE_MUTEX)
64
64
  fastmutex_global_init();              /* Must be called early */
65
65
#endif
 
66
#ifdef THREAD
66
67
#if defined(HAVE_PTHREAD_INIT)
67
 
  pthread_init();
 
68
  pthread_init();                       /* Must be called before DBUG_ENTER */
68
69
#endif
69
70
  if (my_thread_global_init())
70
71
    return 1;
71
72
  sigfillset(&my_signals);              /* signals blocked by mf_brkhant */
 
73
#endif /* THREAD */
72
74
  {
 
75
    DBUG_ENTER("my_init");
 
76
    DBUG_PROCESS((char*) (my_progname ? my_progname : "unknown"));
73
77
    if (!home_dir)
74
78
    {                                   /* Don't initialize twice */
75
79
      if ((home_dir=getenv("HOME")) != 0)
80
84
        /* Default creation of new dir's */
81
85
      if ((str=getenv("UMASK_DIR")) != 0)
82
86
        my_umask_dir=(int) (atoi_octal(str) | 0700);
 
87
      DBUG_PRINT("exit",("home: '%s'",home_dir));
83
88
    }
84
 
    return(0);
 
89
    DBUG_RETURN(0);
85
90
  }
86
91
} /* my_init */
87
92
 
95
100
    Sun CC: Sun C++ 5.6 2004/06/02 for x86, and should not be
96
101
    optimized until this compiler is not in use anymore
97
102
  */
98
 
  FILE *info_file= stderr;
99
 
  bool print_info= 0;
 
103
  FILE *info_file= DBUG_FILE;
 
104
  my_bool print_info= (info_file != stderr);
 
105
  /*
 
106
    We do not use DBUG_ENTER here, as after cleanup DBUG is no longer
 
107
    operational, so we cannot use DBUG_RETURN.
 
108
  */
 
109
  DBUG_PRINT("info",("Shutting down: infoflag: %d  print_info: %d",
 
110
                     infoflag, print_info));
 
111
  if (!info_file)
 
112
  {
 
113
    info_file= stderr;
 
114
    print_info= 0;
 
115
  }
100
116
 
101
117
  if ((infoflag & MY_CHECK_ERROR) || print_info)
102
118
 
105
121
    {
106
122
      sprintf(errbuff[0],EE(EE_OPEN_WARNING),my_file_opened,my_stream_opened);
107
123
      (void) my_message_no_curses(EE_OPEN_WARNING,errbuff[0],ME_BELL);
 
124
      DBUG_PRINT("error",("%s",errbuff[0]));
108
125
      my_print_open_files();
109
126
    }
110
127
  }
118
135
    struct rusage rus;
119
136
#ifdef HAVE_purify
120
137
    /* Purify assumes that rus is uninitialized after getrusage call */
121
 
    memset(&rus, 0, sizeof(rus));
 
138
    bzero((char*) &rus, sizeof(rus));
122
139
#endif
123
140
    if (!getrusage(RUSAGE_SELF, &rus))
124
141
      fprintf(info_file,"\n\
143
160
    TERMINATE(stderr, 0);               /* Print memory leaks on screen */
144
161
  }
145
162
 
 
163
  if (!(infoflag & MY_DONT_FREE_DBUG))
 
164
  {
 
165
    DBUG_END();                /* Must be done before my_thread_end */
 
166
  }
 
167
#ifdef THREAD
146
168
  my_thread_end();
147
169
  my_thread_global_end();
148
170
#if defined(SAFE_MUTEX)
153
175
  safe_mutex_end((infoflag & (MY_GIVE_INFO | MY_CHECK_ERROR)) ? stderr :
154
176
                 (FILE *) 0);
155
177
#endif /* defined(SAFE_MUTEX) */
 
178
#endif /* THREAD */
156
179
 
157
180
  my_init_done=0;
158
181
} /* my_end */