aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/async.c
diff options
context:
space:
mode:
authorMarc G. Fournier <scrappy@hub.org>1997-03-10 00:18:09 +0000
committerMarc G. Fournier <scrappy@hub.org>1997-03-10 00:18:09 +0000
commit977654d55beafd78eddb9a0e226cfaf55b15b0b1 (patch)
treed6cc3f34285827a25956802e874ea365545f008c /src/backend/commands/async.c
parent766bdd2bb5abafe44f7e6db456aeffee2ca3ec51 (diff)
downloadpostgresql-977654d55beafd78eddb9a0e226cfaf55b15b0b1.tar.gz
postgresql-977654d55beafd78eddb9a0e226cfaf55b15b0b1.zip
Massimo's Deadlock patches w/o the #ifdefs
Diffstat (limited to 'src/backend/commands/async.c')
-rw-r--r--src/backend/commands/async.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 328b3286445..af8c401ac2e 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.12 1997/01/24 23:48:25 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.13 1997/03/10 00:18:09 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -84,6 +84,8 @@
#include <port-protos.h> /* for strdup() */
+#include <storage/lmgr.h>
+
static int notifyFrontEndPending = 0;
static int notifyIssued = 0;
static Dllist *pendingNotifies = NULL;
@@ -194,6 +196,7 @@ Async_Notify(char *relname)
lRel = heap_openr(ListenerRelationName);
tdesc = RelationGetTupleDescriptor(lRel);
+ RelationSetLockForWrite(lRel);
sRel = heap_beginscan(lRel, 0, NowTimeQual, 1, &key);
nulls[0] = nulls[1] = nulls[2] = ' ';
@@ -212,6 +215,7 @@ Async_Notify(char *relname)
ReleaseBuffer(b);
}
heap_endscan(sRel);
+ RelationUnsetLockForWrite(lRel);
heap_close(lRel);
notifyIssued = 1;
}
@@ -269,6 +273,7 @@ Async_NotifyAtCommit()
Integer32EqualRegProcedure,
Int32GetDatum(1));
lRel = heap_openr(ListenerRelationName);
+ RelationSetLockForWrite(lRel);
sRel = heap_beginscan(lRel, 0, NowTimeQual, 1, &key);
tdesc = RelationGetTupleDescriptor(lRel);
ourpid = getpid();
@@ -302,6 +307,7 @@ Async_NotifyAtCommit()
ReleaseBuffer(b);
}
heap_endscan(sRel);
+ RelationUnsetLockForWrite(lRel);
heap_close(lRel);
CommitTransactionCommand();
@@ -405,6 +411,7 @@ Async_Listen(char *relname, int pid)
values[i++] = (Datum) 0; /* no notifies pending */
lDesc = heap_openr(ListenerRelationName);
+ RelationSetLockForWrite(lDesc);
/* is someone already listening. One listener per relation */
tdesc = RelationGetTupleDescriptor(lDesc);
@@ -440,6 +447,8 @@ Async_Listen(char *relname, int pid)
/* if (alreadyListener) {
elog(NOTICE,"Async_Listen: already one listener on %s (possibly dead)",relname);
}*/
+
+ RelationUnsetLockForWrite(lDesc);
heap_close(lDesc);
/*
@@ -480,9 +489,13 @@ Async_Unlisten(char *relname, int pid)
Int32GetDatum(pid),
0,0);
lDesc = heap_openr(ListenerRelationName);
+ RelationSetLockForWrite(lDesc);
+
if (lTuple != NULL) {
heap_delete(lDesc,&lTuple->t_ctid);
}
+
+ RelationUnsetLockForWrite(lDesc);
heap_close(lDesc);
}
@@ -549,6 +562,7 @@ Async_NotifyFrontEnd()
Integer32EqualRegProcedure,
Int32GetDatum(ourpid));
lRel = heap_openr(ListenerRelationName);
+ RelationSetLockForWrite(lRel);
tdesc = RelationGetTupleDescriptor(lRel);
sRel = heap_beginscan(lRel, 0, NowTimeQual, 2, key);