Просмотр исходного кода

Restoring authorship annotation for <becks@yandex-team.ru>. Commit 2 of 2.

becks 3 лет назад
Родитель
Сommit
86d17ce355

+ 1 - 1
contrib/libs/poco/Net/include/Poco/Net/HTTPHeaderStream.h

@@ -50,7 +50,7 @@ protected:
 private:
 	HTTPSession& _session;
 	bool         _end;
-	bool         _line_ended; 
+	bool         _line_ended;
 };
 
 

+ 4 - 4
contrib/libs/poco/Net/include/Poco/Net/SocketImpl.h

@@ -213,9 +213,9 @@ public:
 		/// Returns true if the next operation corresponding to
 		/// mode will not block, false otherwise.
 
-	bool pollImpl(Poco::Timespan& timeout, int mode); 
-		/// Modifies `timeout` 
- 
+	bool pollImpl(Poco::Timespan& timeout, int mode);
+		/// Modifies `timeout`
+
 	virtual void setSendBufferSize(int size);
 		/// Sets the size of the send buffer.
 
@@ -450,7 +450,7 @@ protected:
 	static void error(int code, const std::string& arg);
 		/// Throws an appropriate exception for the given error code.
 
-protected: 
+protected:
 	SocketImpl(const SocketImpl&);
 	SocketImpl& operator = (const SocketImpl&);
 

+ 4 - 4
contrib/libs/poco/Net/src/HTTPHeaderStream.cpp

@@ -28,8 +28,8 @@ namespace Net {
 HTTPHeaderStreamBuf::HTTPHeaderStreamBuf(HTTPSession& session, openmode mode):
 	HTTPBasicStreamBuf(HTTPBufferAllocator::BUFFER_SIZE, mode),
 	_session(session),
-	_end(false), 
-	_line_ended(true) 
+	_end(false),
+	_line_ended(true)
 {
 }
 
@@ -56,9 +56,9 @@ int HTTPHeaderStreamBuf::readFromDevice(char* buffer, std::streamsize length)
 	if (ch != eof)
 	{
 		*buffer++ = (char) ch; ++n;
-		if (n == 2) _end = _line_ended; 
+		if (n == 2) _end = _line_ended;
 	}
-	_line_ended = (ch == '\n'); 
+	_line_ended = (ch == '\n');
 	return n;
 }
 

+ 10 - 10
contrib/libs/poco/Net/src/SocketImpl.cpp

@@ -449,7 +449,7 @@ bool SocketImpl::secure() const
 }
 
 
-bool SocketImpl::pollImpl(Poco::Timespan& remainingTime, int mode) 
+bool SocketImpl::pollImpl(Poco::Timespan& remainingTime, int mode)
 {
 	poco_socket_t sockfd = _sockfd;
 	if (sockfd == POCO_INVALID_SOCKET) throw InvalidSocketException();
@@ -580,11 +580,11 @@ bool SocketImpl::pollImpl(Poco::Timespan& remainingTime, int mode)
 #endif // POCO_HAVE_FD_EPOLL
 }
 
-bool SocketImpl::poll(const Poco::Timespan& timeout, int mode) 
-{ 
-	Poco::Timespan remainingTime(timeout); 
-	return pollImpl(remainingTime, mode); 
-} 
+bool SocketImpl::poll(const Poco::Timespan& timeout, int mode)
+{
+	Poco::Timespan remainingTime(timeout);
+	return pollImpl(remainingTime, mode);
+}
 	
 void SocketImpl::setSendBufferSize(int size)
 {
@@ -616,13 +616,13 @@ int SocketImpl::getReceiveBufferSize()
 
 void SocketImpl::setSendTimeout(const Poco::Timespan& timeout)
 {
-#if defined(_WIN32) 
+#if defined(_WIN32)
 	int value = (int) timeout.totalMilliseconds();
 	setOption(SOL_SOCKET, SO_SNDTIMEO, value);
-#else 
+#else
 	setOption(SOL_SOCKET, SO_SNDTIMEO, timeout);
 #endif
-	_sndTimeout = timeout; 
+	_sndTimeout = timeout;
 }
 
 
@@ -650,7 +650,7 @@ void SocketImpl::setReceiveTimeout(const Poco::Timespan& timeout)
 #else
 	setOption(SOL_SOCKET, SO_RCVTIMEO, timeout);
 #endif
-	_recvTimeout = timeout; 
+	_recvTimeout = timeout;
 }
 
 

