Commit 15f7e7ad authored by unknown's avatar unknown
Browse files

Changed implementation in NdbDaemon slightly to handle

  bug lockf & F_TEST on linux alpha,sparc,sparc64

(http://sources.redhat.com/ml/libc-alpha/2000-10/msg00390.html)

parent a87ff6cc
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -55,8 +55,10 @@ NdbDaemon_Make(const char* lockfile, const char* logfile, unsigned flags)
	"%s: lseek failed: %s", lockfile, strerror(errno));
    return -1;
  }
#ifdef F_TLOCK
  /* Test for lock before becoming daemon */
  if (lockf(lockfd, F_TEST, 0) == -1) {
  if (lockf(lockfd, F_TLOCK, 0) == -1) 
  {
    if (errno == EACCES || errno == EAGAIN) {   /* results may vary */
      snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
	       "%s: already locked by pid=%ld", lockfile, NdbDaemon_DaemonPid);
@@ -67,6 +69,7 @@ NdbDaemon_Make(const char* lockfile, const char* logfile, unsigned flags)
        "%s: lock test failed: %s", lockfile, strerror(errno));
    return -1;
  }
#endif
  /* Test open log file before becoming daemon */
  if (logfile != NULL) {
    logfd = open(logfile, O_CREAT|O_WRONLY|O_APPEND, 0644);
@@ -77,6 +80,15 @@ NdbDaemon_Make(const char* lockfile, const char* logfile, unsigned flags)
      return -1;
    }
  }
#ifdef F_TLOCK
  if (lockf(lockfd, F_ULOCK, 0) == -1) 
  {
    snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize,
	     "%s: fail to unlock", lockfile);
    return -1;
  }
#endif
  
  /* Fork */
  n = fork();
  if (n == -1) {