2010-02-15 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Removed ret == 0 checking for SSL_read(), SSL_write() and
	SSL_peek() because the checks are done in the caller.  In
	SocketBuffer::send(), throw exception if nothing could be written
	and socket error was not EWOULDBLOCK
	* src/SocketBuffer.cc
	* src/SocketCore.cc
pull/1/head
Tatsuhiro Tsujikawa 2010-02-15 13:02:14 +00:00
parent a6a174a0b2
commit 3842161f9b
3 changed files with 18 additions and 18 deletions

View File

@ -1,3 +1,12 @@
2010-02-15 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Removed ret == 0 checking for SSL_read(), SSL_write() and
SSL_peek() because the checks are done in the caller. In
SocketBuffer::send(), throw exception if nothing could be written
and socket error was not EWOULDBLOCK
* src/SocketBuffer.cc
* src/SocketCore.cc
2010-02-15 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed error code handling so that it can handle Winsock2 error

View File

@ -33,9 +33,14 @@
*/
/* copyright --> */
#include "SocketBuffer.h"
#include "SocketCore.h"
#include <cassert>
#include "SocketCore.h"
#include "DlAbortEx.h"
#include "message.h"
#include "StringFormat.h"
namespace aria2 {
SocketBuffer::SocketBuffer(const SharedHandle<SocketCore>& socket):
@ -61,6 +66,9 @@ ssize_t SocketBuffer::send()
}
ssize_t len = _socket->writeData(_sendbuf.c_str(),
_sendbuf.size());
if(len == 0 && !_socket->wantRead() && !_socket->wantWrite()) {
throw DL_ABORT_EX(StringFormat(EX_SOCKET_SEND, "Connection closed.").str());
}
_sendbuf.erase(0, len);
return len;
}

View File

@ -624,11 +624,6 @@ ssize_t SocketCore::writeData(const char* data, size_t len)
} else {
#ifdef HAVE_LIBSSL
ret = SSL_write(ssl, data, len);
if(ret == 0) {
throw DL_RETRY_EX
(StringFormat
(EX_SOCKET_SEND, ERR_error_string(SSL_get_error(ssl, ret), 0)).str());
}
if(ret < 0) {
ret = sslHandleEAGAIN(ret);
}
@ -675,13 +670,6 @@ void SocketCore::readData(char* data, size_t& len)
// for SSL
// TODO handling len == 0 case required
ret = SSL_read(ssl, data, len);
if(ret == 0) {
// TODO Check this is really an error with SSL_get_error().
// Or not throw exception and just return 0
throw DL_RETRY_EX
(StringFormat
(EX_SOCKET_RECV, ERR_error_string(SSL_get_error(ssl, ret), 0)).str());
}
if(ret < 0) {
ret = sslHandleEAGAIN(ret);
}
@ -728,11 +716,6 @@ void SocketCore::peekData(char* data, size_t& len)
// for SSL
// TODO handling len == 0 case required
ret = SSL_peek(ssl, data, len);
if(ret == 0) {
throw DL_RETRY_EX
(StringFormat(EX_SOCKET_PEEK,
ERR_error_string(SSL_get_error(ssl, ret), 0)).str());
}
if(ret < 0) {
ret = sslHandleEAGAIN(ret);
}