Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
biboumi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
88
Issues
88
List
Boards
Labels
Service Desk
Milestones
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
louiz’
biboumi
Commits
5328d080
Commit
5328d080
authored
Jul 07, 2016
by
louiz’
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don’t use unique_ptr to store dns socket handlers
parent
9fb2e116
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
14 deletions
+14
-14
louloulibs/network/dns_handler.cpp
louloulibs/network/dns_handler.cpp
+7
-7
louloulibs/network/dns_handler.hpp
louloulibs/network/dns_handler.hpp
+1
-1
louloulibs/network/dns_socket_handler.hpp
louloulibs/network/dns_socket_handler.hpp
+3
-3
louloulibs/network/socket_handler.hpp
louloulibs/network/socket_handler.hpp
+3
-3
No files found.
louloulibs/network/dns_handler.cpp
View file @
5328d080
...
...
@@ -68,7 +68,7 @@ void DNSHandler::watch_dns_sockets(std::shared_ptr<Poller>& poller)
std
::
remove_if
(
this
->
socket_handlers
.
begin
(),
this
->
socket_handlers
.
end
(),
[
&
readers
](
const
auto
&
dns_socket
)
{
return
!
FD_ISSET
(
dns_socket
->
get_socket
(),
&
readers
);
return
!
FD_ISSET
(
dns_socket
.
get_socket
(),
&
readers
);
}),
this
->
socket_handlers
.
end
());
...
...
@@ -81,8 +81,8 @@ void DNSHandler::watch_dns_sockets(std::shared_ptr<Poller>& poller)
this
->
socket_handlers
.
end
(),
[
i
](
const
auto
&
socket_handler
)
{
return
i
==
socket_handler
->
get_socket
();
});
return
i
==
socket_handler
.
get_socket
();
});
if
(
!
read
&&
!
write
)
// No need to read or write to it
{
// If found, erase it and stop watching it because it is not
// needed anymore
...
...
@@ -95,12 +95,12 @@ void DNSHandler::watch_dns_sockets(std::shared_ptr<Poller>& poller)
if
(
it
==
this
->
socket_handlers
.
end
())
{
this
->
socket_handlers
.
emplace
(
this
->
socket_handlers
.
begin
(),
std
::
make_unique
<
DNSSocketHandler
>
(
poller
,
i
)
);
poller
,
i
);
it
=
this
->
socket_handlers
.
begin
();
}
poller
->
add_socket_handler
(
it
->
get
()
);
poller
->
add_socket_handler
(
&*
it
);
if
(
write
)
poller
->
watch_send_events
(
it
->
get
()
);
poller
->
watch_send_events
(
&*
it
);
}
}
// Cancel previous timer, if any.
...
...
@@ -116,7 +116,7 @@ void DNSHandler::watch_dns_sockets(std::shared_ptr<Poller>& poller)
[
this
]()
{
for
(
auto
&
dns_socket_handler
:
this
->
socket_handlers
)
dns_socket_handler
->
on_recv
();
dns_socket_handler
.
on_recv
();
},
"DNS timeout"
));
}
...
...
louloulibs/network/dns_handler.hpp
View file @
5328d080
...
...
@@ -50,7 +50,7 @@ private:
* call to ares_fds. DNSSocketHandlers are added to it or removed from it
* in the watch_dns_sockets() method
*/
std
::
vector
<
std
::
unique_ptr
<
DNSSocketHandler
>
>
socket_handlers
;
std
::
vector
<
DNSSocketHandler
>
socket_handlers
;
ares_channel
channel
;
};
...
...
louloulibs/network/dns_socket_handler.hpp
View file @
5328d080
...
...
@@ -17,11 +17,11 @@ class DNSSocketHandler: public SocketHandler
{
public:
explicit
DNSSocketHandler
(
std
::
shared_ptr
<
Poller
>
poller
,
const
socket_t
socket
);
~
DNSSocketHandler
()
=
default
;
~
DNSSocketHandler
();
DNSSocketHandler
(
DNSSocketHandler
&&
)
=
default
;
DNSSocketHandler
&
operator
=
(
DNSSocketHandler
&&
)
=
default
;
DNSSocketHandler
(
const
DNSSocketHandler
&
)
=
delete
;
DNSSocketHandler
(
DNSSocketHandler
&&
)
=
delete
;
DNSSocketHandler
&
operator
=
(
const
DNSSocketHandler
&
)
=
delete
;
DNSSocketHandler
&
operator
=
(
DNSSocketHandler
&&
)
=
delete
;
/**
* Just call dns_process_fd, c-ares will do its work of send()ing or
...
...
louloulibs/network/socket_handler.hpp
View file @
5328d080
...
...
@@ -15,10 +15,10 @@ public:
socket
(
socket
)
{}
virtual
~
SocketHandler
()
{}
SocketHandler
(
const
SocketHandler
&
)
=
delete
;
SocketHandler
(
SocketHandler
&&
)
=
de
lete
;
SocketHandler
&
operator
=
(
SocketHandler
&&
)
=
default
;
SocketHandler
(
SocketHandler
&&
)
=
de
fault
;
SocketHandler
&
operator
=
(
const
SocketHandler
&
)
=
delete
;
SocketHandler
&
operator
=
(
SocketHandler
&
&
)
=
delete
;
SocketHandler
(
const
SocketHandler
&
)
=
delete
;
virtual
void
on_recv
()
=
0
;
virtual
void
on_send
()
=
0
;
...
...
louiz’
@louiz
mentioned in commit
de0eff6e
·
Jul 28, 2016
mentioned in commit
de0eff6e
mentioned in commit de0eff6e944db11ae3552e0cd2c191997eebaa2f
Toggle commit list
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