Skip to content

Commit c12b4b6

Browse files
committed
Merge branch 'ptrstuff' of github.com:AndreasAakesson/IncludeOS into dev
2 parents 793859d + 745d685 commit c12b4b6

5 files changed

Lines changed: 14 additions & 14 deletions

File tree

api/net/inet_common.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ namespace net {
5050
}
5151

5252

53-
template<typename Derived, typename Base, typename Del>
54-
auto static_unique_ptr_cast( std::unique_ptr<Base, Del>&& p )
53+
template<typename Derived, typename Base>
54+
auto static_unique_ptr_cast( std::unique_ptr<Base>&& p )
5555
{
5656
auto* d = static_cast<Derived *>(p.release());
57-
return std::unique_ptr<Derived, Del>(d, std::move(p.get_deleter()));
57+
return std::unique_ptr<Derived>(d);
5858
}
5959

6060
} //< namespace net

api/net/packet.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ namespace net
4848
bufstore (bs)
4949
{}
5050

51-
~Packet()
51+
virtual ~Packet()
5252
{
5353
if (bufstore)
5454
bufstore->release(this);

api/net/tcp/common.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ namespace net {
5454
{ return buffer_t(new uint8_t[length], std::default_delete<uint8_t[]>()); }
5555

5656
class Packet;
57-
using Packet_ptr = std::unique_ptr<Packet, std::default_delete<net::Packet>>;
57+
using Packet_ptr = std::unique_ptr<Packet>;
5858

5959
class Connection;
6060
using Connection_ptr = std::shared_ptr<Connection>;

api/net/tcp/connection.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -485,10 +485,10 @@ class Connection : public std::enable_shared_from_this<Connection> {
485485
Timer timewait_timer;
486486

487487
/** Number of retransmission attempts on the packet first in RT-queue */
488-
size_t rtx_attempt_ = 0;
488+
int8_t rtx_attempt_ = 0;
489489

490490
/** number of retransmitted SYN packets. */
491-
size_t syn_rtx_ = 0;
491+
int8_t syn_rtx_ = 0;
492492

493493
/** Congestion control */
494494
// is fast recovery state
@@ -665,19 +665,19 @@ class Connection : public std::enable_shared_from_this<Connection> {
665665
Invoke/signal the diffrent TCP events.
666666
*/
667667
void signal_connect()
668-
{ on_connect_(shared_from_this()); }
668+
{ if(on_connect_) on_connect_(shared_from_this()); }
669669

670670
void signal_disconnect(Disconnect::Reason&& reason)
671671
{ on_disconnect_(shared_from_this(), Disconnect{reason}); }
672672

673673
void signal_error(TCPException error)
674-
{ on_error_(std::forward<TCPException>(error)); }
674+
{ if(on_error_) on_error_(std::forward<TCPException>(error)); }
675675

676676
void signal_packet_dropped(const Packet& packet, const std::string& reason)
677-
{ on_packet_dropped_(packet, reason); }
677+
{ if(on_packet_dropped_) on_packet_dropped_(packet, reason); }
678678

679679
void signal_rtx_timeout()
680-
{ on_rtx_timeout_(rtx_attempt_+1, rttm.RTO); }
680+
{ if(on_rtx_timeout_) on_rtx_timeout_(rtx_attempt_+1, rttm.RTO); }
681681

682682
/*
683683
Drop a packet. Used for debug/callback.

src/net/tcp/connection.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ Connection::Connection(TCP& host, port_t local_port, Socket remote) :
4141
cb(),
4242
read_request(),
4343
writeq(),
44+
on_disconnect_({this, &Connection::default_on_disconnect}),
4445
bytes_rx_(0), bytes_tx_(0),
4546
queued_(false),
4647
rtx_timer({this, &Connection::rtx_timeout}),
4748
timewait_timer({this, &Connection::timewait_timeout})
4849
{
4950
setup_congestion_control();
50-
setup_default_callbacks();
5151
debug("<Connection> %s created\n", to_string().c_str());
5252
}
5353

@@ -816,7 +816,7 @@ void Connection::signal_close() {
816816
debug("<Connection::signal_close> It's time to delete this connection. \n");
817817

818818
// call user callback
819-
on_close_();
819+
if(on_close_) on_close_();
820820

821821
// clean up all copies, delegates and timers
822822
clean_up();
@@ -833,7 +833,7 @@ void Connection::clean_up() {
833833
auto shared = shared_from_this();
834834
// clean up all other copies
835835
// either in TCP::listeners_ (open) or Listener::syn_queue_ (half-open)
836-
_on_cleanup_(shared);
836+
if(_on_cleanup_) _on_cleanup_(shared);
837837

838838
on_connect_.reset();
839839
on_disconnect_.reset(),

0 commit comments

Comments
 (0)