~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_file.cc

  • Committer: Mark Atwood
  • Date: 2009-01-05 04:37:22 UTC
  • mto: (758.1.1 devel)
  • mto: This revision was merged to the branch mainline in revision 759.
  • Revision ID: me@mark.atwood.name-20090105043722-03l4mzcxi4yjjjih
replace sql_print_error etc with errmsg_print

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
#include "mysys_priv.h"
17
17
#include "my_static.h"
18
18
#include <mystrings/m_string.h>
 
19
#include <stdlib.h>
 
20
#include <string.h>
19
21
 
20
22
/*
21
23
  set how many open files we want to be able to handle
41
43
static uint32_t set_max_open_files(uint32_t max_file_limit)
42
44
{
43
45
  struct rlimit rlimit;
44
 
  uint32_t old_cur;
 
46
  rlim_t old_cur;
45
47
 
46
48
  if (!getrlimit(RLIMIT_NOFILE,&rlimit))
47
49
  {
48
 
    old_cur= (uint) rlimit.rlim_cur;
 
50
    old_cur= rlimit.rlim_cur;
49
51
    if (rlimit.rlim_cur == RLIM_INFINITY)
50
52
      rlimit.rlim_cur = max_file_limit;
51
53
    if (rlimit.rlim_cur >= max_file_limit)
52
 
      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
    }
53
60
    rlimit.rlim_cur= rlimit.rlim_max= max_file_limit;
54
61
    if (setrlimit(RLIMIT_NOFILE, &rlimit))
55
 
      max_file_limit= old_cur;                  /* Use original value */
 
62
      max_file_limit= (old_cur < UINT32_MAX) ? (uint32_t)old_cur : UINT32_MAX;
56
63
    else
57
64
    {
58
65
      rlimit.rlim_cur= 0;                       /* Safety if next call fails */
59
66
      (void) getrlimit(RLIMIT_NOFILE,&rlimit);
60
67
      if (rlimit.rlim_cur)                      /* If call didn't fail */
61
 
        max_file_limit= (uint) rlimit.rlim_cur;
 
68
        max_file_limit= (uint32_t) rlimit.rlim_cur;
62
69
    }
63
70
  }
64
71
  return(max_file_limit);
92
99
  if (files <= MY_NFILE)
93
100
    return(files);
94
101
 
95
 
  if (!(tmp= (struct st_my_file_info*) my_malloc(sizeof(*tmp) * files,
96
 
                                                 MYF(MY_WME))))
 
102
  if (!(tmp= (st_my_file_info*) malloc(sizeof(st_my_file_info) * files)))
97
103
    return(MY_NFILE);
98
104
 
99
105
  /* Copy any initialized files */