On Thursday 07 of February 2019 16:52:21 Russell Brown wrote:
Hi,
I don't know how closely the devs watch the Bug list but I believe I've fixed Bug 2998.
As this bug results in kdesktop/kdesktop_lock eating CPU and going unresponsive; might I humbly request that the fix is incorporated in the next possible/dev version.
As the code I posted on bugzilla used a crude fixed buffer, here's a cleaned up version that uses malloc.
*** /tmp/tdebase-trinity-14.0.6~pre38/kdesktop/lock/main.cc Thu Feb 7 15:48:21 2019 --- /usr/tmp/tdebase-trinity-14.0.6~pre38/kdesktop/lock/main.cc Sun May 20 19:41:55 2018 *************** *** 325,336 **** #endif }
! char *locknameroot="kdesktop_lock_lockfile."; ! char *lockfilename = (char*)malloc(strlen(locknameroot) + strlen(getenv("DISPLAY")) + 1); ! strcpy(lockfilename,locknameroot); ! strcat(lockfilename,getenv("DISPLAY")); ! ! TDELockFile lock(locateLocal("tmp", lockfilename)); lock.setStaleTime(0); TDELockFile::LockResult lockRet = lock.lock(); if (lockRet != TDELockFile::LockOK) { --- 325,331 ---- #endif }
! TDELockFile lock(locateLocal("tmp", "kdesktop_lock_lockfile")); lock.setStaleTime(0); TDELockFile::LockResult lockRet = lock.lock(); if (lockRet != TDELockFile::LockOK) {
Hi Russell,
your observation gives a very clear sense. The name of the lock does not distinguish between $DISPLAY and therefore two separate kdesktop_lock processes struggles for one file. Good conclusion!
Because locateLocal expects a TQString value as argument, I suggest using this fact and make the patch simpler:
--- a/kdesktop/lock/main.cc +++ b/kdesktop/lock/main.cc @@ -325,7 +325,7 @@ #endif }
- TDELockFile lock(locateLocal("tmp", "kdesktop_lock_lockfile")); + TDELockFile lock(locateLocal("tmp", TQString("kdesktop_lock_lockfile.%1").arg(getenv("DISPLAY")))); lock.setStaleTime(0); TDELockFile::LockResult lockRet = lock.lock(); if (lockRet != TDELockFile::LockOK) {
If you want to get involved, the best way is to register on TDE Gitea Workspace and create a pull-request. See:
https://wiki.trinitydesktop.org/TDE_Gitea_Workspace
Note: Pull-requests should always be on the master branch. Core developers then take care of a backport patch into a stable branch.
Note1: By the way, in your proposed code is missing free, so this would leads to memory leaks.
Cheers