+/*
+ * Copyright (c) 2016, JANET(UK)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of JANET(UK) nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
#include <stdio.h>
#include <pthread.h>
#include <fcntl.h>
tr_debug("tr_trps_event_cb: unexpected event on TRPS socket (event=0x%X)", event);
} else {
/* create a thread to handle this connection */
- asprintf(&name, "trustrouter@%s", trps->hostname);
+ if (asprintf(&name, "trustrouter@%s", trps->hostname)==-1) {
+ goto cleanup;
+ }
gssname=tr_new_name(name);
free(name); name=NULL;
conn=trp_connection_accept(tmp_ctx, listener, gssname);
pthread_create(trp_connection_get_thread(conn), NULL, tr_trps_thread, thread_data);
}
}
+
+ cleanup:
talloc_free(tmp_ctx);
}
/* everything belonging to the thread is in the TRP_CONNECTION
* associated with it */
tr_debug("tr_trps_cleanup_conn: freeing %p", conn);
-/* pthread_join(*trp_connection_get_thread(conn), NULL); -- removed while debugging, put back!!! --jlr */
+ pthread_join(*trp_connection_get_thread(conn), NULL);
trps_remove_connection(trps, conn);
talloc_report_full(conn, stderr);
trp_connection_free(conn);
trps_set_update_interval(trps, new_cfg->internal->trp_update_interval);
trps_set_sweep_interval(trps, new_cfg->internal->trp_sweep_interval);
trps_set_ptable(trps, new_cfg->peers);
+ trps_set_peer_status_callback(trps, tr_peer_status_change, (void *)trps);
trps_clear_rtable(trps); /* should we do this every time??? */
tr_add_local_routes(trps, new_cfg); /* should we do this every time??? */
trps_update_active_routes(trps); /* find new routes */