~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_init.c

  • Committer: Brian Aker
  • Date: 2008-07-14 03:04:13 UTC
  • mfrom: (77.1.90 codestyle)
  • Revision ID: brian@tangent.org-20080714030413-dpv6opb0eoy1rd3f
Merging Monty's code, I did remove error on compile though (since it does
not currently work because of sql_plugin.cc)

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
23
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
 
64
64
  fastmutex_global_init();              /* Must be called early */
65
65
#endif
66
66
#if defined(HAVE_PTHREAD_INIT)
67
 
  pthread_init();
 
67
  pthread_init();                       /* Must be called before DBUG_ENTER */
68
68
#endif
69
69
  if (my_thread_global_init())
70
70
    return 1;
71
71
  sigfillset(&my_signals);              /* signals blocked by mf_brkhant */
72
72
  {
 
73
    DBUG_ENTER("my_init");
 
74
    DBUG_PROCESS((char*) (my_progname ? my_progname : "unknown"));
73
75
    if (!home_dir)
74
76
    {                                   /* Don't initialize twice */
75
77
      if ((home_dir=getenv("HOME")) != 0)
80
82
        /* Default creation of new dir's */
81
83
      if ((str=getenv("UMASK_DIR")) != 0)
82
84
        my_umask_dir=(int) (atoi_octal(str) | 0700);
 
85
      DBUG_PRINT("exit",("home: '%s'",home_dir));
83
86
    }
84
 
    return(0);
 
87
    DBUG_RETURN(0);
85
88
  }
86
89
} /* my_init */
87
90
 
95
98
    Sun CC: Sun C++ 5.6 2004/06/02 for x86, and should not be
96
99
    optimized until this compiler is not in use anymore
97
100
  */
98
 
  FILE *info_file= stderr;
99
 
  bool print_info= 0;
 
101
  FILE *info_file= DBUG_FILE;
 
102
  bool print_info= (info_file != stderr);
 
103
  /*
 
104
    We do not use DBUG_ENTER here, as after cleanup DBUG is no longer
 
105
    operational, so we cannot use DBUG_RETURN.
 
106
  */
 
107
  DBUG_PRINT("info",("Shutting down: infoflag: %d  print_info: %d",
 
108
                     infoflag, print_info));
 
109
  if (!info_file)
 
110
  {
 
111
    info_file= stderr;
 
112
    print_info= 0;
 
113
  }
100
114
 
101
115
  if ((infoflag & MY_CHECK_ERROR) || print_info)
102
116
 
105
119
    {
106
120
      sprintf(errbuff[0],EE(EE_OPEN_WARNING),my_file_opened,my_stream_opened);
107
121
      (void) my_message_no_curses(EE_OPEN_WARNING,errbuff[0],ME_BELL);
 
122
      DBUG_PRINT("error",("%s",errbuff[0]));
108
123
      my_print_open_files();
109
124
    }
110
125
  }
118
133
    struct rusage rus;
119
134
#ifdef HAVE_purify
120
135
    /* Purify assumes that rus is uninitialized after getrusage call */
121
 
    memset(&rus, 0, sizeof(rus));
 
136
    bzero((char*) &rus, sizeof(rus));
122
137
#endif
123
138
    if (!getrusage(RUSAGE_SELF, &rus))
124
139
      fprintf(info_file,"\n\
143
158
    TERMINATE(stderr, 0);               /* Print memory leaks on screen */
144
159
  }
145
160
 
 
161
  if (!(infoflag & MY_DONT_FREE_DBUG))
 
162
  {
 
163
    DBUG_END();                /* Must be done before my_thread_end */
 
164
  }
146
165
  my_thread_end();
147
166
  my_thread_global_end();
148
167
#if defined(SAFE_MUTEX)