~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_open.c

Fixed the test programs linking issue. (I hope)
Made the plugin def use libmyisam.la instead of libmyisam.a so that we 
can take advantage of libtool convenience libs. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
                                /* Special flags */
38
38
{
39
39
  File fd;
 
40
  DBUG_ENTER("my_open");
 
41
  DBUG_PRINT("my",("Name: '%s'  Flags: %d  MyFlags: %d",
 
42
                   FileName, Flags, MyFlags));
40
43
 
41
44
#if !defined(NO_OPEN_3)
42
45
  fd = open(FileName, Flags, my_umask); /* Normal unix */
44
47
  fd = open((char *) FileName, Flags);
45
48
#endif
46
49
 
47
 
  return(my_register_filename(fd, FileName, FILE_BY_OPEN,
 
50
  DBUG_RETURN(my_register_filename(fd, FileName, FILE_BY_OPEN,
48
51
                                   EE_FILENOTFOUND, MyFlags));
49
52
} /* my_open */
50
53
 
62
65
int my_close(File fd, myf MyFlags)
63
66
{
64
67
  int err;
 
68
  DBUG_ENTER("my_close");
 
69
  DBUG_PRINT("my",("fd: %d  MyFlags: %d",fd, MyFlags));
65
70
 
66
71
  pthread_mutex_lock(&THR_LOCK_open);
67
72
  do
71
76
 
72
77
  if (err)
73
78
  {
 
79
    DBUG_PRINT("error",("Got error %d on close",err));
74
80
    my_errno=errno;
75
81
    if (MyFlags & (MY_FAE | MY_WME))
76
82
      my_error(EE_BADCLOSE, MYF(ME_BELL+ME_WAITTANG),my_filename(fd),errno);
85
91
  }
86
92
  my_file_opened--;
87
93
  pthread_mutex_unlock(&THR_LOCK_open);
88
 
  return(err);
 
94
  DBUG_RETURN(err);
89
95
} /* my_close */
90
96
 
91
97
 
109
115
File my_register_filename(File fd, const char *FileName, enum file_type
110
116
                          type_of_file, uint error_message_number, myf MyFlags)
111
117
{
 
118
  DBUG_ENTER("my_register_filename");
112
119
  if ((int) fd >= 0)
113
120
  {
114
121
    if ((uint) fd >= my_file_limit)
117
124
      my_errno= EMFILE;
118
125
#else
119
126
      thread_safe_increment(my_file_opened,&THR_LOCK_open);
120
 
      return(fd);                               /* safeguard */
 
127
      DBUG_RETURN(fd);                          /* safeguard */
121
128
#endif
122
129
    }
123
130
    else
132
139
        pthread_mutex_init(&my_file_info[fd].mutex,MY_MUTEX_INIT_FAST);
133
140
#endif
134
141
        pthread_mutex_unlock(&THR_LOCK_open);
135
 
        return(fd);
 
142
        DBUG_PRINT("exit",("fd: %d",fd));
 
143
        DBUG_RETURN(fd);
136
144
      }
137
145
      pthread_mutex_unlock(&THR_LOCK_open);
138
146
      my_errno= ENOMEM;
142
150
  else
143
151
    my_errno= errno;
144
152
 
 
153
  DBUG_PRINT("error",("Got error %d on open", my_errno));
145
154
  if (MyFlags & (MY_FFNF | MY_FAE | MY_WME))
146
155
  {
147
156
    if (my_errno == EMFILE)
148
157
      error_message_number= EE_OUT_OF_FILERESOURCES;
 
158
    DBUG_PRINT("error",("print err: %d",error_message_number));
149
159
    my_error(error_message_number, MYF(ME_BELL+ME_WAITTANG),
150
160
             FileName, my_errno);
151
161
  }
152
 
  return(-1);
 
162
  DBUG_RETURN(-1);
153
163
}
154
164
 
155
165