Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pa4
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nilesh Jagdish
pa4
Commits
3aca97f5
Commit
3aca97f5
authored
Nov 10, 2020
by
Saikumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modified by sai
parent
acf37be8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
12 deletions
+13
-12
Makefile
Makefile
+1
-1
cache.cpp
cache.cpp
+3
-2
client.c
client.c
+5
-5
server.cpp
server.cpp
+4
-4
No files found.
Makefile
View file @
3aca97f5
...
...
@@ -25,4 +25,4 @@ server:all
./server_s
client
:
./client_c 127.1.1.
3
20000
./client_c 127.1.1.
2
20000
cache.cpp
View file @
3aca97f5
...
...
@@ -4,7 +4,7 @@
#include <unordered_map>
#include <string>
#include <cstdlib>
#include "cs_thread.h"
//
#include "cs_thread.h"
#include "cache.h"
#include "storage.h"
using
namespace
std
;
...
...
@@ -112,6 +112,7 @@ string GET(string key) {
// //uncLock
// }
// return value;
return
"ERROR"
;
}
return
ans
;
...
...
@@ -119,7 +120,7 @@ string GET(string key) {
}
string
PUT
(
string
key
,
string
value
)
{
cout
<<
"PUT started"
<<
endl
;
//
cout << "PUT started" << endl;
pthread_mutex_lock
(
&
cLock
);
string
ans
=
search
(
key
);
if
(
ans
==
""
)
{
...
...
client.c
View file @
3aca97f5
...
...
@@ -83,7 +83,7 @@ void sendToServer(int sockfd) {
}
int
GET
(
char
*
key
,
char
*
request
)
{
printf
(
"GET called!
\n
"
);
//
printf("GET called!\n");
// char request[513];
memset
(
request
,
'0'
,
513
);
request
[
0
]
=
'1'
;
...
...
@@ -93,19 +93,19 @@ int GET(char* key, char *request) {
}
int
PUT
(
char
*
key
,
char
*
value
,
char
*
request
)
{
printf
(
"PUT called!
\n
"
);
//
printf("PUT called!\n");
// char request[513];
memset
(
request
,
'0'
,
513
);
request
[
0
]
=
'2'
;
// memcpy(request+1, key, strlen(key));
memcpy
(
request
+
257
-
strlen
(
key
),
key
,
strlen
(
key
));
memcpy
(
request
+
513
-
strlen
(
value
),
value
,
strlen
(
value
));
printf
(
"key at index: %ld
\n
"
,
257
-
strlen
(
key
));
printf
(
"value at index: %ld
\n
"
,
513
-
strlen
(
value
));
//
printf("key at index: %ld\n", 257-strlen(key));
//
printf("value at index: %ld\n", 513-strlen(value));
}
int
DELETE
(
char
*
key
,
char
*
request
)
{
// char request[513];
printf
(
"DELETE called!
\n
"
);
//
printf("DELETE called!\n");
memset
(
request
,
'0'
,
513
);
request
[
0
]
=
'3'
;
// memcpy(request+1, key, strlen(key));
...
...
server.cpp
View file @
3aca97f5
...
...
@@ -8,7 +8,7 @@
#include <pthread.h>
#include <stdlib.h>
#include "cache.h"
#include "cs_thread.h"
//
#include "cs_thread.h"
using
namespace
std
;
// struct lock cLock;
...
...
@@ -52,7 +52,7 @@ void *respondToClient(void *args) {
string
key_string
,
value_string
;
switch
(
todo
)
{
case
'1'
:
printf
(
"GET recvd
\n
"
);
//
printf("GET recvd\n");
// printf("Key: %s\n", key);
// j = search(key);
// printf("j=%d\n", j);
...
...
@@ -67,7 +67,7 @@ void *respondToClient(void *args) {
write
(
clientFd
,
converted_output
,
output
.
length
());
break
;
case
'2'
:
printf
(
"PUT recvd
\n
"
);
//
printf("PUT recvd\n");
// printf("Key: %s\n", key);
// printf("Value: %s\n", value);
key_string
=
key
;
...
...
@@ -80,7 +80,7 @@ void *respondToClient(void *args) {
write
(
clientFd
,
converted_output
,
output
.
length
());
break
;
case
'3'
:
printf
(
"DELETE recvd
\n
"
);
//
printf("DELETE recvd\n");
// printf("Key: %s\n", key);
key_string
=
key
;
// pthread_mutex_lock(&cLock);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment