List:Commits« Previous MessageNext Message »
From:Stewart Smith Date:March 11 2008 1:15pm
Subject:bk commit into 5.0 tree (stewart:1.2534)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of stewart. When stewart does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2008-03-11 23:15:53+11:00, stewart@willster.(none) +2 -0
  WL4012 ndb_mgmd on win32: try and fix NdbDaemon build

  ndb/src/common/portlib/Makefile.am@stripped, 2008-03-11 23:15:51+11:00,
stewart@willster.(none) +2 -2
    fix NdbDaemon names

  ndb/src/common/portlib/NdbDaemonOld.c@stripped, 2008-03-11 23:03:44+11:00,
stewart@willster.(none) +0 -0
    Rename: ndb/src/common/portlib/NdbDaemon.c -> ndb/src/common/portlib/NdbDaemonOld.c

diff -Nrup a/ndb/src/common/portlib/Makefile.am b/ndb/src/common/portlib/Makefile.am
--- a/ndb/src/common/portlib/Makefile.am	2008-03-11 19:48:20 +11:00
+++ b/ndb/src/common/portlib/Makefile.am	2008-03-11 23:15:51 +11:00
@@ -13,14 +13,14 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-EXTRA_DIST = CMakeLists.txt winNdbTick.c NdbDaemonOld.c NdbDaemon.cpp win32/NdbDaemon.cpp
+EXTRA_DIST = CMakeLists.txt win32/NdbTick.c NdbDaemonOld.c NdbDaemon.cpp
win32/NdbDaemon.cpp
 
 noinst_LTLIBRARIES = libportlib.la
 
 libportlib_la_SOURCES = \
 	NdbCondition.c NdbMutex.c NdbTick.c \
 	NdbEnv.c NdbThread.c NdbHost.c NdbTCP.cpp	    \
-	NdbDaemon.c NdbMem.c \
+	NdbDaemonOld.c NdbMem.c \
 	NdbConfig.c
 
 include $(top_srcdir)/ndb/config/common.mk.am
