mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 05:22:25 +01:00
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)
This commit is contained in:
parent
07b25eaaa6
commit
1c9297329c
1 changed files with 16 additions and 4 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue