~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_read.c

  • Committer: Jay Pipes
  • Date: 2008-07-17 18:48:58 UTC
  • mto: This revision was merged to the branch mainline in revision 182.
  • Revision ID: jay@mysql.com-20080717184858-2mbouxl8xi41gcge
Removed DBUG from CSV and Blackhole storage engines

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
 
 
16
 
#include <config.h>
17
 
 
18
 
#include <drizzled/internal/my_sys.h>
19
 
#include <drizzled/error.h>
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
#include "mysys_priv.h"
 
17
#include "mysys_err.h"
20
18
#include <errno.h>
21
19
 
22
 
namespace drizzled
23
 
{
24
 
namespace internal
25
 
{
26
 
 
27
20
 
28
21
/*
29
22
  Read a chunk of bytes from a file with retry's if needed
40
33
      N  number of bytes read.
41
34
*/
42
35
 
43
 
size_t my_read(int Filedes, unsigned char *Buffer, size_t Count, myf MyFlags)
 
36
size_t my_read(File Filedes, uchar *Buffer, size_t Count, myf MyFlags)
44
37
{
45
38
  size_t readbytes, save_count;
 
39
  DBUG_ENTER("my_read");
 
40
  DBUG_PRINT("my",("Fd: %d  Buffer: 0x%lx  Count: %lu  MyFlags: %d",
 
41
                   Filedes, (long) Buffer, (ulong) Count, MyFlags));
46
42
  save_count= Count;
47
43
 
48
44
  for (;;)
50
46
    errno= 0;                                   /* Linux doesn't reset this */
51
47
    if ((readbytes= read(Filedes, Buffer, Count)) != Count)
52
48
    {
53
 
      errno= errno ? errno : -1;
 
49
      my_errno= errno ? errno : -1;
 
50
      DBUG_PRINT("warning",("Read only %d bytes off %lu from %d, errno: %d",
 
51
                            (int) readbytes, (ulong) Count, Filedes,
 
52
                            my_errno));
54
53
      if ((readbytes == 0 || (int) readbytes == -1) && errno == EINTR)
55
 
      {
 
54
      {  
 
55
        DBUG_PRINT("debug", ("my_read() was interrupted and returned %ld",
 
56
                             (long) readbytes));
56
57
        continue;                              /* Interrupted */
57
58
      }
58
59
      if (MyFlags & (MY_WME | MY_FAE | MY_FNABP))
59
60
      {
60
61
        if (readbytes == (size_t) -1)
61
62
          my_error(EE_READ, MYF(ME_BELL+ME_WAITTANG),
62
 
                   "unknown", errno);
 
63
                   my_filename(Filedes),my_errno);
63
64
        else if (MyFlags & (MY_NABP | MY_FNABP))
64
65
          my_error(EE_EOFERR, MYF(ME_BELL+ME_WAITTANG),
65
 
                   "unknown", errno);
 
66
                   my_filename(Filedes),my_errno);
66
67
      }
67
68
      if (readbytes == (size_t) -1 ||
68
69
          ((MyFlags & (MY_FNABP | MY_NABP)) && !(MyFlags & MY_FULL_IO)))
69
 
        return(MY_FILE_ERROR);  /* Return with error */
 
70
        DBUG_RETURN(MY_FILE_ERROR);     /* Return with error */
70
71
      if (readbytes != (size_t) -1 && (MyFlags & MY_FULL_IO))
71
72
      {
72
73
        Buffer+= readbytes;
81
82
      readbytes= save_count;
82
83
    break;
83
84
  }
84
 
  return(readbytes);
 
85
  DBUG_RETURN(readbytes);
85
86
} /* my_read */
86
 
 
87
 
} /* namespace internal */
88
 
} /* namespace drizzled */