Added a workarround for the packet sending problem. This is not optimal, but seems to work fairly well.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1054 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2009-02-26 14:04:48 +00:00
parent 580123a232
commit 23a617dca4
2 changed files with 25 additions and 5 deletions

View File

@ -33,6 +33,7 @@
#include "util/rsnet.h"
#include "util/rsdebug.h"
#include <unistd.h>
#include <errno.h>
#include <openssl/err.h>
@ -1341,7 +1342,14 @@ int pqissl::accept(SSL *ssl, int fd, struct sockaddr_in foreign_addr) // initiat
int pqissl::senddata(void *data, int len)
{
int tmppktlen = SSL_write(ssl_connection, data, len);
int tmppktlen ;
int nbtries = 0 ;
#ifdef WIN32
while( (tmppktlen = SSL_write(ssl_connection, data, len)) == -1 && nbtries++ < 50) Sleep(300);
#else
while( (tmppktlen = SSL_write(ssl_connection, data, len)) == -1 && nbtries++ < 50) usleep(300000);
#endif
if (len != tmppktlen)
{
std::ostringstream out;
@ -1359,6 +1367,7 @@ int pqissl::senddata(void *data, int len)
out << std::endl;
out << "Socket Closed Abruptly.... Resetting PQIssl";
out << std::endl;
std::cerr << out.str() ;
rslog(RSL_ALERT, pqisslzone, out.str());
reset();
return -1;
@ -1368,6 +1377,7 @@ int pqissl::senddata(void *data, int len)
out << "SSL_write() SSL_ERROR_WANT_WRITE";
out << std::endl;
rslog(RSL_ALERT, pqisslzone, out.str());
std::cerr << out.str() ;
return -1;
}
else if (err == SSL_ERROR_WANT_READ)
@ -1375,6 +1385,7 @@ int pqissl::senddata(void *data, int len)
out << "SSL_write() SSL_ERROR_WANT_READ";
out << std::endl;
rslog(RSL_ALERT, pqisslzone, out.str());
std::cerr << out.str() ;
return -1;
}
else
@ -1385,6 +1396,7 @@ int pqissl::senddata(void *data, int len)
out << std::endl;
out << "\tResetting!";
out << std::endl;
std::cerr << out.str() ;
rslog(RSL_ALERT, pqisslzone, out.str());
reset();
@ -1442,6 +1454,7 @@ int pqissl::readdata(void *data, int len)
}
rslog(RSL_ALERT, pqisslzone, out.str());
std::cerr << out.str() << std::endl ;
return 0;
}
@ -1454,6 +1467,7 @@ int pqissl::readdata(void *data, int len)
out << std::endl;
rslog(RSL_ALERT, pqisslzone, out.str());
reset();
std::cerr << out.str() << std::endl ;
return -1;
}
else if (error == SSL_ERROR_WANT_WRITE)
@ -1461,6 +1475,7 @@ int pqissl::readdata(void *data, int len)
out << "SSL_read() SSL_ERROR_WANT_WRITE";
out << std::endl;
rslog(RSL_ALERT, pqisslzone, out.str());
std::cerr << out.str() << std::endl ;
return -1;
}
else if (error == SSL_ERROR_WANT_READ)
@ -1468,6 +1483,7 @@ int pqissl::readdata(void *data, int len)
out << "SSL_read() SSL_ERROR_WANT_READ";
out << std::endl;
rslog(RSL_ALERT, pqisslzone, out.str());
std::cerr << out.str() << std::endl ;
return -1;
}
else
@ -1476,6 +1492,7 @@ int pqissl::readdata(void *data, int len)
out << std::endl;
out << "\tResetting!";
rslog(RSL_ALERT, pqisslzone, out.str());
std::cerr << out.str() << std::endl ;
reset();
return -1;
}

View File

@ -436,12 +436,14 @@ int pqistreamer::handleoutgoing()
if (pkt_wpending)
{
std::ostringstream out;
out << "Sending Out Pkt!";
// write packet.
len = getRsItemSize(pkt_wpending);
out << "Sending Out Pkt of size " << len << " !";
if (len != (ss = bio->senddata(pkt_wpending, len)))
{
out << "Problems with Send Data!";
out << "Problems with Send Data! (only " << ss << " bytes sent" << ", total pkt size=" << len ;
out << std::endl;
std::cerr << out.str() ;
pqioutput(PQL_DEBUG_BASIC, pqistreamerzone, out.str());
@ -586,7 +588,7 @@ int pqistreamer::handleincoming()
std::ostringstream out;
out << "Error Completing Read (read ";
out << tmplen << "/" << extralen << ")" << std::endl;
// std::cerr << out.str() ;
std::cerr << out.str() ;
pqioutput(PQL_ALERT, pqistreamerzone, out.str());
pqiNotify *notify = getPqiNotify();
@ -606,7 +608,8 @@ int pqistreamer::handleincoming()
msgout << "\n";
std::string msg = msgout.str();
notify->AddSysMessage(0, RS_SYS_WARNING, title, msg);
std::cout << msg << std::endl ;
// notify->AddSysMessage(0, RS_SYS_WARNING, title, msg);
}
bio->close();
return -1;