Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
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
savoirfairelinux
opendht
Commits
432f3874
Commit
432f3874
authored
5 years ago
by
Seva
Committed by
Adrien Béraud
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
http: ensure conn callbacks are always invoked
parent
3abb9114
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/http.cpp
+14
-0
14 additions, 0 deletions
src/http.cpp
with
14 additions
and
0 deletions
src/http.cpp
+
14
−
0
View file @
432f3874
...
@@ -163,6 +163,8 @@ Connection::is_open()
...
@@ -163,6 +163,8 @@ Connection::is_open()
return
ssl_socket_
->
is_open
();
return
ssl_socket_
->
is_open
();
else
if
(
socket_
)
else
if
(
socket_
)
return
socket_
->
is_open
();
return
socket_
->
is_open
();
else
return
false
;
}
}
bool
bool
...
@@ -234,6 +236,8 @@ Connection::async_connect(std::vector<asio::ip::tcp::endpoint>&& endpoints, Conn
...
@@ -234,6 +236,8 @@ Connection::async_connect(std::vector<asio::ip::tcp::endpoint>&& endpoints, Conn
asio
::
async_connect
(
ssl_socket_
->
lowest_layer
(),
std
::
move
(
endpoints
),
cb
);
asio
::
async_connect
(
ssl_socket_
->
lowest_layer
(),
std
::
move
(
endpoints
),
cb
);
else
if
(
socket_
)
else
if
(
socket_
)
asio
::
async_connect
(
*
socket_
,
std
::
move
(
endpoints
),
cb
);
asio
::
async_connect
(
*
socket_
,
std
::
move
(
endpoints
),
cb
);
else
if
(
cb
)
cb
(
asio
::
error
::
operation_aborted
,
{});
}
}
void
void
...
@@ -258,6 +262,8 @@ Connection::async_handshake(HandlerCb cb)
...
@@ -258,6 +262,8 @@ Connection::async_handshake(HandlerCb cb)
});
});
else
if
(
socket_
)
else
if
(
socket_
)
cb
(
asio
::
error
::
no_protocol_option
);
cb
(
asio
::
error
::
no_protocol_option
);
else
if
(
cb
)
cb
(
asio
::
error
::
operation_aborted
);
}
}
void
void
...
@@ -269,6 +275,8 @@ Connection::async_write(BytesHandlerCb cb)
...
@@ -269,6 +275,8 @@ Connection::async_write(BytesHandlerCb cb)
asio
::
async_write
(
*
ssl_socket_
,
write_buf_
,
cb
);
asio
::
async_write
(
*
ssl_socket_
,
write_buf_
,
cb
);
else
if
(
socket_
)
else
if
(
socket_
)
asio
::
async_write
(
*
socket_
,
write_buf_
,
cb
);
asio
::
async_write
(
*
socket_
,
write_buf_
,
cb
);
else
if
(
cb
)
cb
(
asio
::
error
::
operation_aborted
,
0
);
}
}
void
void
...
@@ -280,6 +288,8 @@ Connection::async_read_until(const char* delim, BytesHandlerCb cb)
...
@@ -280,6 +288,8 @@ Connection::async_read_until(const char* delim, BytesHandlerCb cb)
asio
::
async_read_until
(
*
ssl_socket_
,
read_buf_
,
delim
,
cb
);
asio
::
async_read_until
(
*
ssl_socket_
,
read_buf_
,
delim
,
cb
);
else
if
(
socket_
)
else
if
(
socket_
)
asio
::
async_read_until
(
*
socket_
,
read_buf_
,
delim
,
cb
);
asio
::
async_read_until
(
*
socket_
,
read_buf_
,
delim
,
cb
);
else
if
(
cb
)
cb
(
asio
::
error
::
operation_aborted
,
0
);
}
}
void
void
...
@@ -291,6 +301,8 @@ Connection::async_read(const size_t bytes, BytesHandlerCb cb)
...
@@ -291,6 +301,8 @@ Connection::async_read(const size_t bytes, BytesHandlerCb cb)
asio
::
async_read
(
*
ssl_socket_
,
read_buf_
,
asio
::
transfer_exactly
(
bytes
),
cb
);
asio
::
async_read
(
*
ssl_socket_
,
read_buf_
,
asio
::
transfer_exactly
(
bytes
),
cb
);
else
if
(
socket_
)
else
if
(
socket_
)
asio
::
async_read
(
*
socket_
,
read_buf_
,
asio
::
transfer_exactly
(
bytes
),
cb
);
asio
::
async_read
(
*
socket_
,
read_buf_
,
asio
::
transfer_exactly
(
bytes
),
cb
);
else
if
(
cb
)
cb
(
asio
::
error
::
operation_aborted
,
0
);
}
}
void
void
...
@@ -299,6 +311,8 @@ Connection::timeout(const std::chrono::seconds timeout, HandlerCb cb)
...
@@ -299,6 +311,8 @@ Connection::timeout(const std::chrono::seconds timeout, HandlerCb cb)
if
(
!
is_open
()){
if
(
!
is_open
()){
if
(
logger_
)
if
(
logger_
)
logger_
->
e
(
"[http:client] [connection:%i] closed, can't timeout"
,
id_
);
logger_
->
e
(
"[http:client] [connection:%i] closed, can't timeout"
,
id_
);
if
(
cb
)
cb
(
asio
::
error
::
operation_aborted
);
return
;
return
;
}
}
if
(
!
timeout_timer_
)
if
(
!
timeout_timer_
)
...
...
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