*** a/src/backend/replication/walreceiver.c
--- b/src/backend/replication/walreceiver.c
***************
*** 330,336 **** WalRcvDie(int code, Datum arg)
  	SpinLockRelease(&walrcv->mutex);
  
  	/* Terminate the connection gracefully. */
! 	walrcv_disconnect();
  }
  
  /* SIGHUP: set flag to re-read config file at next convenient time */
--- 330,337 ----
  	SpinLockRelease(&walrcv->mutex);
  
  	/* Terminate the connection gracefully. */
! 	if (walrcv_disconnect != NULL)
! 		walrcv_disconnect();
  }
  
  /* SIGHUP: set flag to re-read config file at next convenient time */