+ 3 - 3
contrib/libs/poco/NetSSL_OpenSSL/include/Poco/Net/SecureSocketImpl.h

@@ -195,7 +195,7 @@ protected:
 		/// Returns true iff the given host name is the local host 
 		/// (either "localhost" or "127.0.0.1").
 
-	bool mustRetry(int rc, Poco::Timespan& remaining_time); 
+	bool mustRetry(int rc, Poco::Timespan& remaining_time);
 		/// Returns true if the last operation should be retried,
 		/// otherwise false.
 		///
@@ -221,8 +221,8 @@ protected:
 		/// Note that simply closing a socket is not sufficient
 		/// to be able to re-use it again.
 
-	Poco::Timespan getMaxTimeout(); 
- 
+	Poco::Timespan getMaxTimeout();
+
 private:	
 	SecureSocketImpl(const SecureSocketImpl&);
 	SecureSocketImpl& operator = (const SecureSocketImpl&);

+ 4 - 4
contrib/libs/poco/NetSSL_OpenSSL/include/Poco/Net/SecureStreamSocketImpl.h

@@ -39,9 +39,9 @@ public:
 	SecureStreamSocketImpl(StreamSocketImpl* pStreamSocket, Context::Ptr pContext);
 		/// Creates the SecureStreamSocketImpl.
 
-    void setSendTimeout(const Poco::Timespan& timeout); 
-    void setReceiveTimeout(const Poco::Timespan& timeout); 
- 
+    void setSendTimeout(const Poco::Timespan& timeout);
+    void setReceiveTimeout(const Poco::Timespan& timeout);
+
 	SocketImpl* acceptConnection(SocketAddress& clientAddr);
 		/// Not supported by a SecureStreamSocket.
 		///
@@ -219,7 +219,7 @@ private:
 	SecureStreamSocketImpl(const SecureStreamSocketImpl&);
 	SecureStreamSocketImpl& operator = (const SecureStreamSocketImpl&);
 
-    StreamSocketImpl * underlying_socket; 
+    StreamSocketImpl * underlying_socket;
 	SecureSocketImpl _impl;
 	bool             _lazyHandshake;
 

+ 54 - 54
contrib/libs/poco/NetSSL_OpenSSL/src/SecureSocketImpl.cpp

@@ -44,22 +44,22 @@ using Poco::Timespan;
 namespace Poco {
 namespace Net {
 
-struct RemainingTimeCounter 
-{ 
-	RemainingTimeCounter(Poco::Timespan& remainingTime_) : remainingTime(remainingTime_) {}; 
-	~RemainingTimeCounter() 
-	{ 
-		Poco::Timestamp end; 
-		Poco::Timespan waited = end - start; 
-		if (waited < remainingTime) 
-			remainingTime -= waited; 
-		else 
-			remainingTime = 0; 
-	} 
-private: 
-	Poco::Timespan& remainingTime; 
-	Poco::Timestamp start; 
-}; 
+struct RemainingTimeCounter
+{
+	RemainingTimeCounter(Poco::Timespan& remainingTime_) : remainingTime(remainingTime_) {};
+	~RemainingTimeCounter()
+	{
+		Poco::Timestamp end;
+		Poco::Timespan waited = end - start;
+		if (waited < remainingTime)
+			remainingTime -= waited;
+		else
+			remainingTime = 0;
+	}
+private:
+	Poco::Timespan& remainingTime;
+	Poco::Timestamp start;
+};
 
 SecureSocketImpl::SecureSocketImpl(Poco::AutoPtr<SocketImpl> pSocketImpl, Context::Ptr pContext):
 	_pSSL(0),
@@ -135,8 +135,8 @@ void SecureSocketImpl::connect(const SocketAddress& address, const Poco::Timespa
 	poco_assert (!_pSSL);
 
 	_pSocket->connect(address, timeout);
-	//FIXME it updates timeouts of SecureStreamSocketImpl::underlying_socket it does not update timeouts of SecureStreamSocketImpl 
-	//However, timeouts of SecureStreamSocketImpl are not used in connectSSL() and previous settings are restored after 
+	//FIXME it updates timeouts of SecureStreamSocketImpl::underlying_socket it does not update timeouts of SecureStreamSocketImpl
+	//However, timeouts of SecureStreamSocketImpl are not used in connectSSL() and previous settings are restored after
 	Poco::Timespan receiveTimeout = _pSocket->getReceiveTimeout();
 	Poco::Timespan sendTimeout = _pSocket->getSendTimeout();
 	_pSocket->setReceiveTimeout(timeout);
@@ -191,14 +191,14 @@ void SecureSocketImpl::connectSSL(bool performHandshake)
 	{
 		if (performHandshake && _pSocket->getBlocking())
 		{
-			int ret; 
-			Poco::Timespan remaining_time = getMaxTimeout(); 
-			do 
-			{ 
-				RemainingTimeCounter counter(remaining_time); 
-				ret = SSL_connect(_pSSL); 
-			} 
-			while (mustRetry(ret, remaining_time)); 
+			int ret;
+			Poco::Timespan remaining_time = getMaxTimeout();
+			do
+			{
+				RemainingTimeCounter counter(remaining_time);
+				ret = SSL_connect(_pSSL);
+			}
+			while (mustRetry(ret, remaining_time));
 			handleError(ret);
 			verifyPeerCertificate();
 		}
@@ -289,14 +289,14 @@ int SecureSocketImpl::sendBytes(const void* buffer, int length, int /*flags*/)
 		else
 			return rc;
 	}
- 
-	Poco::Timespan remaining_time = getMaxTimeout(); 
+
+	Poco::Timespan remaining_time = getMaxTimeout();
 	do
 	{
-		RemainingTimeCounter counter(remaining_time); 
+		RemainingTimeCounter counter(remaining_time);
 		rc = SSL_write(_pSSL, buffer, length);
 	}
-	while (mustRetry(rc, remaining_time)); 
+	while (mustRetry(rc, remaining_time));
 	if (rc <= 0)
 	{
 		rc = handleError(rc);
@@ -320,17 +320,17 @@ int SecureSocketImpl::receiveBytes(void* buffer, int length, int /*flags*/)
 		else
 			return rc;
 	}
- 
-	Poco::Timespan remaining_time = getMaxTimeout(); 
+
+	Poco::Timespan remaining_time = getMaxTimeout();
 	do
 	{
-		/// SSL record may consist of several TCP packets, 
-		/// so thread can be blocked on recv/send and epoll_wait several times 
-		/// until SSL_read will return rc > 0. Let's use our own time counter. 
-		RemainingTimeCounter counter(remaining_time); 
+		/// SSL record may consist of several TCP packets,
+		/// so thread can be blocked on recv/send and epoll_wait several times
+		/// until SSL_read will return rc > 0. Let's use our own time counter.
+		RemainingTimeCounter counter(remaining_time);
 		rc = SSL_read(_pSSL, buffer, length);
 	}
-	while (mustRetry(rc, remaining_time)); 
+	while (mustRetry(rc, remaining_time));
 	if (rc <= 0)
 	{
 		return handleError(rc);
@@ -353,13 +353,13 @@ int SecureSocketImpl::completeHandshake()
 	poco_check_ptr (_pSSL);
 
 	int rc;
-	Poco::Timespan remaining_time = getMaxTimeout(); 
+	Poco::Timespan remaining_time = getMaxTimeout();
 	do
 	{
-		RemainingTimeCounter counter(remaining_time); 
+		RemainingTimeCounter counter(remaining_time);
 		rc = SSL_do_handshake(_pSSL);
 	}
-	while (mustRetry(rc, remaining_time)); 
+	while (mustRetry(rc, remaining_time));
 	if (rc <= 0)
 	{
 		return handleError(rc);
@@ -430,16 +430,16 @@ X509* SecureSocketImpl::peerCertificate() const
 		return 0;
 }
 
-Poco::Timespan SecureSocketImpl::getMaxTimeout() 
-{ 
-	Poco::Timespan remaining_time = _pSocket->getReceiveTimeout(); 
-	Poco::Timespan send_timeout = _pSocket->getSendTimeout(); 
-	if (remaining_time < send_timeout) 
-		remaining_time = send_timeout; 
-	return remaining_time; 
-} 
+Poco::Timespan SecureSocketImpl::getMaxTimeout()
+{
+	Poco::Timespan remaining_time = _pSocket->getReceiveTimeout();
+	Poco::Timespan send_timeout = _pSocket->getSendTimeout();
+	if (remaining_time < send_timeout)
+		remaining_time = send_timeout;
+	return remaining_time;
+}
 
-bool SecureSocketImpl::mustRetry(int rc, Poco::Timespan& remaining_time) 
+bool SecureSocketImpl::mustRetry(int rc, Poco::Timespan& remaining_time)
 {
 	if (rc <= 0)
 	{
@@ -450,9 +450,9 @@ bool SecureSocketImpl::mustRetry(int rc, Poco::Timespan& remaining_time)
 		case SSL_ERROR_WANT_READ:
 			if (_pSocket->getBlocking())
 			{
-				/// Level-triggered mode of epoll_wait is used, so if SSL_read don't read all available data from socket, 
-				/// epoll_wait returns true without waiting for new data even if remaining_time == 0 
-				if (_pSocket->pollImpl(remaining_time, Poco::Net::Socket::SELECT_READ) && remaining_time != 0) 
+				/// Level-triggered mode of epoll_wait is used, so if SSL_read don't read all available data from socket,
+				/// epoll_wait returns true without waiting for new data even if remaining_time == 0
+				if (_pSocket->pollImpl(remaining_time, Poco::Net::Socket::SELECT_READ) && remaining_time != 0)
 					return true;
 				else
 					throw Poco::TimeoutException();
@@ -461,8 +461,8 @@ bool SecureSocketImpl::mustRetry(int rc, Poco::Timespan& remaining_time)
 		case SSL_ERROR_WANT_WRITE:
 			if (_pSocket->getBlocking())
 			{
-				/// The same as for SSL_ERROR_WANT_READ 
-				if (_pSocket->pollImpl(remaining_time, Poco::Net::Socket::SELECT_WRITE) && remaining_time != 0) 
+				/// The same as for SSL_ERROR_WANT_READ
+				if (_pSocket->pollImpl(remaining_time, Poco::Net::Socket::SELECT_WRITE) && remaining_time != 0)
 					return true;
 				else
 					throw Poco::TimeoutException();

+ 15 - 15
contrib/libs/poco/NetSSL_OpenSSL/src/SecureStreamSocketImpl.cpp

@@ -22,16 +22,16 @@ namespace Net {
 
 
 SecureStreamSocketImpl::SecureStreamSocketImpl(Context::Ptr pContext):
-    underlying_socket(new StreamSocketImpl), 
-	_impl(underlying_socket, pContext), 
+    underlying_socket(new StreamSocketImpl),
+	_impl(underlying_socket, pContext),
 	_lazyHandshake(false)
 {
 }
 
 
 SecureStreamSocketImpl::SecureStreamSocketImpl(StreamSocketImpl* pStreamSocket, Context::Ptr pContext):
-    underlying_socket(pStreamSocket), 
-	_impl(underlying_socket, pContext), 
+    underlying_socket(pStreamSocket),
+	_impl(underlying_socket, pContext),
 	_lazyHandshake(false)
 {
 	pStreamSocket->duplicate();
@@ -51,18 +51,18 @@ SecureStreamSocketImpl::~SecureStreamSocketImpl()
 	}
 }
 
-void SecureStreamSocketImpl::setSendTimeout(const Poco::Timespan& timeout) 
-{ 
-    underlying_socket->setSendTimeout(timeout); 
-    _sndTimeout = underlying_socket->getSendTimeout(); 
-} 
+void SecureStreamSocketImpl::setSendTimeout(const Poco::Timespan& timeout)
+{
+    underlying_socket->setSendTimeout(timeout);
+    _sndTimeout = underlying_socket->getSendTimeout();
+}
+
+void SecureStreamSocketImpl::setReceiveTimeout(const Poco::Timespan& timeout)
+{
+    underlying_socket->setReceiveTimeout(timeout);
+    _recvTimeout = underlying_socket->getReceiveTimeout();
+}
 
-void SecureStreamSocketImpl::setReceiveTimeout(const Poco::Timespan& timeout) 
-{ 
-    underlying_socket->setReceiveTimeout(timeout); 
-    _recvTimeout = underlying_socket->getReceiveTimeout(); 
-} 
- 
 SocketImpl* SecureStreamSocketImpl::acceptConnection(SocketAddress& /*clientAddr*/)
 {
 	throw Poco::InvalidAccessException("Cannot acceptConnection() on a SecureStreamSocketImpl");