~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_file.c

  • Committer: Jay Pipes
  • Date: 2008-07-21 17:52:33 UTC
  • mto: (201.2.1 drizzle)
  • mto: This revision was merged to the branch mainline in revision 204.
  • Revision ID: jay@mysql.com-20080721175233-mtyz298j8xl3v63y
cleanup of FAQ file

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 <mystrings/m_string.h>
 
18
#include <m_string.h>
19
19
 
20
20
/*
21
21
  set how many open files we want to be able to handle
38
38
#define RLIM_INFINITY ((uint) 0xffffffff)
39
39
#endif
40
40
 
41
 
static uint32_t set_max_open_files(uint32_t max_file_limit)
 
41
static uint set_max_open_files(uint max_file_limit)
42
42
{
43
43
  struct rlimit rlimit;
44
 
  uint32_t old_cur;
 
44
  uint old_cur;
45
45
 
46
46
  if (!getrlimit(RLIMIT_NOFILE,&rlimit))
47
47
  {
65
65
}
66
66
 
67
67
#else
68
 
static int set_max_open_files(uint32_t max_file_limit)
 
68
static int set_max_open_files(uint max_file_limit)
69
69
{
70
70
  /* We don't know the limit. Return best guess */
71
 
  return cmin(max_file_limit, OS_FILE_LIMIT);
 
71
  return min(max_file_limit, OS_FILE_LIMIT);
72
72
}
73
73
#endif
74
74
 
84
84
    number of files available for open
85
85
*/
86
86
 
87
 
uint32_t my_set_max_open_files(uint32_t files)
 
87
uint my_set_max_open_files(uint files)
88
88
{
89
89
  struct st_my_file_info *tmp;
90
90
 
91
 
  files= set_max_open_files(cmin(files, OS_FILE_LIMIT));
 
91
  files= set_max_open_files(min(files, OS_FILE_LIMIT));
92
92
  if (files <= MY_NFILE)
93
93
    return(files);
94
94
 
97
97
    return(MY_NFILE);
98
98
 
99
99
  /* Copy any initialized files */
100
 
  memcpy(tmp, my_file_info, sizeof(*tmp) * cmin(my_file_limit, files));
101
 
  /*
102
 
    The int cast is necessary since 'my_file_limits' might be greater
103
 
    than 'files'.
104
 
  */
105
 
  memset(tmp + my_file_limit, 0,
106
 
         cmax((int) (files - my_file_limit), 0)*sizeof(*tmp));
 
100
  memcpy((char*) tmp, (char*) my_file_info,
 
101
         sizeof(*tmp) * min(my_file_limit, files));
 
102
  bzero((char*) (tmp + my_file_limit),
 
103
        max((int) (files- my_file_limit), 0)*sizeof(*tmp));
107
104
  my_free_open_file_info();                     /* Free if already allocated */
108
105
  my_file_info= tmp;
109
106
  my_file_limit= files;
116
113
  if (my_file_info != my_file_info_default)
117
114
  {
118
115
    /* Copy data back for my_print_open_files */
119
 
    memcpy(my_file_info_default, my_file_info,
 
116
    memcpy((char*) my_file_info_default, my_file_info,
120
117
           sizeof(*my_file_info_default)* MY_NFILE);
121
 
    free((char*) my_file_info);
 
118
    my_free((char*) my_file_info, MYF(0));
122
119
    my_file_info= my_file_info_default;
123
120
    my_file_limit= MY_NFILE;
124
121
  }