Remove allocation as part of detecting duplicate clients

We were tracking association IDs as part of connecting.  This was saving
all the IDs found in a vector.  Which was being allocated at runtime.
Move this to allocating it at construction time to be the worst case.
Another allocation down.

Change-Id: Ia774f6815c8cdefe9437a65bc44db7e18680e8f5
Signed-off-by: Austin Schuh <austin.schuh@bluerivertech.com>
diff --git a/aos/network/message_bridge_server_lib.cc b/aos/network/message_bridge_server_lib.cc
index 266c604..5d7cdde 100644
--- a/aos/network/message_bridge_server_lib.cc
+++ b/aos/network/message_bridge_server_lib.cc
@@ -389,6 +389,7 @@
   // Buffer up the max size a bit so everything fits nicely.
   LOG(INFO) << "Max message size for all clients is " << max_size;
   server_.SetMaxSize(max_size);
+  reconnected_.reserve(max_channels());
 }
 
 void MessageBridgeServer::NodeConnected(sctp_assoc_t assoc_id) {
@@ -555,8 +556,7 @@
     // number of messages is overwhelming right now at first boot. This also
     // should mean that we only send a single abort per association change,
     // which is more correct behavior.
-    std::vector<sctp_assoc_t> reconnected;
-    reconnected.reserve(connect->channels_to_transfer()->size());
+    reconnected_.clear();
     for (const Channel *channel : *connect->channels_to_transfer()) {
       bool matched = false;
       for (std::unique_ptr<ChannelState> &channel_state : channels_) {
@@ -566,7 +566,7 @@
         if (channel_state->Matches(channel)) {
           node_index = channel_state->NodeConnected(
               connect->node(), message->header.rcvinfo.rcv_assoc_id,
-              channel_index, &server_, monotonic_now, &reconnected);
+              channel_index, &server_, monotonic_now, &reconnected_);
           CHECK_NE(node_index, -1);
           matched = true;
           break;
diff --git a/aos/network/message_bridge_server_lib.h b/aos/network/message_bridge_server_lib.h
index 0938094..2884e58 100644
--- a/aos/network/message_bridge_server_lib.h
+++ b/aos/network/message_bridge_server_lib.h
@@ -153,6 +153,10 @@
   std::vector<std::unique_ptr<ChannelState>> channels_;
 
   std::string config_sha256_;
+
+  // List of assoc_id's that have been found already when connecting.  This is a
+  // member variable so the memory is allocated in the constructor.
+  std::vector<sctp_assoc_t> reconnected_;
 };
 
 }  // namespace message_bridge