Skip to content

Commit

Permalink
Another fix of my mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
NTX authored and NTX committed Mar 24, 2012
1 parent 927f209 commit 371bc3e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
34 changes: 18 additions & 16 deletions Protocol/FTP/FTP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void* SendData(void* args)
{
memset(data, 0, intConfigs[CONFIG_INT_MAX_DATA_SEGMENT_SIZE]);
sendingPart = file.readsome(data, intConfigs[CONFIG_INT_MAX_DATA_SEGMENT_SIZE]);
pSock->Send(data, sendingPart, 0 );
sendReturn = pSock->Send(data, sendingPart, 0 );
}
//protoLog->outDebug("Sended: %d bytes from %lu remaining: %lu", sendReturn, dataLength, dataLength - sended);
if (sendReturn == -1)
Expand Down Expand Up @@ -171,17 +171,33 @@ void* SendData(void* args)
FTP::SendCommandResponse(sock, 226);
if (session.abortTranfser)
FTP::SendCommandResponse(sock, 426);
if (fileName)
delete fileName;
delete data;
delete sendStat;
if (fileSending)
file.close();
session.DTPActive = false;
session.activeSend = NULL;
session.abortTranfser = false;
protoLog->outDebug("SendData End session: %s", session.DTPActive? "Data Tranfsering": "Data Tranfser Completed" );
protoLog->outDebug("SendData End session: %s Sent: %lu bytes", session.DTPActive? "Data Tranfsering": "Data Tranfser Completed", sended );
return NULL;
}

void FTP::SendOverDTP(int fd, char* data, size_t dataLength, const char* file)
{
if (!data && !file)
return;
SessionDataStruct& session = sessionData[fd];
Socket* sock = app->socketMgr->GetSocketByFd(fd);
protoLog->outDebug("Sending %d bytes over DTP to: %s:%d Mode: %s", dataLength, session.ip.ToChar(), session.port, session.isPassive? "Passive" : "Active");
SessionSendStruct* s = new SessionSendStruct(session, sock, data, dataLength, file);
session.DTPActive = true;
session.activeSend = s;
session.abortTranfser = false;
Thread::CreateThread(&SendData, (void*) s);
}

void* RecvData(void* args)
{
protoLog->outDebug("RecvData Begin");
Expand Down Expand Up @@ -314,20 +330,6 @@ void* RecvData(void* args)
return NULL;
}

void FTP::SendOverDTP(int fd, char* data, size_t dataLength, const char* file)
{
if (!data && !file)
return;
SessionDataStruct& session = sessionData[fd];
Socket* sock = app->socketMgr->GetSocketByFd(fd);
protoLog->outDebug("Sending %d bytes over DTP to: %s:%d Mode: %s", dataLength, session.ip.ToChar(), session.port, session.isPassive? "Passive" : "Active");
SessionSendStruct* s = new SessionSendStruct(session, sock, data, dataLength, file);
session.DTPActive = true;
session.activeSend = s;
session.abortTranfser = false;
Thread::CreateThread(&SendData, (void*) s);
}

void FTP::RecieveOverDTP(int fd, const char* fileName)
{
if (!fileName)
Expand Down
12 changes: 10 additions & 2 deletions Protocol/FTP/FTP.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,20 @@ struct SessionDataStruct
struct SessionSendStruct
{
SessionSendStruct(SessionDataStruct& sdata, Socket* sock, char* data, size_t length, const char* file = NULL):
s(sdata), so(sock), d(data), f(file), l(length) { }
s(sdata), so(sock), d(data), l(length)
{
if (file)
{
f = new char[strlen(file)+1];
memset(f, 0, strlen(file)+1);
memcpy(f, file, strlen(file));
}
}

SessionDataStruct& s;
Socket* so;
char* d;
const char* f;
char* f;
size_t l;
};

Expand Down
2 changes: 1 addition & 1 deletion Sockets/Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ int Socket::Recieve(BinnaryData &data, int flags)
bool _isIPv4(char* ip)
{
int Byte[4];
short pos[5]={-1, 0 ,0, 0, 0};
short pos[5]= {-1, 0 ,0, 0, 0};
if (strlen(ip) - 1 < 7)
return false;
if (strlen(ip) - 1 > 15)
Expand Down

0 comments on commit 371bc3e

Please sign in to comment.