← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 3182: fix errno calls

 

------------------------------------------------------------
revno: 3182
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Thu 2013-01-24 00:33:50 +0100
message:
  fix errno calls
modified:
  dcpp/SSLSocket.cpp
  dcpp/Socket.cpp
  dcpp/Socket.h


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dcpp/SSLSocket.cpp'
--- dcpp/SSLSocket.cpp	2013-01-21 18:43:04 +0000
+++ dcpp/SSLSocket.cpp	2013-01-23 23:33:50 +0000
@@ -159,9 +159,10 @@
 				auto sys_err = ERR_get_error();
 				if(sys_err == 0) {
 					if(ret == 0) {
+						dcdebug("TLS error: call ret = %d, SSL_get_error = %d, ERR_get_error = %d\n", ret, err, sys_err);
 						throw SSLSocketException(_("TLS error"));
 					}
-					sys_err = ::GetLastError();
+					sys_err = getLastError();
 				}
 				throw SSLSocketException(sys_err);
 			}

=== modified file 'dcpp/Socket.cpp'
--- dcpp/Socket.cpp	2013-01-18 21:28:38 +0000
+++ dcpp/Socket.cpp	2013-01-23 23:33:50 +0000
@@ -47,8 +47,6 @@
 
 #ifdef _WIN32
 
-inline int getLastError() { return ::WSAGetLastError(); }
-
 template<typename F>
 inline auto check(F f, bool blockOk = false) -> decltype(f()) {
 	for(;;) {
@@ -57,7 +55,7 @@
 			return ret;
 		}
 
-		auto error = getLastError();
+		auto error = Socket::getLastError();
 		if(blockOk && error == WSAEWOULDBLOCK) {
 			return static_cast<decltype(ret)>(-1);
 		}
@@ -75,8 +73,6 @@
 
 #else
 
-inline int getLastError() { return errno; }
-
 template<typename F>
 inline auto check(F f, bool blockOk = false) -> decltype(f()) {
 	for(;;) {
@@ -85,7 +81,7 @@
 			return ret;
 		}
 
-		auto error = getLastError();
+		auto error = Socket::getLastError();
 		if(blockOk && (error == EWOULDBLOCK || error == ENOBUFS || error == EINPROGRESS || error == EAGAIN)) {
 			return -1;
 		}
@@ -178,6 +174,8 @@
 	sock = s;
 }
 
+int Socket::getLastError() { return ::WSAGetLastError(); }
+
 #else
 
 void SocketHandle::reset(socket_t s) {
@@ -188,6 +186,8 @@
 	sock = s;
 }
 
+int Socket::getLastError() { return errno; }
+
 #endif
 
 Socket::Stats Socket::stats = { 0, 0 };

=== modified file 'dcpp/Socket.h'
--- dcpp/Socket.h	2013-01-18 21:28:38 +0000
+++ dcpp/Socket.h	2013-01-23 23:33:50 +0000
@@ -180,6 +180,8 @@
 	/** When socks settings are updated, this has to be called... */
 	static void socksUpdated();
 
+	static inline int getLastError();
+
 	GETSET(string, ip, Ip);
 	GETSET(string, localIp4, LocalIp4);
 	GETSET(string, localIp6, LocalIp6);
@@ -209,6 +211,7 @@
 
 	static addr udpAddr;
 	static socklen_t udpAddrLen;
+
 private:
 	void socksAuth(uint32_t timeout);
 	socket_t setSock(socket_t s, int af);