- use proper signedness
[oweals/gnunet.git] / src / transport / plugin_transport_unix.c
index 3d6ac4d23af5fe486a1ccdda23ce8748306133f3..3a2fa6516f96af5c0f3af7901e5341b5fe339aef 100644 (file)
@@ -599,6 +599,21 @@ unix_session_disconnect (void *cls,
 }
 
 
+/**
+ * Function that is called to get the keepalive factor.
+ * GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to
+ * calculate the interval between keepalive packets.
+ *
+ * @param cls closure with the `struct Plugin`
+ * @return keepalive factor
+ */
+static unsigned int
+unix_query_keepalive_factor (void *cls)
+{
+  return 3;
+}
+
+
 /**
  * Actually send out the message, assume we've got the address and
  * send_handle squared away!
@@ -891,6 +906,21 @@ unix_plugin_get_session (void *cls,
   return s;
 }
 
+static void
+unix_plugin_update_session_timeout (void *cls,
+                                  const struct GNUNET_PeerIdentity *peer,
+                                  struct Session *session)
+{
+  struct Plugin *plugin = cls;
+
+  if (GNUNET_OK !=
+      GNUNET_CONTAINER_multipeermap_contains_value (plugin->session_map,
+                                                    &session->target,
+                                                    session))
+    return;
+
+  reschedule_session_timeout (session);
+}
 
 /**
  * Function that can be used by the transport service to transmit
@@ -956,7 +986,7 @@ unix_plugin_send (void *cls,
   memcpy (&message->sender, plugin->env->my_identity,
           sizeof (struct GNUNET_PeerIdentity));
   memcpy (&message[1], msgbuf, msgbuf_size);
-  reschedule_session_timeout (session);
+
   wrapper = GNUNET_new (struct UNIXMessageWrapper);
   wrapper->msg = message;
   wrapper->msgsize = ssize;
@@ -1614,11 +1644,13 @@ libgnunet_plugin_transport_unix_init (void *cls)
   api->send = &unix_plugin_send;
   api->disconnect_peer = &unix_peer_disconnect;
   api->disconnect_session = &unix_session_disconnect;
+  api->query_keepalive_factor = &unix_query_keepalive_factor;
   api->address_pretty_printer = &unix_plugin_address_pretty_printer;
   api->address_to_string = &unix_address_to_string;
   api->check_address = &unix_check_address;
   api->string_to_address = &unix_string_to_address;
   api->get_network = &unix_get_network;
+  api->update_session_timeout = &unix_plugin_update_session_timeout;
   sockets_created = unix_transport_server_start (plugin);
   if (0 == sockets_created)
     LOG (GNUNET_ERROR_TYPE_WARNING,