Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cta
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
Harbor 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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dCache
cta
Commits
a9307909
Commit
a9307909
authored
10 years ago
by
Giuseppe Lo Presti
Browse files
Options
Downloads
Patches
Plain Diff
Added an errorcode argument to mover_open_file() plus some cosmetic changes
parent
f22ae7af
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
movers/moveropenclose.cpp
+12
-15
12 additions, 15 deletions
movers/moveropenclose.cpp
movers/moveropenclose.h
+11
-8
11 additions, 8 deletions
movers/moveropenclose.h
with
23 additions
and
23 deletions
movers/moveropenclose.cpp
+
12
−
15
View file @
a9307909
...
...
@@ -37,7 +37,7 @@
extern
"C"
{
/* internal function to connect to the diskmanager */
int
connect
_to_d
iskmanager
(
const
int
port
)
{
int
connect
ToD
iskmanager
(
const
int
port
)
{
// connect and send data
int
sockfd
=
0
;
if
((
sockfd
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
))
<
0
)
{
...
...
@@ -55,7 +55,7 @@ extern "C" {
/* internal function to parse the answer from the diskmanager */
void
parse
_a
nswer
(
const
int
sockfd
,
int
*
rc
,
char
**
errormsg
)
{
void
parse
A
nswer
(
const
int
sockfd
,
int
*
rc
,
char
**
errormsg
)
{
// synchronously read answer back from sockfd until \n
// Format is <returnCode> [<error message>]\n
int
n
=
0
;
...
...
@@ -82,42 +82,40 @@ extern "C" {
}
int
mover_open_file
(
const
int
port
,
const
char
*
transferMetaData
,
char
**
errormsg
)
{
int
rc
=
0
;
int
mover_open_file
(
const
int
port
,
const
char
*
transferMetaData
,
int
*
errorcode
,
char
**
errormsg
)
{
*
errormsg
=
NULL
;
try
{
/* Prepare open message. Protocol:
OPEN <transferMetaData>
OPEN
<errorCode>
<transferMetaData>
where the latter is a tuple:
(<isWriteFlag>, <tident>, <transferType>, <physicalPath> [, transferId])
*/
std
::
ostringstream
writeBuf
;
writeBuf
<<
"OPEN "
<<
transferMetaData
;
writeBuf
<<
"OPEN "
<<
*
errorcode
<<
" "
<<
transferMetaData
;
try
{
int
sockfd
=
0
,
n
=
0
;
// connect and send data
sockfd
=
connect
_to_d
iskmanager
(
port
);
sockfd
=
connect
ToD
iskmanager
(
port
);
n
=
write
(
sockfd
,
writeBuf
.
str
().
c_str
(),
writeBuf
.
str
().
length
());
// process result
if
(
n
!=
(
int
)
writeBuf
.
str
().
length
())
{
throw
std
::
runtime_error
(
"Failed to send OPEN message"
);
}
// synchronously read and parse answer
parse
_a
nswer
(
sockfd
,
&
rc
,
errormsg
);
parse
A
nswer
(
sockfd
,
errorcode
,
errormsg
);
}
catch
(
std
::
exception
&
e
)
{
// report any exception to the caller
rc
=
SEINTERNAL
;
*
errorcode
=
SEINTERNAL
;
*
errormsg
=
strdup
(
e
.
what
());
}
}
catch
(...)
{
// this is to avoid core dumps on standard exceptions
rc
=
SEINTERNAL
;
*
errorcode
=
SEINTERNAL
;
*
errormsg
=
strdup
(
"mover_open_file: caught general exception"
);
}
return
rc
;
return
*
errorcode
;
}
...
...
@@ -139,14 +137,13 @@ extern "C" {
try
{
int
sockfd
=
0
,
n
=
0
;
// connect and send data
sockfd
=
connect
_to_d
iskmanager
(
port
);
sockfd
=
connect
ToD
iskmanager
(
port
);
n
=
write
(
sockfd
,
writeBuf
.
str
().
c_str
(),
writeBuf
.
str
().
length
());
// process result
if
(
n
!=
(
int
)
writeBuf
.
str
().
length
())
{
throw
std
::
runtime_error
(
"Failed to send CLOSE message"
);
}
// synchronously read and parse answer
parse
_a
nswer
(
sockfd
,
errorcode
,
errormsg
);
parse
A
nswer
(
sockfd
,
errorcode
,
errormsg
);
}
catch
(
std
::
exception
&
e
)
{
// report any exception to the caller
...
...
This diff is collapsed.
Click to expand it.
movers/moveropenclose.h
+
11
−
8
View file @
a9307909
...
...
@@ -42,24 +42,27 @@ extern "C" {
* where tident has the format: username.clientPid:fd@clientHost
* and transferType is one of Tape, User, D2DUser, D2DInternal, D2DDraining, D2DBalance
* and transferId is missing for non-user transfers
* errorcode an error code to be passed in case of a failure; it may be filled
with a non-zero value when the operation fails
* errormsg a pointer to a buffer for the error message if the operation failed
*
* The return value is 0 for success, SETIMEDOUT if the slot had timed out meanwhile
* or SEINTERNAL for any other error.
*/
int
mover_open_file
(
const
int
port
,
const
char
*
transferMetaData
,
char
**
errormsg
);
int
mover_open_file
(
const
int
port
,
const
char
*
transferMetaData
,
int
*
errorcode
,
char
**
errormsg
);
/**
* mover_close_file allows a mover to close a CASTOR file after a transfer.
* It connects to the diskmanagerd daemon and synchronously wait for the response.
*
* port the port to which to connect
* transferUuid the UUID of the current transfer, aka the subRequest id
* filesize the size of the file (relevant only on Put requests)
* cksumtype the type of checksum (relevant only on Put requests)
* cksumvalue the hexadecimal value of the checksum (relevant only on Put requests)
* errorcode an error code to be passed in case of failure
* errormsg a pointer to a buffer for the error message if the operation failed
* port the port to which to connect
* transferUuid the UUID of the current transfer, aka the subRequest id
* filesize the size of the file (relevant only on Put requests)
* cksumtype the type of checksum (relevant only on Put requests)
* cksumvalue the hexadecimal value of the checksum (relevant only on Put requests)
* errorcode an error code to be passed in case of a failure; it may be filled
with a non-zero value when the operation fails
* errormsg a pointer to a buffer for the error message if the operation failed
*
* errorcode and errormsg are then populated with the result of the operation:
* if errorcode == 0 the operation was successful, otherwise errormsg contains
...
...
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