Skip to content

Commit c129c16

Browse files
author
Neil Conway
committed
Slight refactoring and optimization of some code in WaitOnLock().
1 parent a258a1b commit c129c16

File tree

1 file changed

+6
-4
lines changed
  • src/backend/storage/lmgr

1 file changed

+6
-4
lines changed

src/backend/storage/lmgr/lock.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.147 2005/03/01 21:14:59 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.148 2005/03/11 03:52:06 neilc Exp $
1212
*
1313
* NOTES
1414
* Outside modules can create a lock table and acquire/release
@@ -1076,16 +1076,18 @@ WaitOnLock(LOCKMETHODID lockmethodid, LOCALLOCK *locallock,
10761076
LockMethod lockMethodTable = LockMethods[lockmethodid];
10771077
char *new_status,
10781078
*old_status;
1079+
size_t len;
10791080

10801081
Assert(lockmethodid < NumLockMethods);
10811082

10821083
LOCK_PRINT("WaitOnLock: sleeping on lock",
10831084
locallock->lock, locallock->tag.mode);
10841085

10851086
old_status = pstrdup(get_ps_display());
1086-
new_status = (char *) palloc(strlen(old_status) + 10);
1087-
strcpy(new_status, old_status);
1088-
strcat(new_status, " waiting");
1087+
len = strlen(old_status);
1088+
new_status = (char *) palloc(len + 8 + 1);
1089+
memcpy(new_status, old_status, len);
1090+
strcpy(new_status + len, " waiting");
10891091
set_ps_display(new_status);
10901092

10911093
awaitedLock = locallock;

0 commit comments

Comments
 (0)