~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_file.cc

  • Committer: Monty Taylor
  • Date: 2008-12-01 17:53:42 UTC
  • mto: This revision was merged to the branch mainline in revision 637.
  • Revision ID: monty@bitters-20081201175342-hcvfaecqmljhv86g
Fixed Sun Studio warnings in mysys.

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
      if (rlimit.rlim_cur > UINT32_MAX)
 
55
        return UINT32_MAX;
 
56
      else
 
57
        return((uint32_t)rlimit.rlim_cur);
55
58
    rlimit.rlim_cur= rlimit.rlim_max= max_file_limit;
56
59
    if (setrlimit(RLIMIT_NOFILE, &rlimit))
57
 
      max_file_limit= old_cur;                  /* Use original value */
 
60
      max_file_limit= (old_cur < UINT32_MAX) ? (uint32_t)old_cur : UINT32_MAX;
58
61
    else
59
62
    {
60
63
      rlimit.rlim_cur= 0;                       /* Safety if next call fails */
61
64
      (void) getrlimit(RLIMIT_NOFILE,&rlimit);
62
65
      if (rlimit.rlim_cur)                      /* If call didn't fail */
63
 
        max_file_limit= (uint) rlimit.rlim_cur;
 
66
        max_file_limit= (uint32_t) rlimit.rlim_cur;
64
67
    }
65
68
  }
66
69
  return(max_file_limit);
94
97
  if (files <= MY_NFILE)
95
98
    return(files);
96
99
 
97
 
  if (!(tmp= (struct st_my_file_info*) my_malloc(sizeof(*tmp) * files,
98
 
                                                 MYF(MY_WME))))
 
100
  if (!(tmp= (st_my_file_info*) malloc(sizeof(st_my_file_info) * files)))
99
101
    return(MY_NFILE);
100
102
 
101
103
  /* Copy any initialized files */