~eday/drizzle/eday-dev

« back to all changes in this revision

Viewing changes to plugin/myisam/my_pread.cc

  • Committer: Eric Day
  • Date: 2010-01-07 20:02:38 UTC
  • mfrom: (971.3.291 staging)
  • Revision ID: eday@oddments.org-20100107200238-uqw8v6kv9pl7nny5
Merged trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
#include "myisam_priv.h"
17
 
#include <mysys/mysys_err.h>
 
17
#include "drizzled/my_error.h"
18
18
#include <errno.h>
19
19
#include <unistd.h>
20
20
 
39
39
    #             Number of bytes read
40
40
*/
41
41
 
42
 
size_t my_pread(File Filedes, unsigned char *Buffer, size_t Count, my_off_t offset,
 
42
size_t my_pread(int Filedes, unsigned char *Buffer, size_t Count, my_off_t offset,
43
43
                myf MyFlags)
44
44
{
45
45
  size_t readbytes;
48
48
  {
49
49
    errno=0;                                    /* Linux doesn't reset this */
50
50
    if ((error= ((readbytes= pread(Filedes, Buffer, Count, offset)) != Count)))
51
 
      my_errno= errno ? errno : -1;
 
51
      errno= errno ? errno : -1;
52
52
    if (error || readbytes != Count)
53
53
    {
54
54
      if ((readbytes == 0 || readbytes == (size_t) -1) && errno == EINTR)
58
58
      if (MyFlags & (MY_WME | MY_FAE | MY_FNABP))
59
59
      {
60
60
        if (readbytes == (size_t) -1)
61
 
          my_error(EE_READ, MYF(ME_BELL+ME_WAITTANG), "unknown", my_errno);
 
61
          my_error(EE_READ, MYF(ME_BELL+ME_WAITTANG), "unknown", errno);
62
62
        else if (MyFlags & (MY_NABP | MY_FNABP))
63
 
          my_error(EE_EOFERR, MYF(ME_BELL+ME_WAITTANG), "unknown", my_errno);
 
63
          my_error(EE_EOFERR, MYF(ME_BELL+ME_WAITTANG), "unknown", errno);
64
64
      }
65
65
      if (readbytes == (size_t) -1 || (MyFlags & (MY_FNABP | MY_NABP)))
66
66
        return(MY_FILE_ERROR);          /* Return with error */
105
105
  {
106
106
    if ((writenbytes= pwrite(Filedes, Buffer, Count,offset)) == Count)
107
107
      break;
108
 
    my_errno= errno;
 
108
    errno= errno;
109
109
    if (writenbytes != (size_t) -1)
110
110
    {                                   /* Safegueard */
111
111
      written+=writenbytes;
116
116
#ifndef NO_BACKGROUND
117
117
    if (my_thread_var->abort)
118
118
      MyFlags&= ~ MY_WAIT_IF_FULL;              /* End if aborted by user */
119
 
    if ((my_errno == ENOSPC || my_errno == EDQUOT) &&
 
119
    if ((errno == ENOSPC || errno == EDQUOT) &&
120
120
        (MyFlags & MY_WAIT_IF_FULL))
121
121
    {
122
122
      if (!(errors++ % MY_WAIT_GIVE_USER_A_MESSAGE))
123
123
        my_error(EE_DISK_FULL,MYF(ME_BELL | ME_NOREFRESH),
124
 
                 "unknown", my_errno, MY_WAIT_FOR_USER_TO_FIX_PANIC);
 
124
                 "unknown", errno, MY_WAIT_FOR_USER_TO_FIX_PANIC);
125
125
      sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC);
126
126
      continue;
127
127
    }
128
 
    if ((writenbytes && writenbytes != (size_t) -1) || my_errno == EINTR)
 
128
    if ((writenbytes && writenbytes != (size_t) -1) || errno == EINTR)
129
129
      continue;                                 /* Retry */
130
130
#endif
131
131
    if (MyFlags & (MY_NABP | MY_FNABP))
132
132
    {
133
133
      if (MyFlags & (MY_WME | MY_FAE | MY_FNABP))
134
134
      {
135
 
        my_error(EE_WRITE, MYF(ME_BELL | ME_WAITTANG), "unknown", my_errno);
 
135
        my_error(EE_WRITE, MYF(ME_BELL | ME_WAITTANG), "unknown", errno);
136
136
      }
137
137
      return(MY_FILE_ERROR);            /* Error on read */
138
138
    }