Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
fail
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
E-EXK4 - Operating System Group
projects
fail
Commits
0534b503
Commit
0534b503
authored
11 years ago
by
Michael Lenz
Browse files
Options
Downloads
Plain Diff
Merge branch 'use_size_prefix-REMOVED'
parents
0a5e54e9
9c984b97
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/core/comm/SocketComm.cc
+31
-22
31 additions, 22 deletions
src/core/comm/SocketComm.cc
src/core/comm/SocketComm.hpp
+8
-2
8 additions, 2 deletions
src/core/comm/SocketComm.hpp
src/core/cpn/JobServer.cc
+1
-1
1 addition, 1 deletion
src/core/cpn/JobServer.cc
with
40 additions
and
25 deletions
src/core/comm/SocketComm.cc
+
31
−
22
View file @
0534b503
...
...
@@ -15,7 +15,6 @@ void SocketComm::init()
bool
SocketComm
::
sendMsg
(
int
sockfd
,
google
::
protobuf
::
Message
&
msg
)
{
#ifdef USE_SIZE_PREFIX
int
size
=
htonl
(
msg
.
ByteSize
());
std
::
string
buf
;
if
(
safe_write
(
sockfd
,
&
size
,
sizeof
(
size
))
==
-
1
...
...
@@ -23,35 +22,45 @@ bool SocketComm::sendMsg(int sockfd, google::protobuf::Message& msg)
||
safe_write
(
sockfd
,
buf
.
c_str
(),
buf
.
size
())
==
-
1
)
{
return
false
;
}
#else
char
c
=
0
;
if
(
!
msg
.
SerializeToFileDescriptor
(
sockfd
)
||
safe_write
(
sockfd
,
&
c
,
1
)
==
-
1
)
{
return
false
;
}
#endif
return
true
;
}
bool
SocketComm
::
rcvMsg
(
int
sockfd
,
google
::
protobuf
::
Message
&
msg
)
{
#ifdef USE_SIZE_PREFIX
int
size
;
if
(
safe_read
(
sockfd
,
&
size
,
sizeof
(
size
))
==
-
1
)
{
return
false
;
char
*
buf
;
int
bufsiz
;
if
((
buf
=
getBuf
(
sockfd
,
&
bufsiz
)))
{
std
::
string
st
(
buf
,
bufsiz
);
delete
[]
buf
;
return
msg
.
ParseFromString
(
st
);
}
return
false
;
}
bool
SocketComm
::
dropMsg
(
int
sockfd
)
{
char
*
buf
;
int
bufsiz
;
if
((
buf
=
getBuf
(
sockfd
,
&
bufsiz
)))
{
delete
[]
buf
;
return
true
;
}
size
=
ntohl
(
size
);
char
*
buf
=
new
char
[
size
];
if
(
safe_read
(
sockfd
,
buf
,
size
)
==
-
1
)
{
return
false
;
}
char
*
SocketComm
::
getBuf
(
int
sockfd
,
int
*
size
)
{
char
*
buf
;
if
(
safe_read
(
sockfd
,
size
,
sizeof
(
int
))
==
-
1
)
{
return
0
;
}
*
size
=
ntohl
(
*
size
);
buf
=
new
char
[
*
size
];
if
(
safe_read
(
sockfd
,
buf
,
*
size
)
==
-
1
)
{
delete
[]
buf
;
return
false
;
return
0
;
}
std
::
string
st
(
buf
,
size
);
delete
[]
buf
;
return
msg
.
ParseFromString
(
st
);
#else
return
msg
.
ParseFromFileDescriptor
(
sockfd
);
#endif
return
buf
;
}
ssize_t
SocketComm
::
safe_write
(
int
fd
,
const
void
*
buf
,
size_t
count
)
...
...
This diff is collapsed.
Click to expand it.
src/core/comm/SocketComm.hpp
+
8
−
2
View file @
0534b503
...
...
@@ -15,8 +15,6 @@
#include
<fstream>
#include
<google/protobuf/message.h>
#define USE_SIZE_PREFIX
namespace
fail
{
class
SocketComm
{
...
...
@@ -40,7 +38,15 @@ public:
*/
static
bool
rcvMsg
(
int
sockfd
,
google
::
protobuf
::
Message
&
msg
);
/**
* Receive Protobuf-generated message and just drop it
* @param sockfd open socket descriptor to read from
* \return false if message reception failed
*/
static
bool
dropMsg
(
int
sockfd
);
private:
static
char
*
getBuf
(
int
sockfd
,
int
*
size
);
static
ssize_t
safe_write
(
int
fd
,
const
void
*
buf
,
size_t
count
);
static
ssize_t
safe_read
(
int
fd
,
void
*
buf
,
size_t
count
);
};
...
...
This diff is collapsed.
Click to expand it.
src/core/cpn/JobServer.cc
+
1
−
1
View file @
0534b503
...
...
@@ -357,7 +357,7 @@ void CommThread::receiveExperimentResults(Minion& minion, FailControlMessage& ct
cout
<<
"[Server] Received another result for workload id ["
<<
ctrlmsg
.
workloadid
(
i
)
<<
"] -- ignored."
<<
endl
;
// TODO: Any need for error-handling here?
SocketComm
::
dropMsg
(
minion
.
getSocketDescriptor
());
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment