From 72b7e5597b11114cafb0e8ae3c14252a357c9a2c Mon Sep 17 00:00:00 2001 From: "gni/root@dev3-127.(none)" <> Date: Sun, 8 Oct 2006 11:35:03 +0800 Subject: [PATCH 1/3] BUG #21858 Make sure retry when EINTR returns, which decreases memory leak chance. --- ndb/src/common/util/File.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/ndb/src/common/util/File.cpp b/ndb/src/common/util/File.cpp index 056b7ff199b..33d6ca1d535 100644 --- a/ndb/src/common/util/File.cpp +++ b/ndb/src/common/util/File.cpp @@ -123,13 +123,25 @@ bool File_class::close() { bool rc = true; + int retval = 0; + if (m_file != NULL) { ::fflush(m_file); - rc = (::fclose(m_file) == 0 ? true : false); - m_file = NULL; // Try again? + retval = ::fclose(m_file); + while ( (retval != 0) && (errno == EINTR) ){ + retval = ::fclose(m_file); + } + if( retval == 0){ + rc = true; + } + else { + rc = false; + ndbout_c("ERROR: Close file error in File.cpp for %s",strerror(errno)); + } } - + m_file = NULL; + return rc; } From 97515d24de6faabc7da011cafda125d9f661ef72 Mon Sep 17 00:00:00 2001 From: "lzhou/root@dev3-138.dev.cn.tlan" <> Date: Wed, 1 Nov 2006 10:50:19 +0000 Subject: [PATCH 2/3] BUG#21052 Modify the overflow error existed in last patch. --- ndb/include/ndbapi/ndberror.h | 2 +- ndb/src/mgmsrv/Services.cpp | 9 ++++++--- ndb/src/ndbapi/ndberror.c | 7 +++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ndb/include/ndbapi/ndberror.h b/ndb/include/ndbapi/ndberror.h index 2225f68f08d..4d4eddfe617 100644 --- a/ndb/include/ndbapi/ndberror.h +++ b/ndb/include/ndbapi/ndberror.h @@ -93,7 +93,7 @@ typedef ndberror_classification_enum ndberror_classification; const char *ndberror_status_message(ndberror_status); const char *ndberror_classification_message(ndberror_classification); void ndberror_update(ndberror_struct *); -int ndb_error_string(int err_no, char *str, unsigned int size); +int ndb_error_string(int err_no, char *str, int size); #endif /* doxygen skip internal*/ diff --git a/ndb/src/mgmsrv/Services.cpp b/ndb/src/mgmsrv/Services.cpp index 95afeba30ac..c8d99d2f2da 100644 --- a/ndb/src/mgmsrv/Services.cpp +++ b/ndb/src/mgmsrv/Services.cpp @@ -1337,7 +1337,7 @@ Ndb_mgmd_event_service::log(int eventType, const Uint32* theData, NodeId nodeId) if (EventLoggerBase::event_lookup(eventType,cat,threshold,severity,textF)) DBUG_VOID_RETURN; - char m_text[256]; + char m_text[512]; EventLogger::getText(m_text, sizeof(m_text), textF, theData, nodeId); @@ -1356,8 +1356,11 @@ Ndb_mgmd_event_service::log(int eventType, const Uint32* theData, NodeId nodeId) if(strcmp(ndb_logevent_body[i].token,"error") == 0) { int m_text_len= strlen(m_text); - snprintf(m_text+m_text_len, 4 , " - "); - ndb_error_string(theData[3], m_text+(m_text_len+3), sizeof(m_text)-m_text_len-3); + if(sizeof(m_text)-m_text_len-3 > 0) + { + BaseString::snprintf(m_text+m_text_len, 4 , " - "); + ndb_error_string(val, m_text+(m_text_len+3), sizeof(m_text)-m_text_len-3); + } } } diff --git a/ndb/src/ndbapi/ndberror.c b/ndb/src/ndbapi/ndberror.c index 6173292261d..247fdfe65c9 100644 --- a/ndb/src/ndbapi/ndberror.c +++ b/ndb/src/ndbapi/ndberror.c @@ -680,11 +680,14 @@ const char *ndberror_classification_message(ndberror_classification classificati return empty_string; } -int ndb_error_string(int err_no, char *str, unsigned int size) +int ndb_error_string(int err_no, char *str, int size) { ndberror_struct error; - unsigned int len; + int len; + assert(size > 1); + if(size <= 1) + return 0; error.code = err_no; ndberror_update(&error); From 2f6df58526c5f9195ab913899e77a935caa95b4f Mon Sep 17 00:00:00 2001 From: "lzhou/root@dev3-138.dev.cn.tlan" <> Date: Wed, 1 Nov 2006 18:23:30 +0000 Subject: [PATCH 3/3] BUG#19352 return exact error message when parameters overflow in 32-bit platform. --- ndb/src/kernel/vm/SimulatedBlock.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ndb/src/kernel/vm/SimulatedBlock.cpp b/ndb/src/kernel/vm/SimulatedBlock.cpp index 9b52ac65331..d5ba3ac63c1 100644 --- a/ndb/src/kernel/vm/SimulatedBlock.cpp +++ b/ndb/src/kernel/vm/SimulatedBlock.cpp @@ -658,24 +658,26 @@ SimulatedBlock::allocRecord(const char * type, size_t s, size_t n, bool clear) void * p = NULL; size_t size = n*s; + Uint64 real_size = (Uint64)((Uint64)n)*((Uint64)s); refresh_watch_dog(); - if (size > 0){ + if (real_size > 0){ #ifdef VM_TRACE_MEM - ndbout_c("%s::allocRecord(%s, %u, %u) = %u bytes", + ndbout_c("%s::allocRecord(%s, %u, %u) = %llu bytes", getBlockName(number()), type, s, n, - size); + real_size); #endif - p = NdbMem_Allocate(size); + if( real_size == (Uint64)size ) + p = NdbMem_Allocate(size); if (p == NULL){ char buf1[255]; char buf2[255]; BaseString::snprintf(buf1, sizeof(buf1), "%s could not allocate memory for %s", getBlockName(number()), type); - BaseString::snprintf(buf2, sizeof(buf2), "Requested: %ux%u = %u bytes", - (Uint32)s, (Uint32)n, (Uint32)size); + BaseString::snprintf(buf2, sizeof(buf2), "Requested: %ux%u = %llu bytes", + (Uint32)s, (Uint32)n, (Uint64)real_size); ERROR_SET(fatal, ERR_MEMALLOC, buf1, buf2); }