[Box Backup-commit] COMMIT r3541 - box/trunk/lib/common

subversion at boxbackup.org subversion at boxbackup.org
Mon Apr 6 13:17:47 BST 2015


Author: chris
Date: 2015-04-06 12:17:47 +0000 (Mon, 06 Apr 2015)
New Revision: 3541

Modified:
   box/trunk/lib/common/Archive.h
Log:
Add missing timeouts to Archive reads.

Allows Archive to be used safely on network streams.

Modified: box/trunk/lib/common/Archive.h
===================================================================
--- box/trunk/lib/common/Archive.h	2015-04-04 20:22:35 UTC (rev 3540)
+++ box/trunk/lib/common/Archive.h	2015-04-06 12:17:47 UTC (rev 3541)
@@ -49,18 +49,18 @@
 	void Write(int Item)
 	{
 		int32_t privItem = htonl(Item);
-		mrStream.Write(&privItem, sizeof(privItem));
+		mrStream.Write(&privItem, sizeof(privItem), mTimeout);
 	}
 	void Write(int64_t Item)
 	{
 		int64_t privItem = box_hton64(Item);
-		mrStream.Write(&privItem, sizeof(privItem));
+		mrStream.Write(&privItem, sizeof(privItem), mTimeout);
 	}
 	void WriteExact(uint64_t Item) { Write(Item); }
 	void Write(uint64_t Item)
 	{
 		uint64_t privItem = box_hton64(Item);
-		mrStream.Write(&privItem, sizeof(privItem));
+		mrStream.Write(&privItem, sizeof(privItem), mTimeout);
 	}
 	void Write(uint8_t Item)
 	{
@@ -71,7 +71,7 @@
 	{
 		int size = Item.size();
 		Write(size);
-		mrStream.Write(Item.c_str(), size);
+		mrStream.Write(Item.c_str(), size, mTimeout);
 	}
 	//
 	//
@@ -100,7 +100,9 @@
 	void Read(int &rItemOut)
 	{
 		int32_t privItem;
-		if(!mrStream.ReadFullBuffer(&privItem, sizeof(privItem), 0 /* not interested in bytes read if this fails */))
+		if(!mrStream.ReadFullBuffer(&privItem, sizeof(privItem),
+			0 /* not interested in bytes read if this fails */,
+			mTimeout))
 		{
 			THROW_EXCEPTION(CommonException, ArchiveBlockIncompleteRead)
 		}
@@ -110,7 +112,8 @@
 	{
 		int32_t privItem;
 		int bytesRead;
-		if(mrStream.ReadFullBuffer(&privItem, sizeof(privItem), &bytesRead))
+		if(mrStream.ReadFullBuffer(&privItem, sizeof(privItem),
+			&bytesRead, mTimeout))
 		{
 			rItemOut = ntohl(privItem);
 		}
@@ -128,7 +131,9 @@
 	void Read(int64_t &rItemOut)
 	{
 		int64_t privItem;
-		if(!mrStream.ReadFullBuffer(&privItem, sizeof(privItem), 0 /* not interested in bytes read if this fails */))
+		if(!mrStream.ReadFullBuffer(&privItem, sizeof(privItem),
+			0 /* not interested in bytes read if this fails */,
+			mTimeout))
 		{
 			THROW_EXCEPTION(CommonException, ArchiveBlockIncompleteRead)
 		}
@@ -138,7 +143,9 @@
 	void Read(uint64_t &rItemOut)
 	{
 		uint64_t privItem;
-		if(!mrStream.ReadFullBuffer(&privItem, sizeof(privItem), 0 /* not interested in bytes read if this fails */))
+		if(!mrStream.ReadFullBuffer(&privItem, sizeof(privItem),
+			0 /* not interested in bytes read if this fails */,
+			mTimeout))
 		{
 			THROW_EXCEPTION(CommonException, ArchiveBlockIncompleteRead)
 		}




More information about the Boxbackup-commit mailing list