Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
key-value-store
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Samarth Joshi
key-value-store
Commits
77c47536
Commit
77c47536
authored
Oct 26, 2020
by
Roshan Rabinarayan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
t
parent
fd69388c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
6 deletions
+20
-6
KVServer.c
KVServer.c
+20
-6
server
server
+0
-0
No files found.
KVServer.c
View file @
77c47536
...
@@ -107,20 +107,34 @@ void *worker(void *args) {
...
@@ -107,20 +107,34 @@ void *worker(void *args) {
fflush
(
stdout
);
fflush
(
stdout
);
read
(
read_pipe
,
newfd
,
sizeof
(
newfd
));
read
(
read_pipe
,
newfd
,
sizeof
(
newfd
));
printf
(
"
\n
read %d
\n
"
,
*
newfd
);
printf
(
"
\n
read %d
\n
"
,
*
newfd
);
socketEvent
.
data
.
fd
=*
newfd
;
ev
.
data
.
fd
=*
newfd
;
if
(
epoll_ctl
(
epollfd
,
EPOLL_CTL_ADD
,
*
newfd
,
&
socketEvent
)
==
-
1
)
{
ev
.
events
=
EPOLLIN
;
if
(
epoll_ctl
(
epollfd
,
EPOLL_CTL_ADD
,
*
newfd
,
&
ev
)
==
-
1
)
{
perror
(
"epoll_ctl: read_pipe"
);
perror
(
"epoll_ctl: read_pipe"
);
printf
(
"haga
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
fflush
(
stdout
);
fflush
(
stdout
);
}
}
else
if
(
events
[
i
].
data
.
fd
==
*
newfd
)
{
else
{
struct
message
*
requestMessage
=
malloc
(
sizeof
(
struct
message
));
struct
message
*
requestMessage
=
malloc
(
sizeof
(
struct
message
));
read
(
*
newfd
,
requestMessage
,
sizeof
(
struct
message
));
read
(
events
[
i
].
data
.
fd
,
requestMessage
,
sizeof
(
struct
message
));
printf
(
"[Message Received from client]
\n
[[Status:%c]
\n
[Key:%s]
\n
[Value:%s]]"
,
requestMessage
->
status
,
requestMessage
->
key
,
requestMessage
->
value
);
if
(
requestMessage
->
status
==
EOF
)
{
ev
.
data
.
fd
=
events
[
i
].
data
.
fd
;
ev
.
events
=
EPOLLIN
;
epoll_ctl
(
epollfd
,
EPOLL_CTL_DEL
,
events
[
i
].
data
.
fd
,
&
ev
);
close
(
events
[
i
].
data
.
fd
);
}
else
{
printf
(
"[Message Received from client]
\n
[[Status:%c]
\n
[Key:%s]
\n
[Value:%s]]"
,
requestMessage
->
status
,
requestMessage
->
key
,
requestMessage
->
value
);
}
}
}
}
}
}
}
...
...
server
View file @
77c47536
No preview for this file type
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