Commit 9cee4e2d authored by mayankkakad's avatar mayankkakad

errors rectified

parent 731414cf
...@@ -330,6 +330,11 @@ public: ...@@ -330,6 +330,11 @@ public:
cout << endl; cout << endl;
} }
int hash(string s)
{
return (((int)s.at(0)) << 8) + ((int)s.at(1));
}
string getKeyValuePairs(int id) string getKeyValuePairs(int id)
{ {
unordered_map<string, string> flush; unordered_map<string, string> flush;
...@@ -379,15 +384,9 @@ public: ...@@ -379,15 +384,9 @@ public:
closedir(dirFile); closedir(dirFile);
} }
Node *temp = head->next; for(int i=0;i<=curr_pos;i++)
while (temp->next) if(hash(cacheHeap[i]->key)<=id)
{ flush[cacheHeap[i]->key]=cacheHeap[i]->value;
if (hash(temp->key) <= id)
{
flush[temp->key] = temp->payload;
}
temp = temp->next;
}
unordered_map<string, string>::iterator itr; unordered_map<string, string>::iterator itr;
for (itr = flush.begin(); itr != flush.end(); itr++) for (itr = flush.begin(); itr != flush.end(); itr++)
......
...@@ -186,7 +186,13 @@ private: ...@@ -186,7 +186,13 @@ private:
RequestType reqType; RequestType reqType;
}; };
void signalHandler(int signum) {
remove(SERVERS);
exit(0);
}
int main(int argc,char **argv) { int main(int argc,char **argv) {
signal(SIGINT, signalHandler);
srand(time(0)); srand(time(0));
string server_address("0.0.0.0:1234"); string server_address("0.0.0.0:1234");
builder.AddListeningPort(server_address, grpc::InsecureServerCredentials()); builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment