*** a/doc/src/sgml/ref/pg_receivexlog.sgml
--- b/doc/src/sgml/ref/pg_receivexlog.sgml
***************
*** 191,196 **** PostgreSQL documentation
--- 191,198 ----
          A value of zero disables the periodic status updates completely,
          although an update will still be sent when requested by the server, to
          avoid timeout disconnect. The default value is 10 seconds.
+         If -1 is specified, status packets sent to the server , 
+         after WAL file is flushed. 
         </para>
        </listitem>
       </varlistentry>
*** a/src/bin/pg_basebackup/pg_receivexlog.c
--- b/src/bin/pg_basebackup/pg_receivexlog.c
***************
*** 428,434 **** main(int argc, char **argv)
  				break;
  			case 's':
  				standby_message_timeout = atoi(optarg) * 1000;
! 				if (standby_message_timeout < 0)
  				{
  					fprintf(stderr, _("%s: invalid status interval \"%s\"\n"),
  							progname, optarg);
--- 428,434 ----
  				break;
  			case 's':
  				standby_message_timeout = atoi(optarg) * 1000;
! 				if (standby_message_timeout < -1000)
  				{
  					fprintf(stderr, _("%s: invalid status interval \"%s\"\n"),
  							progname, optarg);
*** a/src/bin/pg_basebackup/receivelog.c
--- b/src/bin/pg_basebackup/receivelog.c
***************
*** 46,59 **** static bool ProcessKeepaliveMsg(PGconn *conn, char *copybuf, int len,
  static bool ProcessXLogDataMsg(PGconn *conn, char *copybuf, int len,
  							   XLogRecPtr *blockpos, uint32 timeline,
  							   char *basedir, stream_stop_callback stream_stop,
! 							   char *partial_suffix);
  static PGresult *HandleEndOfCopyStream(PGconn *conn, char *copybuf,
  									   XLogRecPtr blockpos, char *basedir, char *partial_suffix,
! 									   XLogRecPtr *stoppos);
  static bool CheckCopyStreamStop(PGconn *conn, XLogRecPtr blockpos,
  								uint32 timeline, char *basedir,
  								stream_stop_callback stream_stop,
! 								char *partial_suffix, XLogRecPtr *stoppos);
  static long CalculateCopyStreamSleeptime(int64 now, int standby_message_timeout,
  										 int64 last_status, int fsync_interval,
  										 XLogRecPtr blockpos);
--- 46,60 ----
  static bool ProcessXLogDataMsg(PGconn *conn, char *copybuf, int len,
  							   XLogRecPtr *blockpos, uint32 timeline,
  							   char *basedir, stream_stop_callback stream_stop,
! 							   char *partial_suffix, int standby_message_timeout);
  static PGresult *HandleEndOfCopyStream(PGconn *conn, char *copybuf,
  									   XLogRecPtr blockpos, char *basedir, char *partial_suffix,
! 									   XLogRecPtr *stoppos, int standby_message_timeout);
  static bool CheckCopyStreamStop(PGconn *conn, XLogRecPtr blockpos,
  								uint32 timeline, char *basedir,
  								stream_stop_callback stream_stop,
! 								char *partial_suffix, XLogRecPtr *stoppos,
! 								int standby_message_timeout);
  static long CalculateCopyStreamSleeptime(int64 now, int standby_message_timeout,
  										 int64 last_status, int fsync_interval,
  										 XLogRecPtr blockpos);
***************
*** 61,66 **** static long CalculateCopyStreamSleeptime(int64 now, int standby_message_timeout,
--- 62,70 ----
  static bool ReadEndOfStreamingResult(PGresult *res, XLogRecPtr *startpos,
  						 uint32 *timeline);
  
+ static bool sendFeedback(PGconn *conn, XLogRecPtr blockpos, int64 now,
+ 						 bool replyRequested);
+ 
  /*
   * Open a new WAL file in the specified directory.
   *
***************
*** 154,160 **** open_walfile(XLogRecPtr startpoint, uint32 timeline, char *basedir,
   * and returns false, otherwise returns true.
   */
  static bool
! close_walfile(char *basedir, char *partial_suffix, XLogRecPtr pos)
  {
  	off_t		currpos;
  
--- 158,164 ----
   * and returns false, otherwise returns true.
   */
  static bool
! close_walfile(char *basedir, char *partial_suffix, XLogRecPtr pos, int standby_message_timeout)
  {
  	off_t		currpos;
  
***************
*** 210,215 **** close_walfile(char *basedir, char *partial_suffix, XLogRecPtr pos)
--- 214,223 ----
  
  	lastFlushPosition = pos;
  	last_fsync = feGetCurrentTimestamp();
+ 	/* Send feedback! */
+ 	if (standby_message_timeout < 0)
+ 		if (!sendFeedback(conn, pos, last_fsync, false))
+ 			return false;
  	return true;
  }
  
***************
*** 778,784 **** HandleCopyStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline,
  		 * Check if we should continue streaming, or abort at this point.
  		 */
  		if (!CheckCopyStreamStop(conn, blockpos, timeline, basedir,
! 								stream_stop, partial_suffix, stoppos))
  			goto error;
  
  		now = feGetCurrentTimestamp();
--- 786,792 ----
  		 * Check if we should continue streaming, or abort at this point.
  		 */
  		if (!CheckCopyStreamStop(conn, blockpos, timeline, basedir,
! 								stream_stop, partial_suffix, stoppos, standby_message_timeout))
  			goto error;
  
  		now = feGetCurrentTimestamp();
***************
*** 802,807 **** HandleCopyStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline,
--- 810,820 ----
  
  			lastFlushPosition = blockpos;
  			last_fsync = now;
+ 
+ 			/* Send feedback! */
+ 			if (standby_message_timeout < 0)
+ 				if (!sendFeedback(conn, blockpos, now, false))
+ 					goto error;
  		}
  
  		/*
***************
*** 831,837 **** HandleCopyStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline,
  			if (r == -2)
  			{
  				PGresult	*res = HandleEndOfCopyStream(conn, copybuf, blockpos,
! 														 basedir, partial_suffix, stoppos);
  				if (res == NULL)
  					goto error;
  				else
--- 844,850 ----
  			if (r == -2)
  			{
  				PGresult	*res = HandleEndOfCopyStream(conn, copybuf, blockpos,
! 														 basedir, partial_suffix, stoppos, standby_message_timeout);
  				if (res == NULL)
  					goto error;
  				else
***************
*** 848,861 **** HandleCopyStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline,
  			else if (copybuf[0] == 'w')
  			{
  				if (!ProcessXLogDataMsg(conn, copybuf, r, &blockpos,
! 										timeline, basedir, stream_stop, partial_suffix))
  					goto error;
  
  				/*
  				 * Check if we should continue streaming, or abort at this point.
  				 */
  				if (!CheckCopyStreamStop(conn, blockpos, timeline, basedir,
! 										 stream_stop, partial_suffix, stoppos))
  					goto error;
  			}
  			else
--- 861,874 ----
  			else if (copybuf[0] == 'w')
  			{
  				if (!ProcessXLogDataMsg(conn, copybuf, r, &blockpos,
! 										timeline, basedir, stream_stop, partial_suffix, standby_message_timeout))
  					goto error;
  
  				/*
  				 * Check if we should continue streaming, or abort at this point.
  				 */
  				if (!CheckCopyStreamStop(conn, blockpos, timeline, basedir,
! 										 stream_stop, partial_suffix, stoppos, standby_message_timeout))
  					goto error;
  			}
  			else
***************
*** 1037,1043 **** static bool
  ProcessXLogDataMsg(PGconn *conn, char *copybuf, int len,
  				   XLogRecPtr *blockpos, uint32 timeline,
  				   char *basedir, stream_stop_callback stream_stop,
! 				   char *partial_suffix)
  {
  	int			xlogoff;
  	int			bytes_left;
--- 1050,1056 ----
  ProcessXLogDataMsg(PGconn *conn, char *copybuf, int len,
  				   XLogRecPtr *blockpos, uint32 timeline,
  				   char *basedir, stream_stop_callback stream_stop,
! 				   char *partial_suffix, int standby_message_timeout)
  {
  	int			xlogoff;
  	int			bytes_left;
***************
*** 1145,1151 **** ProcessXLogDataMsg(PGconn *conn, char *copybuf, int len,
  		/* Did we reach the end of a WAL segment? */
  		if (*blockpos % XLOG_SEG_SIZE == 0)
  		{
! 			if (!close_walfile(basedir, partial_suffix, *blockpos))
  				/* Error message written in close_walfile() */
  				return false;
  
--- 1158,1164 ----
  		/* Did we reach the end of a WAL segment? */
  		if (*blockpos % XLOG_SEG_SIZE == 0)
  		{
! 			if (!close_walfile(basedir, partial_suffix, *blockpos, standby_message_timeout))
  				/* Error message written in close_walfile() */
  				return false;
  
***************
*** 1175,1181 **** ProcessXLogDataMsg(PGconn *conn, char *copybuf, int len,
  static PGresult *
  HandleEndOfCopyStream(PGconn *conn, char *copybuf,
  					  XLogRecPtr blockpos, char *basedir, char *partial_suffix,
! 					  XLogRecPtr *stoppos)
  {
  	PGresult   *res = PQgetResult(conn);
  
--- 1188,1194 ----
  static PGresult *
  HandleEndOfCopyStream(PGconn *conn, char *copybuf,
  					  XLogRecPtr blockpos, char *basedir, char *partial_suffix,
! 					  XLogRecPtr *stoppos, int standby_message_timeout)
  {
  	PGresult   *res = PQgetResult(conn);
  
***************
*** 1186,1192 **** HandleEndOfCopyStream(PGconn *conn, char *copybuf,
  	 */
  	if (still_sending)
  	{
! 		if (!close_walfile(basedir, partial_suffix, blockpos))
  		{
  			/* Error message written in close_walfile() */
  			PQclear(res);
--- 1199,1205 ----
  	 */
  	if (still_sending)
  	{
! 		if (!close_walfile(basedir, partial_suffix, blockpos, standby_message_timeout))
  		{
  			/* Error message written in close_walfile() */
  			PQclear(res);
***************
*** 1218,1228 **** HandleEndOfCopyStream(PGconn *conn, char *copybuf,
  static bool
  CheckCopyStreamStop(PGconn *conn, XLogRecPtr blockpos, uint32 timeline,
  					char *basedir, stream_stop_callback stream_stop,
! 					char *partial_suffix, XLogRecPtr *stoppos)
  {
  	if (still_sending && stream_stop(blockpos, timeline, false))
  	{
! 		if (!close_walfile(basedir, partial_suffix, blockpos))
  		{
  			/* Potential error message is written by close_walfile */
  			return false;
--- 1231,1242 ----
  static bool
  CheckCopyStreamStop(PGconn *conn, XLogRecPtr blockpos, uint32 timeline,
  					char *basedir, stream_stop_callback stream_stop,
! 					char *partial_suffix, XLogRecPtr *stoppos,
! 					int standby_message_timeout)
  {
  	if (still_sending && stream_stop(blockpos, timeline, false))
  	{
! 		if (!close_walfile(basedir, partial_suffix, blockpos, standby_message_timeout))
  		{
  			/* Potential error message is written by close_walfile */
  			return false;
