~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/my_lock.c

  • Committer: Monty Taylor
  • Date: 2008-07-05 17:07:46 UTC
  • mto: This revision was merged to the branch mainline in revision 63.
  • Revision ID: monty@inaugust.com-20080705170746-8aq11u9fuwtfwy85
Removed my_alarm. Made my_lock only do the non-alarm version. Moved my_lock to MyISAM where it belongs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#endif
24
24
#include <my_alarm.h>
25
25
 
26
 
/* 
27
 
  Lock a part of a file 
 
26
 
 
27
/*
 
28
  Lock a part of a file
28
29
 
29
30
  RETURN VALUE
30
31
    0   Success
33
34
*/
34
35
 
35
36
int my_lock(File fd, int locktype, my_off_t start, my_off_t length,
36
 
            myf MyFlags)
 
37
            myf MyFlags)
37
38
{
38
 
#ifdef HAVE_FCNTL
39
39
  int value;
40
 
  ALARM_VARIABLES;
41
 
#endif
 
40
  long alarm_pos=0,alarm_end_pos=MY_HOW_OFTEN_TO_WRITE-1;
 
41
 
42
42
  DBUG_ENTER("my_lock");
43
43
  DBUG_PRINT("my",("Fd: %d  Op: %d  start: %ld  Length: %ld  MyFlags: %d",
44
44
                   fd,locktype,(long) start,(long) length,MyFlags));
59
59
      if (fcntl(fd,F_SETLK,&lock) != -1)        /* Check if we can lock */
60
60
        DBUG_RETURN(0);                 /* Ok, file locked */
61
61
      DBUG_PRINT("info",("Was locked, trying with alarm"));
62
 
      ALARM_INIT;
63
 
      while ((value=fcntl(fd,F_SETLKW,&lock)) && ! ALARM_TEST &&
 
62
      while ((value=fcntl(fd,F_SETLKW,&lock)) && !  (alarm_pos++ >= alarm_end_pos) &&
64
63
             errno == EINTR)
65
64
      {                 /* Setup again so we don`t miss it */
66
 
        ALARM_REINIT;
 
65
        alarm_end_pos+=MY_HOW_OFTEN_TO_WRITE;
67
66
      }
68
 
      ALARM_END;
69
67
      if (value != -1)
70
68
        DBUG_RETURN(0);
71
69
      if (errno == EINTR)