~ubuntu-branches/ubuntu/hardy/mysql-dfsg-5.0/hardy-updates

« back to all changes in this revision

Viewing changes to mysys/my_wincond.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2007-04-02 16:10:53 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20070402161053-zkil9hjq9k5p1uzv
Tags: 5.0.37-0ubuntu1
* New upstream bugfix release.
  - Fixes replication failure with auto-increment and on duplicate key
    update, a regression introduced into 5.0.24. (LP: #95821)
* debian/control: Set Ubuntu maintainer.
* debian/rules: Change comments from 'Debian etch' to 'Ubuntu 7.04'.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
   This program is free software; you can redistribute it and/or modify
4
4
   it under the terms of the GNU General Public License as published by
5
 
   the Free Software Foundation; either version 2 of the License, or
6
 
   (at your option) any later version.
 
5
   the Free Software Foundation; version 2 of the License.
7
6
 
8
7
   This program is distributed in the hope that it will be useful,
9
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
37
36
 
38
37
int pthread_cond_destroy(pthread_cond_t *cond)
39
38
{
40
 
        return CloseHandle(cond->semaphore) ? 0 : EINVAL;
 
39
  return CloseHandle(cond->semaphore) ? 0 : EINVAL;
41
40
}
42
41
 
43
42
 
51
50
  return 0 ;
52
51
}
53
52
 
 
53
 
54
54
int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
55
55
                           struct timespec *abstime)
56
56
{
57
 
  struct _timeb curtime;
58
57
  int result;
59
 
  long timeout;
60
 
  _ftime(&curtime);
61
 
  timeout= ((long) (abstime->tv_sec - curtime.time)*1000L +
62
 
                    (long)((abstime->tv_nsec/1000) - curtime.millitm)/1000L);
63
 
  if (timeout < 0)                              /* Some safety */
64
 
    timeout = 0L;
 
58
  long timeout; 
 
59
  union ft64 now;
 
60
  
 
61
  GetSystemTimeAsFileTime(&now.ft);
 
62
 
 
63
  /*
 
64
    Calculate time left to abstime
 
65
    - subtract start time from current time(values are in 100ns units)
 
66
    - convert to millisec by dividing with 10000
 
67
  */
 
68
  timeout= (long)((abstime->tv.i64 - now.i64) / 10000);
 
69
  
 
70
  /* Don't allow the timeout to be negative */
 
71
  if (timeout < 0)
 
72
    timeout= 0L;
 
73
 
 
74
  /*
 
75
    Make sure the calucated timeout does not exceed original timeout
 
76
    value which could cause "wait for ever" if system time changes
 
77
  */
 
78
  if (timeout > abstime->max_timeout_msec)
 
79
    timeout= abstime->max_timeout_msec;
 
80
 
65
81
  InterlockedIncrement(&cond->waiting);
66
82
  LeaveCriticalSection(mutex);
67
 
  result=WaitForSingleObject(cond->semaphore,timeout);
 
83
  result= WaitForSingleObject(cond->semaphore,timeout);
68
84
  InterlockedDecrement(&cond->waiting);
69
85
  EnterCriticalSection(mutex);
70
86