~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_file.c

  • Committer: Jay Pipes
  • Date: 2008-07-17 21:18:07 UTC
  • mto: This revision was merged to the branch mainline in revision 182.
  • Revision ID: jay@mysql.com-20080717211807-k9cwb1m2wi7ys9fq
Phase 6 - Remove DBUG from mysys

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
{
43
43
  struct rlimit rlimit;
44
44
  uint old_cur;
45
 
  DBUG_ENTER("set_max_open_files");
46
 
  DBUG_PRINT("enter",("files: %u", max_file_limit));
47
45
 
48
46
  if (!getrlimit(RLIMIT_NOFILE,&rlimit))
49
47
  {
50
48
    old_cur= (uint) rlimit.rlim_cur;
51
 
    DBUG_PRINT("info", ("rlim_cur: %u  rlim_max: %u",
52
 
                        (uint) rlimit.rlim_cur,
53
 
                        (uint) rlimit.rlim_max));
54
49
    if (rlimit.rlim_cur == RLIM_INFINITY)
55
50
      rlimit.rlim_cur = max_file_limit;
56
51
    if (rlimit.rlim_cur >= max_file_limit)
57
 
      DBUG_RETURN(rlimit.rlim_cur);             /* purecov: inspected */
 
52
      return(rlimit.rlim_cur);          /* purecov: inspected */
58
53
    rlimit.rlim_cur= rlimit.rlim_max= max_file_limit;
59
54
    if (setrlimit(RLIMIT_NOFILE, &rlimit))
60
55
      max_file_limit= old_cur;                  /* Use original value */
62
57
    {
63
58
      rlimit.rlim_cur= 0;                       /* Safety if next call fails */
64
59
      (void) getrlimit(RLIMIT_NOFILE,&rlimit);
65
 
      DBUG_PRINT("info", ("rlim_cur: %u", (uint) rlimit.rlim_cur));
66
60
      if (rlimit.rlim_cur)                      /* If call didn't fail */
67
61
        max_file_limit= (uint) rlimit.rlim_cur;
68
62
    }
69
63
  }
70
 
  DBUG_PRINT("exit",("max_file_limit: %u", max_file_limit));
71
 
  DBUG_RETURN(max_file_limit);
 
64
  return(max_file_limit);
72
65
}
73
66
 
74
67
#else
94
87
uint my_set_max_open_files(uint files)
95
88
{
96
89
  struct st_my_file_info *tmp;
97
 
  DBUG_ENTER("my_set_max_open_files");
98
 
  DBUG_PRINT("enter",("files: %u  my_file_limit: %u", files, my_file_limit));
99
90
 
100
91
  files= set_max_open_files(min(files, OS_FILE_LIMIT));
101
92
  if (files <= MY_NFILE)
102
 
    DBUG_RETURN(files);
 
93
    return(files);
103
94
 
104
95
  if (!(tmp= (struct st_my_file_info*) my_malloc(sizeof(*tmp) * files,
105
96
                                                 MYF(MY_WME))))
106
 
    DBUG_RETURN(MY_NFILE);
 
97
    return(MY_NFILE);
107
98
 
108
99
  /* Copy any initialized files */
109
100
  memcpy((char*) tmp, (char*) my_file_info,
113
104
  my_free_open_file_info();                     /* Free if already allocated */
114
105
  my_file_info= tmp;
115
106
  my_file_limit= files;
116
 
  DBUG_PRINT("exit",("files: %u", files));
117
 
  DBUG_RETURN(files);
 
107
  return(files);
118
108
}
119
109
 
120
110
 
121
111
void my_free_open_file_info()
122
112
{
123
 
  DBUG_ENTER("my_free_file_info");
124
113
  if (my_file_info != my_file_info_default)
125
114
  {
126
115
    /* Copy data back for my_print_open_files */
130
119
    my_file_info= my_file_info_default;
131
120
    my_file_limit= MY_NFILE;
132
121
  }
133
 
  DBUG_VOID_RETURN;
 
122
  return;
134
123
}