}
/**
- * Destroys the port and all resources associated with it.
+ * Stop receiving requests on the port.
*
* @param port
*/
-void forb_destroy_port(forb_port_t *port)
+void forb_stop_port(forb_port_t *port)
{
- forb_t *forb = port->forb;
void *thread_return;
port->finish = true; /* Exit all the threads */
/* FIXME: Canceling discovery thread sometimes didn't
* work. The discovery thread stayed forever in the
* pthread_cond_timedwait(). */
- //pthread_cancel(port->discovery_thread.pthread_id);
-
+#ifndef CONFIG_FORB_PROTO_INET_DEFAULT
+ pthread_cancel(port->discovery_thread.pthread_id);
+#endif
/* Sometimes, cancelation doesn't work and the
* discovery_thread hangs in pthread_cond_timedwait
* infinitely. */
#ifndef CONFIG_FORB_PROTO_INET_DEFAULT
pthread_join(port->discovery_thread.pthread_id, &thread_return);
#endif
+}
+
+/**
+ * Destroys the port and all resources associated with it.
+ *
+ * @param port
+ */
+void forb_destroy_port(forb_port_t *port)
+{
+ forb_t *forb = port->forb;
+
/* Because of no locking of port->peers, this must be called
* after receiver thread is stopped. */
forb_peer_t *peer;
forb_peer_disconnected(peer);
forb_peer_put(peer);
}
+ if (port->new_peer)
+ forb_peer_put(port->new_peer);
if (port->desc.proto->port_destroy) {
port->desc.proto->port_destroy(port);