*** a/src/bin/pg_basebackup/pg_receivexlog.c
--- b/src/bin/pg_basebackup/pg_receivexlog.c
***************
*** 293,299 **** StreamLog(void)
  	/*
  	 * Connect in replication mode to the server
  	 */
! 	conn = GetConnection();
  	if (!conn)
  		/* Error message already written in GetConnection() */
  		return;
--- 293,300 ----
  	/*
  	 * Connect in replication mode to the server
  	 */
! 	if (conn == NULL)
! 		conn = GetConnection();
  	if (!conn)
  		/* Error message already written in GetConnection() */
  		return;
***************
*** 345,350 **** StreamLog(void)
--- 346,352 ----
  					  fsync_interval);
  
  	PQfinish(conn);
+ 	conn = NULL;
  }
  
  /*
***************
*** 591,596 **** main(int argc, char **argv)
--- 593,603 ----
  			disconnect_and_exit(1);
  	}
  
+ 	/*
+ 	 * Don't close the connection here so that subsequent StreamLog()
+ 	 * can reuse it.
+ 	 */
+ 
  	while (true)
  	{
  		StreamLog();
