~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/internal/my_sync.cc

  • Committer: Brian Aker
  • Date: 2010-04-05 23:46:43 UTC
  • Revision ID: brian@gaz-20100405234643-0he3xnj902rc70r8
Fixing tests to work with PBXT.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
 
#include "mysys/mysys_priv.h"
17
 
#include "mysys/mysys_err.h"
 
16
#include "config.h"
 
17
#include "drizzled/internal/my_sys.h"
 
18
 
18
19
#include <errno.h>
 
20
#include <fcntl.h>
 
21
 
 
22
#include "drizzled/error.h"
 
23
 
 
24
namespace drizzled
 
25
{
 
26
namespace internal
 
27
{
19
28
 
20
29
/*
21
30
  Sync data in file to disk
40
49
    -1 error
41
50
*/
42
51
 
43
 
int my_sync(File fd, myf my_flags)
 
52
int my_sync(int fd, myf my_flags)
44
53
{
45
54
  int res;
46
55
 
57
66
#endif
58
67
#if defined(HAVE_FDATASYNC)
59
68
    res= fdatasync(fd);
60
 
#elif defined(HAVE_FSYNC)
 
69
#else
61
70
    res= fsync(fd);
62
 
#else
63
 
#error Cannot find a way to sync a file, durability in danger
64
 
    res= 0;                                     /* No sync (strange OS) */
65
71
#endif
66
72
  } while (res == -1 && errno == EINTR);
67
73
 
68
74
  if (res)
69
75
  {
70
76
    int er= errno;
71
 
    if (!(my_errno= er))
72
 
      my_errno= -1;                             /* Unknown error */
 
77
    if (!(errno= er))
 
78
      errno= -1;                             /* Unknown error */
73
79
    if ((my_flags & MY_IGNORE_BADFD) &&
74
80
        (er == EBADF || er == EINVAL || er == EROFS))
75
81
    {
76
82
      res= 0;
77
83
    }
78
84
    else if (my_flags & MY_WME)
79
 
      my_error(EE_SYNC, MYF(ME_BELL+ME_WAITTANG), "unknown", my_errno);
 
85
      my_error(EE_SYNC, MYF(ME_BELL+ME_WAITTANG), "unknown", errno);
80
86
  }
81
87
  return(res);
82
88
} /* my_sync */
97
103
#ifdef NEED_EXPLICIT_SYNC_DIR
98
104
int my_sync_dir(const char *dir_name, myf my_flags)
99
105
{
100
 
  File dir_fd;
 
106
  int dir_fd;
101
107
  int res= 0;
102
108
  const char *correct_dir_name;
103
109
  /* Sometimes the path does not contain an explicit directory */
151
157
}
152
158
#endif
153
159
 
 
160
} /* namespace internal */
 
161
} /* namespace drizzled */