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
2660d560
Commit
2660d560
authored
7 years ago
by
Michael Davis
Browse files
Options
Downloads
Patches
Plain Diff
[XrdSsi] Adds processing of standard responses
Handling of multi-block responses and streaming is not yet implemented.
parent
954af6ce
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/XrdSsiPbRequest.h
+38
-34
38 additions, 34 deletions
frontend/XrdSsiPbRequest.h
frontend/test_client.cpp
+11
-0
11 additions, 0 deletions
frontend/test_client.cpp
with
49 additions
and
34 deletions
frontend/XrdSsiPbRequest.h
+
38
−
34
View file @
2660d560
...
...
@@ -32,10 +32,6 @@ public:
std
::
cerr
<<
" Response buffer size = "
<<
m_response_bufsize
<<
std
::
endl
;
std
::
cerr
<<
" Response timeout = "
<<
timeout
<<
std
::
endl
;
// Allocate response buffer
m_response_bufptr
=
new
char
[
m_response_bufsize
];
// Set response timeout
SetTimeOut
(
timeout
);
...
...
@@ -43,8 +39,6 @@ public:
virtual
~
XrdSsiPbRequest
()
{
std
::
cerr
<<
"Deleting XrdSsiPbRequest object"
<<
std
::
endl
;
delete
[]
m_response_bufptr
;
}
// It is up to the implementation to create request data, save it in some manner, and provide it to
...
...
@@ -79,11 +73,9 @@ private:
const
char
*
m_request_bufptr
;
int
m_request_len
;
//
Pointer to the
Response buffer
// Response buffer
size
char
*
m_response_bufptr
;
int
m_response_bufsize
;
int
m_response_len
;
// Callbacks for each of the XRootD reply types
...
...
@@ -181,15 +173,17 @@ bool XrdSsiPbRequest<RequestType, ResponseType, MetadataType, AlertType>::Proces
}
}
// Handle messages
// Handle
response
messages
if
(
rInfo
.
rType
==
XrdSsiRespInfo
::
isData
)
{
static
const
int
myBSize
=
1024
;
// Allocate response buffer
char
*
myBuff
=
reinterpret_cast
<
char
*>
(
malloc
(
myBS
ize
))
;
char
*
response_bufptr
=
new
char
[
m_response_bufs
ize
]
;
GetResponseData
(
myBuff
,
myBSize
);
// Read the first chunk of data into the buffer, and pass it to ProcessResponseData()
GetResponseData
(
response_bufptr
,
m_response_bufsize
);
}
}
...
...
@@ -199,43 +193,53 @@ bool XrdSsiPbRequest<RequestType, ResponseType, MetadataType, AlertType>::Proces
template
<
typename
RequestType
,
typename
ResponseType
,
typename
MetadataType
,
typename
AlertType
>
XrdSsiRequest
::
PRD_Xeq
XrdSsiPbRequest
<
RequestType
,
ResponseType
,
MetadataType
,
AlertType
>::
ProcessResponseData
(
const
XrdSsiErrInfo
&
eInfo
,
char
*
myBuff
,
int
myBLen
,
bool
isLast
)
XrdSsiRequest
::
PRD_Xeq
XrdSsiPbRequest
<
RequestType
,
ResponseType
,
MetadataType
,
AlertType
>
::
ProcessResponseData
(
const
XrdSsiErrInfo
&
eInfo
,
char
*
response_bufptr
,
int
response_buflen
,
bool
is_last
)
{
using
namespace
std
;
// If we can't handle the queue at this time, return XrdSsiRequest::PRD_Hold;
// GetResponseData() above places the data in the allocated buffer, then calls this method with
// the buffer type and length
// The buffer length can be 0 if the response is metadata only
cerr
<<
"Called ProcessResponseData with myBLen = "
<<
myBLen
<<
", isLast = "
<<
isLast
<<
endl
;
if
(
response_buflen
!=
0
)
{
// How do we handle message boundaries for multi-block responses?
//
myBLen can be 0 if there is no relevant response or response is metadata only
//
Deserialize the response
// Process the response data of length myBLen placed in myBuff
// If there is more data then get it, else free the buffer and
// indicate to the framework that we are done
const
std
::
string
response_str
(
response_bufptr
,
response_buflen
);
if
(
!
isLast
)
{
static
const
int
myBSize
=
1024
;
ResponseType
response
;
// Get the next chunk of data (and call this method recursively ... could this cause a stack overflow ?)
if
(
response
.
ParseFromString
(
response_str
))
{
ResponseCallback
(
response
);
}
else
{
ErrorCallback
(
"response.ParseFromString() failed"
);
}
}
// If there is more data then get it, otherwise clean up
if
(
!
is_last
)
{
// Get the next chunk of data:
// Does this call this method recursively? Is there danger of a stack overflow?
GetResponseData
(
myBuff
,
myBS
ize
);
GetResponseData
(
response_bufptr
,
m_response_bufs
ize
);
}
else
{
myBuff
[
myBLen
]
=
0
;
cerr
<<
"Contents of myBuff = "
<<
myBuff
<<
endl
;
free
(
myBuff
);
delete
[]
response_bufptr
;
Finished
();
// Andy says you can now do a "delete this"
// Note that if request objects are uniform, you may want to re-use them instead
// of deleting them, to avoid the overhead of repeated object creation.
delete
this
;
// Note that if request objects are uniform, you may want to re-use them instead
// of deleting them, to avoid the overhead of repeated object creation.
Finished
();
delete
this
;
}
return
XrdSsiRequest
::
PRD_Normal
;
// Indicate what type of post-processing is required (normal in this case)
...
...
This diff is collapsed.
Click to expand it.
frontend/test_client.cpp
+
11
−
0
View file @
2660d560
...
...
@@ -31,6 +31,17 @@ void XrdSsiPbRequestCallback<xrdssi::test::Metadata>::operator()(const xrdssi::t
// Response callback
template
<
>
void
XrdSsiPbRequestCallback
<
xrdssi
::
test
::
Result
>::
operator
()(
const
xrdssi
::
test
::
Result
&
result
)
{
std
::
cout
<<
"ResponseCallback():"
<<
std
::
endl
;
std
::
cout
<<
MessageToJsonString
(
result
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
// Verify that the version of the Google Protocol Buffer library that we linked against is
...
...
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