~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_write.c

  • Committer: Monty Taylor
  • Date: 2008-07-09 16:42:25 UTC
  • mto: (77.6.1 glibclient-merge)
  • mto: This revision was merged to the branch mainline in revision 112.
  • Revision ID: monty@inaugust.com-20080709164225-2r6n4j98nhxh031l
Moved test to tests... 

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
        /* Write a chunk of bytes to a file */
22
22
 
23
 
size_t my_write(int Filedes, const unsigned char *Buffer, size_t Count, myf MyFlags)
 
23
size_t my_write(int Filedes, const uchar *Buffer, size_t Count, myf MyFlags)
24
24
{
25
25
  size_t writenbytes, written;
26
 
  uint32_t errors;
 
26
  uint errors;
 
27
  DBUG_ENTER("my_write");
 
28
  DBUG_PRINT("my",("Fd: %d  Buffer: 0x%lx  Count: %lu  MyFlags: %d",
 
29
                   Filedes, (long) Buffer, (ulong) Count, MyFlags));
27
30
  errors=0; written=0;
28
31
 
29
32
  /* The behavior of write(fd, buf, 0) is not portable */
30
33
  if (unlikely(!Count))
31
 
    return(0);
 
34
    DBUG_RETURN(0);
32
35
  
33
36
  for (;;)
34
37
  {
41
44
      Count-=writenbytes;
42
45
    }
43
46
    my_errno=errno;
 
47
    DBUG_PRINT("error",("Write only %ld bytes, error: %d",
 
48
                        (long) writenbytes, my_errno));
44
49
#ifndef NO_BACKGROUND
45
50
    if (my_thread_var->abort)
46
51
      MyFlags&= ~ MY_WAIT_IF_FULL;              /* End if aborted by user */
50
55
      if (!(errors++ % MY_WAIT_GIVE_USER_A_MESSAGE))
51
56
        my_error(EE_DISK_FULL,MYF(ME_BELL | ME_NOREFRESH),
52
57
                 my_filename(Filedes),my_errno,MY_WAIT_FOR_USER_TO_FIX_PANIC);
53
 
      sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC);
 
58
      VOID(sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC));
54
59
      continue;
55
60
    }
56
61
 
58
63
    {
59
64
      if (my_errno == EINTR)
60
65
      {
 
66
        DBUG_PRINT("debug", ("my_write() was interrupted and returned %ld",
 
67
                             (long) writenbytes));
61
68
        continue;                               /* Interrupted */
62
69
      }
63
70
 
78
85
        my_error(EE_WRITE, MYF(ME_BELL+ME_WAITTANG),
79
86
                 my_filename(Filedes),my_errno);
80
87
      }
81
 
      return(MY_FILE_ERROR);            /* Error on read */
 
88
      DBUG_RETURN(MY_FILE_ERROR);               /* Error on read */
82
89
    }
83
90
    else
84
91
      break;                                    /* Return bytes written */
85
92
  }
86
93
  if (MyFlags & (MY_NABP | MY_FNABP))
87
 
    return(0);                  /* Want only errors */
88
 
  return(writenbytes+written);
 
94
    DBUG_RETURN(0);                     /* Want only errors */
 
95
  DBUG_RETURN(writenbytes+written);
89
96
} /* my_write */