diff --git a/src/backend/libpq/be-secure.c b/src/backend/libpq/be-secure.c
index 29297e7..61f230b 100644
--- a/src/backend/libpq/be-secure.c
+++ b/src/backend/libpq/be-secure.c
@@ -122,6 +122,7 @@ secure_read(Port *port, void *ptr, size_t len)
 {
 	ssize_t		n;
 	int			waitfor;
+	int			wc;
 
 retry:
 #ifdef USE_SSL
@@ -143,11 +144,13 @@ retry:
 		WaitEvent   event;
 
 		Assert(waitfor);
-
+#if 0
 		ModifyWaitEvent(FeBeWaitSet, 0, waitfor, NULL);
 
 		WaitEventSetWait(FeBeWaitSet, -1 /* no timeout */, &event, 1);
-
+#endif
+		wc = WaitLatchOrSocket(MyLatch, WL_LATCH_SET | WL_POSTMASTER_DEATH | waitfor, port->sock, -1);
+		
 		/*
 		 * If the postmaster has died, it's not safe to continue running,
 		 * because it is the postmaster's job to kill us if some other backend
@@ -165,13 +168,13 @@ retry:
 		 * cycles checking for this very rare condition, and this should cause
 		 * us to exit quickly in most cases.)
 		 */
-		if (event.events & WL_POSTMASTER_DEATH)
+		if (wc & WL_POSTMASTER_DEATH)
 			ereport(FATAL,
 					(errcode(ERRCODE_ADMIN_SHUTDOWN),
 					errmsg("terminating connection due to unexpected postmaster exit")));
 
 		/* Handle interrupt. */
-		if (event.events & WL_LATCH_SET)
+		if (wc & WL_LATCH_SET)
 		{
 			ResetLatch(MyLatch);
 			ProcessClientReadInterrupt(true);
