~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/my_pread.c

  • Committer: Brian Aker
  • Date: 2008-07-01 22:45:34 UTC
  • Revision ID: brian@tangent.org-20080701224534-ro5rfc190vgqs0z8
Moved pread over to just supporting myisam (someone can refactor from here
if they want).

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_priv.h"
 
16
#include "myisamdef.h"
17
17
#include "mysys_err.h"
18
18
#include <errno.h>
19
 
#ifdef HAVE_PREAD
20
19
#include <unistd.h>
21
 
#endif
22
20
 
23
21
/*
24
22
  Read a chunk of bytes from a file from a given position
53
51
  for (;;)
54
52
  {
55
53
    errno=0;                                    /* Linux doesn't reset this */
56
 
#ifndef HAVE_PREAD
57
 
    pthread_mutex_lock(&my_file_info[Filedes].mutex);
58
 
    readbytes= (uint) -1;
59
 
    error= (lseek(Filedes, offset, MY_SEEK_SET) == (my_off_t) -1 ||
60
 
            (readbytes= read(Filedes, Buffer, Count)) != Count);
61
 
    pthread_mutex_unlock(&my_file_info[Filedes].mutex);
62
 
#else
63
54
    if ((error= ((readbytes= pread(Filedes, Buffer, Count, offset)) != Count)))
64
55
      my_errno= errno ? errno : -1;
65
 
#endif
66
56
    if (error || readbytes != Count)
67
57
    {
68
58
      DBUG_PRINT("warning",("Read only %d bytes off %u from %d, errno: %d",
129
119
 
130
120
  for (;;)
131
121
  {
132
 
#ifndef HAVE_PREAD
133
 
    int error;
134
 
    writenbytes= (size_t) -1;
135
 
    pthread_mutex_lock(&my_file_info[Filedes].mutex);
136
 
    error= (lseek(Filedes, offset, MY_SEEK_SET) != (my_off_t) -1 &&
137
 
            (writenbytes = write(Filedes, Buffer, Count)) == Count);
138
 
    pthread_mutex_unlock(&my_file_info[Filedes].mutex);
139
 
    if (error)
140
 
      break;
141
 
#else
142
122
    if ((writenbytes= pwrite(Filedes, Buffer, Count,offset)) == Count)
143
123
      break;
144
124
    my_errno= errno;
145
 
#endif
146
125
    if (writenbytes != (size_t) -1)
147
126
    {                                   /* Safegueard */
148
127
      written+=writenbytes;