Skip to content
Snippets Groups Projects
Commit 165b843d authored by ajf5's avatar ajf5
Browse files

bug fix

parent 1e65ffb4
No related branches found
No related tags found
No related merge requests found
......@@ -910,9 +910,11 @@ void Node::handleTcpMessage()
DIR *dp = nullptr;
if ((dp = opendir(".")) == nullptr) { cout << "tmp directory error " << match << endl; break; }
while ((entry = readdir(dp))){
cout << "[FILES] found " << entry->d_name << " looking to match " << to_string(matchLen) << " chars from " << match << endl;
if (strncmp(entry->d_name, match.c_str(), matchLen) == 0){
string searcher(entry->d_name);
string target = searcher.substr(4);
cout << "[CHUNKACK] found " << entry->d_name << endl;
Messages outMsg(DNS, nodeInformation.ip + "::" + to_string(hashRingPosition) + "::" + target + "::" + entry->d_name + "::" + to_string(-1) + "::" + to_string(-1) + "::" + target + "::" + "0");
cout << "[PUT] Got localfilename: " << entry->d_name << " with sdfsfilename: " << target << endl;
tcpServent->sendMessage(leaderIP, TCPPORT, outMsg.toString());
......
......@@ -55,7 +55,9 @@ void handlePipe(int file, string prefix) {
FILE *stream = fdopen(file, "r"); FILE *tmp;
char str[bufSize];
const char * delim = ",";
int lines = 0;
while ((fgets(str, bufSize, stream)) != NULL){
lines++;
std::string key(strtok(str, delim));
std::string val(strtok(NULL, delim));
string keyFile = "tmp-" + prefix + "-" + key;
......@@ -63,6 +65,7 @@ void handlePipe(int file, string prefix) {
tmp = fopen(keyFile.c_str(), "ab");
fwrite(write.c_str(),sizeof(char),write.size(),tmp);
fclose(tmp);
cout << "[PIPE] " << key << " to " << keyFile << endl;
}
fclose (stream);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment