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
431eb7bc
Commit
431eb7bc
authored
Sep 21, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/curl/{Global,Request}: migrate from DeferredMonitor to DeferEvent
parent
9df4853e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
24 deletions
+21
-24
Global.cxx
src/lib/curl/Global.cxx
+2
-8
Global.hxx
src/lib/curl/Global.hxx
+7
-6
Request.cxx
src/lib/curl/Request.cxx
+5
-4
Request.hxx
src/lib/curl/Request.hxx
+7
-6
No files found.
src/lib/curl/Global.cxx
View file @
431eb7bc
...
...
@@ -96,7 +96,7 @@ private:
};
CurlGlobal
::
CurlGlobal
(
EventLoop
&
_loop
)
:
DeferredMonitor
(
_loop
),
:
defer_read_info
(
_loop
,
BIND_THIS_METHOD
(
ReadInfo
)
),
timeout_event
(
_loop
,
BIND_THIS_METHOD
(
OnTimeout
))
{
multi
.
SetOption
(
CURLMOPT_SOCKETFUNCTION
,
CurlSocket
::
SocketFunction
);
...
...
@@ -264,11 +264,5 @@ CurlGlobal::SocketAction(curl_socket_t fd, int ev_bitmask)
"curl_multi_socket_action() failed: %s"
,
curl_multi_strerror
(
mcode
));
DeferredMonitor
::
Schedule
();
}
void
CurlGlobal
::
RunDeferred
()
{
ReadInfo
();
defer_read_info
.
Schedule
();
}
src/lib/curl/Global.hxx
View file @
431eb7bc
...
...
@@ -32,7 +32,7 @@
#include "Multi.hxx"
#include "event/TimerEvent.hxx"
#include "event/Defer
redMonitor
.hxx"
#include "event/Defer
Event
.hxx"
class
CurlSocket
;
class
CurlRequest
;
...
...
@@ -40,15 +40,19 @@ class CurlRequest;
/**
* Manager for the global CURLM object.
*/
class
CurlGlobal
final
:
DeferredMonitor
{
class
CurlGlobal
final
{
CurlMulti
multi
;
DeferEvent
defer_read_info
;
TimerEvent
timeout_event
;
public
:
explicit
CurlGlobal
(
EventLoop
&
_loop
);
using
DeferredMonitor
::
GetEventLoop
;
EventLoop
&
GetEventLoop
()
{
return
timeout_event
.
GetEventLoop
();
}
void
Add
(
CURL
*
easy
,
CurlRequest
&
request
);
void
Remove
(
CURL
*
easy
);
...
...
@@ -86,9 +90,6 @@ private:
/* callback for #timeout_event */
void
OnTimeout
();
/* virtual methods from class DeferredMonitor */
void
RunDeferred
()
override
;
};
#endif
src/lib/curl/Request.cxx
View file @
431eb7bc
...
...
@@ -46,8 +46,9 @@
CurlRequest
::
CurlRequest
(
CurlGlobal
&
_global
,
const
char
*
url
,
CurlResponseHandler
&
_handler
)
:
DeferredMonitor
(
_global
.
GetEventLoop
()),
global
(
_global
),
handler
(
_handler
)
:
global
(
_global
),
handler
(
_handler
),
postpone_error_event
(
global
.
GetEventLoop
(),
BIND_THIS_METHOD
(
OnPostponeError
))
{
error_buffer
[
0
]
=
0
;
...
...
@@ -241,7 +242,7 @@ CurlRequest::DataReceived(const void *ptr, size_t received_size)
/* move the CurlResponseHandler::OnError() call into a
"safe" stack frame */
postponed_error
=
std
::
current_exception
();
DeferredMonitor
::
Schedule
();
postpone_error_event
.
Schedule
();
return
CURL_WRITEFUNC_PAUSE
;
}
...
...
@@ -260,7 +261,7 @@ CurlRequest::WriteFunction(void *ptr, size_t size, size_t nmemb, void *stream)
}
void
CurlRequest
::
RunDeferred
()
CurlRequest
::
OnPostponeError
()
{
assert
(
postponed_error
);
...
...
src/lib/curl/Request.hxx
View file @
431eb7bc
...
...
@@ -31,7 +31,7 @@
#define CURL_REQUEST_HXX
#include "Easy.hxx"
#include "event/Defer
redMonitor
.hxx"
#include "event/Defer
Event
.hxx"
#include <map>
#include <string>
...
...
@@ -41,7 +41,7 @@ struct StringView;
class
CurlGlobal
;
class
CurlResponseHandler
;
class
CurlRequest
final
:
DeferredMonitor
{
class
CurlRequest
final
{
CurlGlobal
&
global
;
CurlResponseHandler
&
handler
;
...
...
@@ -60,13 +60,15 @@ class CurlRequest final : DeferredMonitor {
/**
* An exception caught by DataReceived(), which will be
* forwarded into a "safe" stack frame by
*
DeferredMonitor::RunDeferred()
. This works around the
*
#postpone_error_event
. This works around the
* problem that libcurl crashes if you call
* curl_multi_remove_handle() from within the WRITEFUNCTION
* (i.e. DataReceived()).
*/
std
::
exception_ptr
postponed_error
;
DeferEvent
postpone_error_event
;
/** error message provided by libcurl */
char
error_buffer
[
CURL_ERROR_SIZE
];
...
...
@@ -134,6 +136,8 @@ private:
void
HeaderFunction
(
StringView
s
);
void
OnPostponeError
();
/** called by curl when new data is available */
static
size_t
_HeaderFunction
(
void
*
ptr
,
size_t
size
,
size_t
nmemb
,
void
*
stream
);
...
...
@@ -141,9 +145,6 @@ private:
/** called by curl when new data is available */
static
size_t
WriteFunction
(
void
*
ptr
,
size_t
size
,
size_t
nmemb
,
void
*
stream
);
/* virtual methods from class DeferredMonitor */
void
RunDeferred
()
override
;
};
#endif
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