Skip to content

Commit 963c1fa

Browse files
committed
Minor cleanups in S_LOCK_TEST code.
1 parent 5f6401e commit 963c1fa

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

src/backend/storage/lmgr/s_lock.c

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/s_lock.c,v 1.13 2003/08/04 02:40:03 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/s_lock.c,v 1.14 2003/08/04 15:28:33 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -29,7 +29,7 @@ s_lock_stuck(volatile slock_t *lock, const char *file, int line)
2929
{
3030
#if defined(S_LOCK_TEST)
3131
fprintf(stderr,
32-
"\nFATAL: stuck spinlock (%p) detected at %s:%d.\n",
32+
"\nStuck spinlock (%p) detected at %s:%d.\n",
3333
lock, file, line);
3434
abort();
3535
#else
@@ -209,37 +209,55 @@ tas_dummy() /* really means: extern int tas(slock_t
209209
#if defined(S_LOCK_TEST)
210210

211211
/*
212-
* test program for verifying a port.
212+
* test program for verifying a port's spinlock support.
213213
*/
214214

215215
volatile slock_t test_lock;
216216

217-
void
217+
int
218218
main()
219219
{
220220
S_INIT_LOCK(&test_lock);
221221

222222
if (!S_LOCK_FREE(&test_lock))
223223
{
224-
printf("S_LOCK_TEST: failed, lock not initialized.\n");
225-
exit(1);
224+
printf("S_LOCK_TEST: failed, lock not initialized\n");
225+
return 1;
226226
}
227227

228228
S_LOCK(&test_lock);
229229

230230
if (S_LOCK_FREE(&test_lock))
231231
{
232232
printf("S_LOCK_TEST: failed, lock not locked\n");
233-
exit(2);
233+
return 1;
234234
}
235235

236-
printf("S_LOCK_TEST: this will hang for a few minutes and then abort\n");
236+
S_UNLOCK(&test_lock);
237+
238+
if (!S_LOCK_FREE(&test_lock))
239+
{
240+
printf("S_LOCK_TEST: failed, lock not unlocked\n");
241+
return 1;
242+
}
243+
244+
S_LOCK(&test_lock);
245+
246+
if (S_LOCK_FREE(&test_lock))
247+
{
248+
printf("S_LOCK_TEST: failed, lock not re-locked\n");
249+
return 1;
250+
}
251+
252+
printf("S_LOCK_TEST: this will hang for a minute or so and then abort\n");
237253
printf(" with a 'stuck spinlock' message if S_LOCK()\n");
238254
printf(" and TAS() are working.\n");
255+
fflush(stdout);
256+
239257
s_lock(&test_lock, __FILE__, __LINE__);
240258

241-
printf("S_LOCK_TEST: failed, lock not locked~\n");
242-
exit(3);
259+
printf("S_LOCK_TEST: failed, lock not locked\n");
260+
return 1;
243261
}
244262

245263
#endif /* S_LOCK_TEST */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy