FreeBSD Bugzilla – Attachment 222190 Details for
Bug 253278
x11-servers/xorg-server: Lock file: Various fixes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch against the ports tree
x11-servers_xorg-server.patch (text/plain), 5.02 KB, created by
Olivier Certner
on 2021-02-05 19:23:36 UTC
(
hide
)
Description:
Patch against the ports tree
Filename:
MIME Type:
Creator:
Olivier Certner
Created:
2021-02-05 19:23:36 UTC
Size:
5.02 KB
patch
obsolete
>Index: x11-servers/xorg-server/files/patch-os_utils.c >=================================================================== >--- x11-servers/xorg-server/files/patch-os_utils.c (nonexistent) >+++ x11-servers/xorg-server/files/patch-os_utils.c (copie de travail) >@@ -0,0 +1,147 @@ >+Several fixes: >+1. Create a lock file in the case of an explicitly requested display even if >+"-displayfd" was specified. This is because, in this case, the server creation >+process is essentially the same as when "-displayfd" is not specified. The only >+difference with the latter case should be that Xorg outputs the passed display >+to the display FD (only the display selection logic is bypassed). >+2. Properly indicate an unexpected problem with link(2), instead of assuming >+that a failure always means that the file indeed exists. >+3. Workaround for some FreeBSD's link bug (link returns EPERM when hard linking >+a file whose permissions are the result of creating a file in a directory with >+sticky bit, although creating a separate copy is perfectly >+possible). Additional benefit: Simplifies the cumbersome logic, which on POSIX >+systems is unnecessary (initial lock file creation with O_EXCL is enough to >+ensure mutual exclusion). >+ >+--- os/utils.c >++++ os/utils.c >+@@ -259,13 +259,18 @@ >+ void >+ LockServer(void) >+ { >+- char tmp[PATH_MAX], pid_str[12]; >+- int lfd, i, haslock, l_pid, t; >++#ifndef __FreeBSD__ >++ char tmp[PATH_MAX]; >++#else >++ char * tmp = LockFile; >++#endif >++ char pid_str[12]; >++ int lfd, i, haslock = 0, l_pid, t; >+ const char *tmppath = LOCK_DIR; >+ int len; >+ char port[20]; >+ >+- if (nolock || NoListenAll) >++ if (nolock || NoListenAll || !explicit_display) >+ return; >+ /* >+ * Path names >+@@ -276,7 +281,9 @@ >+ len += strlen(tmppath) + strlen(port) + strlen(LOCK_SUFFIX) + 1; >+ if (len > sizeof(LockFile)) >+ FatalError("Display name `%s' is too long\n", port); >++#ifndef __FreeBSD__ >+ (void) sprintf(tmp, "%s" LOCK_TMP_PREFIX "%s" LOCK_SUFFIX, tmppath, port); >++#endif >+ (void) sprintf(LockFile, "%s" LOCK_PREFIX "%s" LOCK_SUFFIX, tmppath, port); >+ >+ /* >+@@ -293,6 +300,7 @@ >+ else >+ break; >+ } while (i < 3); >++#ifndef __FreeBSD__ >+ if (lfd < 0) { >+ unlink(tmp); >+ i = 0; >+@@ -305,20 +313,35 @@ >+ break; >+ } while (i < 3); >+ } >+- if (lfd < 0) >++#endif >++ if (lfd < 0) { >++#ifndef __FreeBSD__ >+ FatalError("Could not create lock file in %s\n", tmp); >++#else >++ if (errno == EEXIST) >++ goto existing_server; >++ else >++ goto end; >++#endif >++ } >+ snprintf(pid_str, sizeof(pid_str), "%10lu\n", (unsigned long) getpid()); >+- if (write(lfd, pid_str, 11) != 11) >++ if (write(lfd, pid_str, 11) != 11) { >++ unlink(tmp); >+ FatalError("Could not write pid to lock file in %s\n", tmp); >++ } >+ (void) fchmod(lfd, 0444); >+ (void) close(lfd); >+ >++#ifdef __FreeBSD__ >++ haslock = 1; >++ goto end; >++#endif >++ >+ /* >+ * OK. Now the tmp file exists. Try three times to move it in place >+ * for the lock. >+ */ >+ i = 0; >+- haslock = 0; >+ while ((!haslock) && (i++ < 3)) { >+ haslock = (link(tmp, LockFile) == 0); >+ if (haslock) { >+@@ -327,7 +350,7 @@ >+ */ >+ break; >+ } >+- else { >++ else if (errno == EEXIST) { >+ /* >+ * Read the pid from the existing file >+ */ >+@@ -366,14 +389,22 @@ >+ * Process is still active. >+ */ >+ unlink(tmp); >++ existing_server: >+ FatalError >+ ("Server is already active for display %s\n%s %s\n%s\n", >+ port, "\tIf this server is no longer running, remove", >+ LockFile, "\tand start again."); >+ } >+ } >++ else { >++ unlink(tmp); >++ FatalError >++ ("Linking lock file (%s) in place failed: %s\n", >++ LockFile, strerror(errno)); >++ } >+ } >+ unlink(tmp); >++ end: >+ if (!haslock) >+ FatalError("Could not create server lock file: %s\n", LockFile); >+ StillLocking = FALSE; >+@@ -386,7 +417,7 @@ >+ void >+ UnlockServer(void) >+ { >+- if (nolock || NoListenAll) >++ if (nolock || NoListenAll || !explicit_display) >+ return; >+ >+ if (!StillLocking) { >+@@ -753,9 +784,6 @@ >+ else if (strcmp(argv[i], "-displayfd") == 0) { >+ if (++i < argc) { >+ displayfd = atoi(argv[i]); >+-#ifdef LOCK_SERVER >+- nolock = TRUE; >+-#endif >+ } >+ else >+ UseMsg(); > >Property changes on: x11-servers/xorg-server/files/patch-os_utils.c >___________________________________________________________________ >Added: fbsd:nokeywords >## -0,0 +1 ## >+yes >\ No newline at end of property >Added: svn:eol-style >## -0,0 +1 ## >+native >\ No newline at end of property >Added: svn:mime-type >## -0,0 +1 ## >+text/plain >\ No newline at end of property
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 253278
: 222190