~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_file.cc

  • Committer: Brian Aker
  • Date: 2008-12-02 16:33:43 UTC
  • mfrom: (632.1.19 devel)
  • Revision ID: brian@tangent.org-20081202163343-007ifg17p0lvjga7
Merge from Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
static uint32_t set_max_open_files(uint32_t max_file_limit)
44
44
{
45
45
  struct rlimit rlimit;
46
 
  uint32_t old_cur;
 
46
  rlim_t old_cur;
47
47
 
48
48
  if (!getrlimit(RLIMIT_NOFILE,&rlimit))
49
49
  {
50
 
    old_cur= (uint) rlimit.rlim_cur;
 
50
    old_cur= rlimit.rlim_cur;
51
51
    if (rlimit.rlim_cur == RLIM_INFINITY)
52
52
      rlimit.rlim_cur = max_file_limit;
53
53
    if (rlimit.rlim_cur >= max_file_limit)
54
 
      return(rlimit.rlim_cur);          /* purecov: inspected */
 
54
    {
 
55
      if (rlimit.rlim_cur > UINT32_MAX)
 
56
        return UINT32_MAX;
 
57
      else
 
58
        return((uint32_t)rlimit.rlim_cur);
 
59
    }
55
60
    rlimit.rlim_cur= rlimit.rlim_max= max_file_limit;
56
61
    if (setrlimit(RLIMIT_NOFILE, &rlimit))
57
 
      max_file_limit= old_cur;                  /* Use original value */
 
62
      max_file_limit= (old_cur < UINT32_MAX) ? (uint32_t)old_cur : UINT32_MAX;
58
63
    else
59
64
    {
60
65
      rlimit.rlim_cur= 0;                       /* Safety if next call fails */
61
66
      (void) getrlimit(RLIMIT_NOFILE,&rlimit);
62
67
      if (rlimit.rlim_cur)                      /* If call didn't fail */
63
 
        max_file_limit= (uint) rlimit.rlim_cur;
 
68
        max_file_limit= (uint32_t) rlimit.rlim_cur;
64
69
    }
65
70
  }
66
71
  return(max_file_limit);
94
99
  if (files <= MY_NFILE)
95
100
    return(files);
96
101
 
97
 
  if (!(tmp= (struct st_my_file_info*) my_malloc(sizeof(*tmp) * files,
98
 
                                                 MYF(MY_WME))))
 
102
  if (!(tmp= (st_my_file_info*) malloc(sizeof(st_my_file_info) * files)))
99
103
    return(MY_NFILE);
100
104
 
101
105
  /* Copy any initialized files */