[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 108/205: asiohiper: make sure socket is open in eve
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 108/205: asiohiper: make sure socket is open in event_cb |
Date: |
Thu, 20 Apr 2017 16:20:48 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to annotated tag gnurl-7.54.0
in repository gnurl.
commit 99d708a0165c1bbcbbcf65c96ecc9e62a9ad629a
Author: Edward Kimmel <address@hidden>
AuthorDate: Wed Mar 8 13:11:41 2017 -0500
asiohiper: make sure socket is open in event_cb
Send curl_socket_t to event_cb and make sure it hasn't been closed yet.
Closes https://github.com/curl/curl/pull/1318
---
docs/examples/asiohiper.cpp | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/docs/examples/asiohiper.cpp b/docs/examples/asiohiper.cpp
index ced4ef419..2ff0e6404 100644
--- a/docs/examples/asiohiper.cpp
+++ b/docs/examples/asiohiper.cpp
@@ -170,15 +170,19 @@ static void check_multi_info(GlobalInfo *g)
}
/* Called by asio when there is an action on a socket */
-static void event_cb(GlobalInfo *g, boost::asio::ip::tcp::socket *tcp_socket,
+static void event_cb(GlobalInfo *g, curl_socket_t s,
int action, const boost::system::error_code & error,
int *fdp)
{
fprintf(MSG_OUT, "\nevent_cb: action=%d", action);
+ if(socket_map.find(s) == socket_map.end()) {
+ fprintf(MSG_OUT, "\nevent_cb: socket already closed");
+ return;
+ }
+
/* make sure the event matches what are wanted */
if(*fdp == action || *fdp == CURL_POLL_INOUT) {
- curl_socket_t s = tcp_socket->native_handle();
CURLMcode rc;
if(error)
action = CURL_CSELECT_ERR;
@@ -197,14 +201,16 @@ static void event_cb(GlobalInfo *g,
boost::asio::ip::tcp::socket *tcp_socket,
* in curl_multi_socket_action(), so check them both */
if(!error && socket_map.find(s) != socket_map.end() &&
(*fdp == action || *fdp == CURL_POLL_INOUT)) {
+ boost::asio::ip::tcp::socket *tcp_socket = socket_map.find(s)->second;
+
if(action == CURL_POLL_IN) {
tcp_socket->async_read_some(boost::asio::null_buffers(),
- boost::bind(&event_cb, g, tcp_socket,
+ boost::bind(&event_cb, g, s,
action, _1, fdp));
}
if(action == CURL_POLL_OUT) {
tcp_socket->async_write_some(boost::asio::null_buffers(),
- boost::bind(&event_cb, g, tcp_socket,
+ boost::bind(&event_cb, g, s,
action, _1, fdp));
}
}
@@ -257,7 +263,7 @@ static void setsock(int *fdp, curl_socket_t s, CURL *e, int
act, int oldact,
fprintf(MSG_OUT, "\nwatching for socket to become readable");
if(oldact != CURL_POLL_IN && oldact != CURL_POLL_INOUT) {
tcp_socket->async_read_some(boost::asio::null_buffers(),
- boost::bind(&event_cb, g, tcp_socket,
+ boost::bind(&event_cb, g, s,
CURL_POLL_IN, _1, fdp));
}
}
@@ -265,7 +271,7 @@ static void setsock(int *fdp, curl_socket_t s, CURL *e, int
act, int oldact,
fprintf(MSG_OUT, "\nwatching for socket to become writable");
if(oldact != CURL_POLL_OUT && oldact != CURL_POLL_INOUT) {
tcp_socket->async_write_some(boost::asio::null_buffers(),
- boost::bind(&event_cb, g, tcp_socket,
+ boost::bind(&event_cb, g, s,
CURL_POLL_OUT, _1, fdp));
}
}
@@ -273,12 +279,12 @@ static void setsock(int *fdp, curl_socket_t s, CURL *e,
int act, int oldact,
fprintf(MSG_OUT, "\nwatching for socket to become readable & writable");
if(oldact != CURL_POLL_IN && oldact != CURL_POLL_INOUT) {
tcp_socket->async_read_some(boost::asio::null_buffers(),
- boost::bind(&event_cb, g, tcp_socket,
+ boost::bind(&event_cb, g, s,
CURL_POLL_IN, _1, fdp));
}
if(oldact != CURL_POLL_OUT && oldact != CURL_POLL_INOUT) {
tcp_socket->async_write_some(boost::asio::null_buffers(),
- boost::bind(&event_cb, g, tcp_socket,
+ boost::bind(&event_cb, g, s,
CURL_POLL_OUT, _1, fdp));
}
}
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnurl] 143/205: docs: Explain --fail-early does not imply --fail, (continued)
- [GNUnet-SVN] [gnurl] 143/205: docs: Explain --fail-early does not imply --fail, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 142/205: telnet: (win32) fix read callback return variable, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 169/205: gtls: fix compiler warning, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 152/205: hash: move key into hash struct to reduce mallocs, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 199/205: openssl: fix thread-safety bugs in error-handling, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 121/205: conncache: make hashkey avoid malloc, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 167/205: low_speed_limit: improved function for longer time periods, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 157/205: multi: fix queueing of pending easy handles, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 78/205: Improve code readbility, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 118/205: http: Fix proxy connection reuse with basic-auth, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 108/205: asiohiper: make sure socket is open in event_cb,
gnunet <=
- [GNUnet-SVN] [gnurl] 140/205: libcurl.def: removed, unused, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 182/205: openssl: fix this statement may fall through [-Wimplicit-fallthrough=], gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 48/205: insecure.d: clarify that this is for server connections, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 147/205: multi: make curl_multi_wait avoid malloc in the typical case, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 196/205: extern-scan.pl: strip trailing CR, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 174/205: vtls: fix unreferenced variable warnings, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 191/205: http2: fix handle leak in error path, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 24/205: fix some typos in the doc (#1306), gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 64/205: authneg: clear auth.multi flag at http_done, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 104/205: tests/README: mention nroff for --manual tests, gnunet, 2017/04/20