From 03211e4f58b3626a5b129556844d7e55fd4cb533 Mon Sep 17 00:00:00 2001
From: afederici <ajf5@illinois.edu>
Date: Wed, 18 Nov 2020 21:39:15 -0600
Subject: [PATCH] bug fix

---
 src/Node.cpp      | 2 ++
 src/TcpSocket.cpp | 1 +
 src/Threads.cpp   | 1 +
 3 files changed, 4 insertions(+)

diff --git a/src/Node.cpp b/src/Node.cpp
index db8d4b0..ae531c8 100644
--- a/src/Node.cpp
+++ b/src/Node.cpp
@@ -882,6 +882,7 @@ void Node::handleTcpMessage()
 			}
 
 			case CHUNKACK: {
+				cout << "[CHUNKACK] receiving the put worked!" << endl
 				//IP, exec, start, temp, actual file, prefix
 				if (!isLeader) {
 					//forward to know that the file was put okay
@@ -924,6 +925,7 @@ void Node::handleTcpMessage()
 					tcpServent->sendMessage(leaderIP, TCPPORT, ackMsg.toString());
 					break;
 				}
+				cout << "[CHUNKACK] leader confirming the chunk was received" << endl;
 				vector<tuple<string,string>> temp;
 				for (auto &e : mapleSending[inMsg[0]]){
 					if (get<0>(e).compare(inMsg[4]) == 0){
diff --git a/src/TcpSocket.cpp b/src/TcpSocket.cpp
index 545d910..1a45482 100644
--- a/src/TcpSocket.cpp
+++ b/src/TcpSocket.cpp
@@ -149,6 +149,7 @@ void TcpSocket::sendLines(string ip, string port, string execfile, string readfi
     {
 		lineCounter++;
         if (lineCounter < start) continue;
+		else if (lineCounter == start) cout << "[CHUNK] starting to send at line " << lineCounter << endl;
 		if (lineCounter >= end) break;
 		if (send(sockfd, str.c_str(), strlen(str.c_str()), 0) == -1) {
 			perror("send");
diff --git a/src/Threads.cpp b/src/Threads.cpp
index 42d2f99..df5a71f 100644
--- a/src/Threads.cpp
+++ b/src/Threads.cpp
@@ -38,6 +38,7 @@ void *runTcpSender(void *tcpSocket)
 					//IP, exec, file, start, prefix, end
 					int start = stoi(msgSplit[3]);
 					int end = stoi(msgSplit[5]);
+					cout << "[CHUNK] sending : " << sdfsfilename << " from " << msgSplit[3] << " to " << msgSplit[5] << endl;
 					tcp->sendLines(nodeIP, TCPPORT, localfilename, sdfsfilename, msgSplit[4], start, end); //exec, file, start, end
 				}
 				else tcp->sendFile(nodeIP, TCPPORT, localfilename, sdfsfilename, remoteLocalfilename, overwrite);
-- 
GitLab