Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
5163b1a6
Commit
5163b1a6
authored
Jan 07, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/curl/Request: require the caller to explicitly register the request
This allows constructing an instance in any thread, and register it inside the IOThread later.
parent
860aa9d6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
3 deletions
+44
-3
CurlInputPlugin.cxx
src/input/plugins/CurlInputPlugin.cxx
+2
-0
Request.cxx
src/lib/curl/Request.cxx
+22
-3
Request.hxx
src/lib/curl/Request.hxx
+20
-0
No files found.
src/input/plugins/CurlInputPlugin.cxx
View file @
5163b1a6
...
...
@@ -373,6 +373,8 @@ CurlInputStream::InitEasy()
request_headers
.
Clear
();
request_headers
.
Append
(
"Icy-Metadata: 1"
);
request
->
SetOption
(
CURLOPT_HTTPHEADER
,
request_headers
.
Get
());
request
->
Start
();
}
void
...
...
src/lib/curl/Request.cxx
View file @
5163b1a6
...
...
@@ -62,8 +62,6 @@ CurlRequest::CurlRequest(CurlGlobal &_global, const char *url,
easy
.
SetOption
(
CURLOPT_NOSIGNAL
,
1l
);
easy
.
SetOption
(
CURLOPT_CONNECTTIMEOUT
,
10l
);
easy
.
SetOption
(
CURLOPT_URL
,
url
);
global
.
Add
(
easy
.
Get
(),
*
this
);
}
CurlRequest
::~
CurlRequest
()
...
...
@@ -72,18 +70,39 @@ CurlRequest::~CurlRequest()
}
void
CurlRequest
::
Start
()
{
assert
(
!
registered
);
global
.
Add
(
easy
.
Get
(),
*
this
);
registered
=
true
;
}
void
CurlRequest
::
Stop
()
{
assert
(
registered
);
global
.
Remove
(
easy
.
Get
());
registered
=
false
;
}
void
CurlRequest
::
FreeEasy
()
{
if
(
!
easy
)
return
;
global
.
Remove
(
easy
.
Get
());
if
(
registered
)
Stop
();
easy
=
nullptr
;
}
void
CurlRequest
::
Resume
()
{
assert
(
registered
);
curl_easy_pause
(
easy
.
Get
(),
CURLPAUSE_CONT
);
if
(
IsCurlOlderThan
(
0x072000
))
...
...
src/lib/curl/Request.hxx
View file @
5163b1a6
...
...
@@ -58,7 +58,12 @@ class CurlRequest {
/** error message provided by libcurl */
char
error_buffer
[
CURL_ERROR_SIZE
];
bool
registered
=
false
;
public
:
/**
* To start sending the request, call Start().
*/
CurlRequest
(
CurlGlobal
&
_global
,
const
char
*
url
,
CurlResponseHandler
&
_handler
);
~
CurlRequest
();
...
...
@@ -66,6 +71,21 @@ public:
CurlRequest
(
const
CurlRequest
&
)
=
delete
;
CurlRequest
&
operator
=
(
const
CurlRequest
&
)
=
delete
;
/**
* Register this request via CurlGlobal::Add(), which starts
* the request.
*
* This method must be called in the event loop thread.
*/
void
Start
();
/**
* Unregister this request via CurlGlobal::Remove().
*
* This method must be called in the event loop thread.
*/
void
Stop
();
CURL
*
Get
()
{
return
easy
.
Get
();
}
...
...
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