#At file:///home/jonas/src/telco-6.3/
2627 jonas@stripped 2008-06-09 [merge]
merge
modified:
configure.in
storage/ndb/src/common/portlib/NdbCondition.c
storage/ndb/src/common/portlib/NdbTick.c
storage/ndb/src/common/util/ndb_init.cpp
storage/ndb/src/kernel/blocks/backup/Backup.cpp
storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
storage/ndb/tools/restore/restore_main.cpp
storage/ndb/tools/waiter.cpp
=== modified file 'configure.in'
--- a/configure.in 2008-05-30 09:14:37 +0000
+++ b/configure.in 2008-06-09 14:31:19 +0000
@@ -2066,6 +2066,7 @@ AC_CHECK_FUNCS(alarm bcmp bfill bmove bs
#
#
#
+AC_CHECK_LIB(rt, clock_gettime)
case "$target" in
*-*-aix4* | *-*-sco*)
# (grr) aix 4.3 has a stub for clock_gettime, (returning ENOSYS)
@@ -2076,6 +2077,7 @@ case "$target" in
*) AC_CHECK_FUNCS(clock_gettime)
;;
esac
+AC_CHECK_FUNCS(pthread_condattr_setclock)
#checking for Linux Scheduling and Locking Support
AC_MSG_CHECKING(for Linux scheduling and locking support)
=== modified file 'storage/ndb/src/common/portlib/NdbCondition.c'
--- a/storage/ndb/src/common/portlib/NdbCondition.c 2006-12-23 19:20:40 +0000
+++ b/storage/ndb/src/common/portlib/NdbCondition.c 2008-06-09 11:57:17 +0000
@@ -26,7 +26,51 @@ struct NdbCondition
pthread_cond_t cond;
};
+#ifdef HAVE_CLOCK_GETTIME
+static int clock_id = CLOCK_REALTIME;
+#endif
+
+void
+NdbCondition_Init()
+{
+#if defined HAVE_CLOCK_GETTIME && defined HAVE_PTHREAD_CONDATTR_SETCLOCK && \
+ defined CLOCK_MONOTONIC
+
+ int res, init = 0;
+ pthread_cond_t tmp;
+ pthread_condattr_t attr;
+ if ((res = pthread_condattr_init(&attr)) != 0)
+ goto nogo;
+
+ init = 1;
+
+ if ((res = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC)) != 0)
+ goto nogo;
+
+ if ((res = pthread_cond_init(&tmp, &attr)) != 0)
+ goto nogo;
+ pthread_condattr_destroy(&attr);
+ pthread_cond_destroy(&tmp);
+
+ clock_id = CLOCK_MONOTONIC;
+
+ return;
+
+nogo:
+ if (init)
+ {
+ pthread_condattr_destroy(&attr);
+ }
+
+ clock_id = CLOCK_REALTIME;
+ fprintf(stderr,
+ "Failed to use CLOCK_MONOTONIC for pthread_condition res: %u\n",
+ res);
+ fflush(stderr);
+ return;
+#endif
+}
struct NdbCondition*
NdbCondition_Create(void)
@@ -38,8 +82,24 @@ NdbCondition_Create(void)
if (tmpCond == NULL)
return NULL;
-
+
+#if defined HAVE_CLOCK_GETTIME && defined HAVE_PTHREAD_CONDATTR_SETCLOCK && \
+ defined CLOCK_MONOTONIC
+ if (clock_id == CLOCK_MONOTONIC)
+ {
+ pthread_condattr_t attr;
+ pthread_condattr_init(&attr);
+ pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
+ result = pthread_cond_init(&tmpCond->cond, &attr);
+ pthread_condattr_destroy(&attr);
+ }
+ else
+ {
+ result = pthread_cond_init(&tmpCond->cond, NULL);
+ }
+#else
result = pthread_cond_init(&tmpCond->cond, NULL);
+#endif
assert(result==0);
return tmpCond;
@@ -73,7 +133,7 @@ NdbCondition_WaitTimeout(struct NdbCondi
return 1;
#ifdef HAVE_CLOCK_GETTIME
- clock_gettime(CLOCK_REALTIME, &abstime);
+ clock_gettime(clock_id, &abstime);
#else
{
struct timeval tick_time;
=== modified file 'storage/ndb/src/common/portlib/NdbTick.c'
--- a/storage/ndb/src/common/portlib/NdbTick.c 2007-06-05 16:00:42 +0000
+++ b/storage/ndb/src/common/portlib/NdbTick.c 2008-06-09 11:57:17 +0000
@@ -23,12 +23,18 @@
#define MICROSEC_PER_MILLISEC 1000
#define MILLISEC_PER_NANOSEC 1000000
-
#ifdef HAVE_CLOCK_GETTIME
+
+#ifdef CLOCK_MONOTONIC
+#define CLOCK CLOCK_MONOTONIC
+#else
+#define CLOCK CLOCK_REALTIME
+#endif
+
NDB_TICKS NdbTick_CurrentMillisecond(void)
{
struct timespec tick_time;
- clock_gettime(CLOCK_REALTIME, &tick_time);
+ clock_gettime(CLOCK, &tick_time);
return
((NDB_TICKS)tick_time.tv_sec) * ((NDB_TICKS)MILLISEC_PER_SEC) +
@@ -38,7 +44,7 @@ NDB_TICKS NdbTick_CurrentMillisecond(voi
int
NdbTick_CurrentMicrosecond(NDB_TICKS * secs, Uint32 * micros){
struct timespec t;
- int res = clock_gettime(CLOCK_REALTIME, &t);
+ int res = clock_gettime(CLOCK, &t);
* secs = t.tv_sec;
* micros = t.tv_nsec / 1000;
return res;
=== modified file 'storage/ndb/src/common/util/ndb_init.cpp'
--- a/storage/ndb/src/common/util/ndb_init.cpp 2008-04-22 19:36:05 +0000
+++ b/storage/ndb/src/common/util/ndb_init.cpp 2008-06-09 11:57:17 +0000
@@ -26,6 +26,8 @@ extern void destroy_event_logger(class E
static int ndb_init_called = 0;
+extern "C" void NdbCondition_Init();
+
extern "C"
{
@@ -44,6 +46,8 @@ ndb_init_internal()
exit(1);
}
}
+
+ NdbCondition_Init();
}
int
=== modified file 'storage/ndb/src/kernel/blocks/backup/Backup.cpp'
--- a/storage/ndb/src/kernel/blocks/backup/Backup.cpp 2008-05-29 11:30:21 +0000
+++ b/storage/ndb/src/kernel/blocks/backup/Backup.cpp 2008-06-09 14:31:19 +0000
@@ -2392,9 +2392,8 @@ Backup::stopBackupReply(Signal* signal,
void
Backup::initReportStatus(Signal *signal, BackupRecordPtr ptr)
{
- struct timeval the_time;
- gettimeofday(&the_time, 0);
- ptr.p->m_next_report = the_time.tv_sec + m_backup_report_frequency;
+ Uint64 now = NdbTick_CurrentMillisecond() / 1000;
+ ptr.p->m_next_report = now + m_backup_report_frequency;
}
void
@@ -2403,12 +2402,11 @@ Backup::checkReportStatus(Signal *signal
if (m_backup_report_frequency == 0)
return;
- struct timeval the_time;
- gettimeofday(&the_time, 0);
- if (the_time.tv_sec > ptr.p->m_next_report)
+ Uint64 now = NdbTick_CurrentMillisecond() / 1000;
+ if (now > ptr.p->m_next_report)
{
reportStatus(signal, ptr);
- ptr.p->m_next_report = the_time.tv_sec + m_backup_report_frequency;
+ ptr.p->m_next_report = now + m_backup_report_frequency;
}
}
=== modified file 'storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp 2008-04-23 14:43:44 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp 2008-06-09 14:31:19 +0000
@@ -11962,6 +11962,8 @@ void Dbdih::checkGcpStopLab(Signal* sign
*/
void Dbdih::crashSystemAtGcpStop(Signal* signal, bool local)
{
+ Uint32 save_counter = m_gcp_monitor.m_gcp_save.m_counter;
+ Uint32 micro_counter = m_gcp_monitor.m_micro_gcp.m_counter;
m_gcp_monitor.m_gcp_save.m_counter = 0;
m_gcp_monitor.m_micro_gcp.m_counter = 0;
@@ -11986,7 +11988,7 @@ void Dbdih::crashSystemAtGcpStop(Signal*
return;
}
- if (m_gcp_monitor.m_gcp_save.m_counter == m_gcp_monitor.m_gcp_save.m_max_lag)
+ if (save_counter == m_gcp_monitor.m_gcp_save.m_max_lag)
{
switch(m_gcp_save.m_master.m_state){
case GcpSave::GCP_SAVE_IDLE:
@@ -12050,7 +12052,7 @@ void Dbdih::crashSystemAtGcpStop(Signal*
}
}
- if (m_gcp_monitor.m_micro_gcp.m_counter==m_gcp_monitor.m_micro_gcp.m_max_lag)
+ if (micro_counter == m_gcp_monitor.m_micro_gcp.m_max_lag)
{
switch(m_micro_gcp.m_master.m_state){
case MicroGcp::M_GCP_IDLE:
=== modified file 'storage/ndb/tools/restore/restore_main.cpp'
--- a/storage/ndb/tools/restore/restore_main.cpp 2008-03-18 07:12:39 +0000
+++ b/storage/ndb/tools/restore/restore_main.cpp 2008-06-09 14:31:19 +0000
@@ -668,20 +668,20 @@ static void exitHandler(int code)
static void init_progress()
{
- struct timeval the_time;
- gettimeofday(&the_time, 0);
- g_report_next = the_time.tv_sec + opt_progress_frequency;
+ Uint64 now = NdbTick_CurrentMillisecond() / 1000;
+ g_report_next = now + opt_progress_frequency;
}
static int check_progress()
{
if (!opt_progress_frequency)
return 0;
- struct timeval the_time;
- gettimeofday(&the_time, 0);
- if (the_time.tv_sec >= g_report_next)
+
+ Uint64 now = NdbTick_CurrentMillisecond() / 1000;
+
+ if (now >= g_report_next)
{
- g_report_next = the_time.tv_sec + opt_progress_frequency;
+ g_report_next = now + opt_progress_frequency;
return 1;
}
return 0;
=== modified file 'storage/ndb/tools/waiter.cpp'
--- a/storage/ndb/tools/waiter.cpp 2008-03-20 09:18:53 +0000
+++ b/storage/ndb/tools/waiter.cpp 2008-06-09 11:57:17 +0000
@@ -21,6 +21,7 @@
#include <NdbMain.h>
#include <NdbOut.hpp>
#include <NdbSleep.h>
+#include <NdbTick.h>
#include <NDBT.hpp>
@@ -214,12 +215,11 @@ waitClusterStatus(const char* _addr,
const int MAX_RESET_ATTEMPTS = 10;
bool allInState = false;
- struct timeval time_now;
- gettimeofday(&time_now, 0);
- Int64 timeout_time = time_now.tv_sec + _timeout;
+ Uint64 time_now = NdbTick_CurrentMillisecond();
+ Int64 timeout_time = time_now + 1000 * _timeout;
while (allInState == false){
- if (_timeout > 0 && time_now.tv_sec > timeout_time){
+ if (_timeout > 0 && time_now > timeout_time){
/**
* Timeout has expired waiting for the nodes to enter
* the state we want
@@ -257,7 +257,7 @@ waitClusterStatus(const char* _addr,
<< " resetting timeout "
<< resetAttempts << endl;
- timeout_time = time_now.tv_sec + _timeout;
+ timeout_time = time_now + 1000 * _timeout;
resetAttempts++;
}
@@ -290,7 +290,8 @@ waitClusterStatus(const char* _addr,
}
attempts++;
- gettimeofday(&time_now, 0);
+
+ time_now = NdbTick_CurrentMillisecond();
}
return 0;
}
| Thread |
|---|
| • bzr commit into mysql-5.1-telco-6.3 branch (jonas:2627) | jonas | 9 Jun |