diff -Nrup a/ndb/src/common/portlib/NdbDaemon.c b/ndb/src/common/portlib/NdbDaemon.c
--- a/ndb/src/common/portlib/NdbDaemon.c	2008-02-15 00:27:41 +11:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,199 +0,0 @@
-/* Copyright (C) 2003 MySQL AB
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; version 2 of the License.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
-
-#include <ndb_global.h>
-#include <basestring_vsnprintf.h>
-#include <NdbHost.h>
-#include "NdbDaemon.h"
-
-#define NdbDaemon_ErrorSize 500
-long NdbDaemon_DaemonPid = 0;
-int NdbDaemon_ErrorCode = 0;
-char NdbDaemon_ErrorText[NdbDaemon_ErrorSize] = "";
-
-#ifdef NDB_WIN32
-#define F_ULOCK _LK_UNLCK
-#define F_LOCK _LK_LOCK
-#define F_TLOCK _LK_NBLCK
-#define lockf(fd,mode,size) _locking((fd),(mode),(size))
-#endif
-
-int restofmake(void*);
-struct Dstate
-{ int lockfd,logfd;
-  const char*lockfile,*logfile;
-  NdbDaemonMain restofmain;
-} dstate;
-
-int nothing(void *p)
-{ (void)p; return 0; }
-
-int
-NdbDaemon_Make(const char* lockfile, const char* logfile, unsigned flags)
-{ return NdbDaemon_c("",lockfile,logfile,flags,nothing); }
-
-int
-NdbDaemon_c(const char*argv0,const char* lockfile, const char* logfile, unsigned flags,
NdbDaemonMain restofmain)
-{
-  int n;
-  char buf[64];
-  dstate.lockfd = -1, dstate.logfd = -1;
-  dstate.lockfile=lockfile, dstate.logfile=logfile;
-  dstate.restofmain=restofmain;
-
-  (void)flags; /* remove warning for unused parameter */
-  (void)argv0;
-
-  /* Check that we have write access to lock file */
-  assert(dstate.lockfile != NULL);
-  fopen(dstate.lockfile,"w");
-  dstate.lockfd = open(dstate.lockfile, O_CREAT|O_RDWR, 0644);
-  if (dstate.lockfd == -1) {
-    NdbDaemon_ErrorCode = errno;
-    basestring_snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
-	"%s: open for write failed: %s", dstate.lockfile, strerror(errno));
-
-    return -1;
-  }
-  /* Read any old pid from lock file */
-  buf[0] = 0;
-  n = read(dstate.lockfd, buf, sizeof(buf));
-  if (n < 0) {
-    NdbDaemon_ErrorCode = errno;
-    basestring_snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
-	"%s: read failed: %s", dstate.lockfile, strerror(errno));
-    return -1;
-  }
-  NdbDaemon_DaemonPid = atol(buf);
-  if (lseek(dstate.lockfd, 0, SEEK_SET) == -1) {
-    NdbDaemon_ErrorCode = errno;
-    basestring_snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
-	"%s: lseek failed: %s", dstate.lockfile, strerror(errno));
-    return -1;
-  }
-#ifdef F_TLOCK
-  /* Test for lock before becoming daemon */
-  if (lockf(dstate.lockfd, F_TLOCK, 0) == -1)
-  {
-    if (errno == EACCES || errno == EAGAIN) {   /* results may vary */
-      basestring_snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
-	       "%s: already locked by pid=%ld", dstate.lockfile, NdbDaemon_DaemonPid);
-      return -1;
-    }
-    NdbDaemon_ErrorCode = errno;
-    basestring_snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
-        "%s: lock test failed: %s", dstate.lockfile, strerror(errno));
-    return -1;
-  }
-#endif
-  /* Test open log file before becoming daemon */
-  if (dstate.logfile != NULL) {
-    dstate.logfd = open(dstate.logfile, O_CREAT|O_WRONLY|O_APPEND, 0644);
-    if (dstate.logfd == -1) {
-      NdbDaemon_ErrorCode = errno;
-      basestring_snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
-	  "%s: open for write failed: %s", dstate.logfile, strerror(errno));
-      return -1;
-    }
-  }
-#ifdef F_TLOCK
-  if (lockf(dstate.lockfd, F_ULOCK, 0) == -1)
-  {
-    basestring_snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
-	     "%s: fail to unlock", dstate.lockfile);
-    return -1;
-  }
-#endif
-#ifndef NDB_WIN32
-  n = fork();
-  if (n == -1) {
-    NdbDaemon_ErrorCode = errno;
-    basestring_snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
-	"fork failed: %s", strerror(errno));
-    return -1;
-  }
-  /* Exit if we are the parent */
-  if (n != 0) {
-    exit(0);
-  }
-#endif
-  {
-    char buf[64];int n;
-    /* Running in child process */
-    NdbDaemon_DaemonPid = NdbHost_GetProcessId();
-    /* Lock the lock file (likely to succeed due to test above) */
-    if (lockf(dstate.lockfd, F_LOCK, 0) == -1) {
-	NdbDaemon_ErrorCode = errno;
-	basestring_snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
-	    "%s: lock failed: %s", dstate.lockfile, strerror(errno));
-	return -1;
-  }
-#ifndef NDB_WIN32
-  /* Become process group leader */
-  if (setsid() == -1) {
-    NdbDaemon_ErrorCode = errno;
-    basestring_snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
-	"setsid failed: %s", strerror(errno));
-    return -1;
-  }
-  /* Write pid to lock file */
-  if (ftruncate(dstate.lockfd, 0) == -1) {
-#else
-  if (_chsize(dstate.lockfd, 0) == -1) {
-#endif
-    NdbDaemon_ErrorCode = errno;
-    basestring_snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
-	"%s: ftruncate failed: %s", dstate.lockfile, strerror(errno));
-    return -1;
-  }
-  sprintf(buf, "%ld\n", NdbDaemon_DaemonPid);
-  n = strlen(buf);
-  if (write(dstate.lockfd, buf, n) != n) {
-    NdbDaemon_ErrorCode = errno;
-    basestring_snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
-	"%s: write failed: %s", dstate.lockfile, strerror(errno));
-    return -1;
-  }
-  /* Do input/output redirections (assume fd 0,1,2 not in use) */
-  close(0);
-#ifndef NDB_WIN32
-  open("/dev/null", O_RDONLY);
-#else
-  open("nul:", O_RDONLY);
-#endif
-  if (dstate.logfile != 0) {
-    dup2(dstate.logfd, 1);
-    dup2(dstate.logfd, 2);
-    close(dstate.logfd);
-  }
-  /* Success */
-  return dstate.restofmain(0);
-  }
-}
-
-#ifdef NDB_DAEMON_TEST
-int daemontest(void*p){return p==0;}
-int
-main(int argc, char**argv)
-{
-  if (NdbDaemon_Make(argv[0],"test.pid", "test.log", 0,daemontest) == -1) {
-    fprintf(stderr, "NdbDaemon_Make: %s\n", NdbDaemon_ErrorText);
-    return 1;
-  }
-  sleep(10);
-  return 0;
-}
-
-#endif
diff -Nrup a/ndb/src/common/portlib/NdbDaemonOld.c b/ndb/src/common/portlib/NdbDaemonOld.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/ndb/src/common/portlib/NdbDaemonOld.c	2008-03-11 23:03:44 +11:00
@@ -0,0 +1,199 @@
+/* Copyright (C) 2003 MySQL AB
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#include <ndb_global.h>
+#include <basestring_vsnprintf.h>
+#include <NdbHost.h>
+#include "NdbDaemon.h"
+
+#define NdbDaemon_ErrorSize 500
+long NdbDaemon_DaemonPid = 0;
+int NdbDaemon_ErrorCode = 0;
+char NdbDaemon_ErrorText[NdbDaemon_ErrorSize] = "";
+
+#ifdef NDB_WIN32
+#define F_ULOCK _LK_UNLCK
+#define F_LOCK _LK_LOCK
+#define F_TLOCK _LK_NBLCK
+#define lockf(fd,mode,size) _locking((fd),(mode),(size))
+#endif
+
+int restofmake(void*);
+struct Dstate
+{ int lockfd,logfd;
+  const char*lockfile,*logfile;
+  NdbDaemonMain restofmain;
+} dstate;
+
+int nothing(void *p)
+{ (void)p; return 0; }
+
+int
+NdbDaemon_Make(const char* lockfile, const char* logfile, unsigned flags)
+{ return NdbDaemon_c("",lockfile,logfile,flags,nothing); }
+
+int
+NdbDaemon_c(const char*argv0,const char* lockfile, const char* logfile, unsigned flags,
NdbDaemonMain restofmain)
+{
+  int n;
+  char buf[64];
+  dstate.lockfd = -1, dstate.logfd = -1;
+  dstate.lockfile=lockfile, dstate.logfile=logfile;
+  dstate.restofmain=restofmain;
+
+  (void)flags; /* remove warning for unused parameter */
+  (void)argv0;
+
+  /* Check that we have write access to lock file */
+  assert(dstate.lockfile != NULL);
+  fopen(dstate.lockfile,"w");
+  dstate.lockfd = open(dstate.lockfile, O_CREAT|O_RDWR, 0644);
+  if (dstate.lockfd == -1) {
+    NdbDaemon_ErrorCode = errno;
+    basestring_snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
+	"%s: open for write failed: %s", dstate.lockfile, strerror(errno));
+
+    return -1;
+  }
+  /* Read any old pid from lock file */
+  buf[0] = 0;
+  n = read(dstate.lockfd, buf, sizeof(buf));
+  if (n < 0) {
+    NdbDaemon_ErrorCode = errno;
+    basestring_snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
+	"%s: read failed: %s", dstate.lockfile, strerror(errno));
+    return -1;
+  }
+  NdbDaemon_DaemonPid = atol(buf);
+  if (lseek(dstate.lockfd, 0, SEEK_SET) == -1) {
+    NdbDaemon_ErrorCode = errno;
+    basestring_snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
+	"%s: lseek failed: %s", dstate.lockfile, strerror(errno));
+    return -1;
+  }
+#ifdef F_TLOCK
+  /* Test for lock before becoming daemon */
+  if (lockf(dstate.lockfd, F_TLOCK, 0) == -1)
+  {
+    if (errno == EACCES || errno == EAGAIN) {   /* results may vary */
+      basestring_snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
+	       "%s: already locked by pid=%ld", dstate.lockfile, NdbDaemon_DaemonPid);
+      return -1;
+    }
+    NdbDaemon_ErrorCode = errno;
+    basestring_snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
+        "%s: lock test failed: %s", dstate.lockfile, strerror(errno));
+    return -1;
+  }
+#endif
+  /* Test open log file before becoming daemon */
+  if (dstate.logfile != NULL) {
+    dstate.logfd = open(dstate.logfile, O_CREAT|O_WRONLY|O_APPEND, 0644);
+    if (dstate.logfd == -1) {
+      NdbDaemon_ErrorCode = errno;
+      basestring_snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
+	  "%s: open for write failed: %s", dstate.logfile, strerror(errno));
+      return -1;
+    }
+  }
+#ifdef F_TLOCK
+  if (lockf(dstate.lockfd, F_ULOCK, 0) == -1)
+  {
+    basestring_snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
+	     "%s: fail to unlock", dstate.lockfile);
+    return -1;
+  }
+#endif
+#ifndef NDB_WIN32
+  n = fork();
+  if (n == -1) {
+    NdbDaemon_ErrorCode = errno;
+    basestring_snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
+	"fork failed: %s", strerror(errno));
+    return -1;
+  }
+  /* Exit if we are the parent */
+  if (n != 0) {
+    exit(0);
+  }
+#endif
+  {
+    char buf[64];int n;
+    /* Running in child process */
+    NdbDaemon_DaemonPid = NdbHost_GetProcessId();
+    /* Lock the lock file (likely to succeed due to test above) */
+    if (lockf(dstate.lockfd, F_LOCK, 0) == -1) {
+	NdbDaemon_ErrorCode = errno;
+	basestring_snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
+	    "%s: lock failed: %s", dstate.lockfile, strerror(errno));
+	return -1;
+  }
+#ifndef NDB_WIN32
+  /* Become process group leader */
+  if (setsid() == -1) {
+    NdbDaemon_ErrorCode = errno;
+    basestring_snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
+	"setsid failed: %s", strerror(errno));
+    return -1;
+  }
+  /* Write pid to lock file */
+  if (ftruncate(dstate.lockfd, 0) == -1) {
+#else
+  if (_chsize(dstate.lockfd, 0) == -1) {
+#endif
+    NdbDaemon_ErrorCode = errno;
+    basestring_snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
+	"%s: ftruncate failed: %s", dstate.lockfile, strerror(errno));
+    return -1;
+  }
+  sprintf(buf, "%ld\n", NdbDaemon_DaemonPid);
+  n = strlen(buf);
+  if (write(dstate.lockfd, buf, n) != n) {
+    NdbDaemon_ErrorCode = errno;
+    basestring_snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
+	"%s: write failed: %s", dstate.lockfile, strerror(errno));
+    return -1;
+  }
+  /* Do input/output redirections (assume fd 0,1,2 not in use) */
+  close(0);
+#ifndef NDB_WIN32
+  open("/dev/null", O_RDONLY);
+#else
+  open("nul:", O_RDONLY);
+#endif
+  if (dstate.logfile != 0) {
+    dup2(dstate.logfd, 1);
+    dup2(dstate.logfd, 2);
+    close(dstate.logfd);
+  }
+  /* Success */
+  return dstate.restofmain(0);
+  }
+}
+
+#ifdef NDB_DAEMON_TEST
+int daemontest(void*p){return p==0;}
+int
+main(int argc, char**argv)
+{
+  if (NdbDaemon_Make(argv[0],"test.pid", "test.log", 0,daemontest) == -1) {
+    fprintf(stderr, "NdbDaemon_Make: %s\n", NdbDaemon_ErrorText);
+    return 1;
+  }
+  sleep(10);
+  return 0;
+}
+
+#endif
Thread
bk commit into 5.0 tree (stewart:1.2534)Stewart Smith11 Mar