Commit 52f39b5d authored by Sushant Mahajan's avatar Sushant Mahajan

removed uncalled functions and general housekeeping

parent 822803dd
...@@ -23,4 +23,4 @@ In this project we have implemented the following commands: ...@@ -23,4 +23,4 @@ In this project we have implemented the following commands:
All functions use locking mechanisms to provide concurrency. For performance reasons, if a user asks for a key and it is expired, the user is notified as not found and the key is deleted. All functions use locking mechanisms to provide concurrency. For performance reasons, if a user asks for a key and it is expired, the user is notified as not found and the key is deleted.
Note: Time taken to run all tesk cases 97.555 sec (150 concurrent clients sending 250 commands each) Note: Time taken to run all tesk cases 16.032 sec (150 concurrent clients sending 250 commands each)
...@@ -269,7 +269,7 @@ func parseInput(conn net.Conn, msg string, table *KeyValueStore, ch chan []byte) ...@@ -269,7 +269,7 @@ func parseInput(conn net.Conn, msg string, table *KeyValueStore, ch chan []byte)
return return
} }
if ver, ok, r := performSet(conn, tokens[1:len(tokens)], table, ch); ok { if ver, ok, r := performSet(conn, tokens[1:len(tokens)], table, ch); ok {
debug(table) //debug(table)
logger.Println(ver) logger.Println(ver)
if r { if r {
buffer.Reset() buffer.Reset()
...@@ -299,7 +299,7 @@ func parseInput(conn net.Conn, msg string, table *KeyValueStore, ch chan []byte) ...@@ -299,7 +299,7 @@ func parseInput(conn net.Conn, msg string, table *KeyValueStore, ch chan []byte)
buffer.WriteString(ERR_NOT_FOUND) buffer.WriteString(ERR_NOT_FOUND)
write(conn, buffer.String()) write(conn, buffer.String())
} }
debug(table) //debug(table)
case GETM: case GETM:
if isValid(GETM, tokens, conn) != 0 { if isValid(GETM, tokens, conn) != 0 {
...@@ -328,7 +328,7 @@ func parseInput(conn net.Conn, msg string, table *KeyValueStore, ch chan []byte) ...@@ -328,7 +328,7 @@ func parseInput(conn net.Conn, msg string, table *KeyValueStore, ch chan []byte)
buffer.WriteString(ERR_NOT_FOUND) buffer.WriteString(ERR_NOT_FOUND)
write(conn, buffer.String()) write(conn, buffer.String())
} }
debug(table) //debug(table)
case CAS: case CAS:
if isValid(CAS, tokens, conn) != 0 { if isValid(CAS, tokens, conn) != 0 {
...@@ -359,7 +359,7 @@ func parseInput(conn net.Conn, msg string, table *KeyValueStore, ch chan []byte) ...@@ -359,7 +359,7 @@ func parseInput(conn net.Conn, msg string, table *KeyValueStore, ch chan []byte)
} }
} }
} }
debug(table) //debug(table)
case DELETE: case DELETE:
if isValid(DELETE, tokens, conn) != 0 { if isValid(DELETE, tokens, conn) != 0 {
...@@ -370,7 +370,7 @@ func parseInput(conn net.Conn, msg string, table *KeyValueStore, ch chan []byte) ...@@ -370,7 +370,7 @@ func parseInput(conn net.Conn, msg string, table *KeyValueStore, ch chan []byte)
} else { } else {
write(conn, ERR_NOT_FOUND) write(conn, ERR_NOT_FOUND)
} }
debug(table) //debug(table)
default: default:
buffer.Reset() buffer.Reset()
...@@ -674,6 +674,8 @@ func main() { ...@@ -674,6 +674,8 @@ func main() {
//server will not call this, we'll call it from test cases to clear the map //server will not call this, we'll call it from test cases to clear the map
func ReInitServer() { func ReInitServer() {
defer table.Unlock()
table.Lock()
for key, _ := range table.dictionary { for key, _ := range table.dictionary {
delete(table.dictionary, key) delete(table.dictionary, key)
} }
......
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