コード例 #1
0
ファイル: listen_point.c プロジェクト: MariadeAnton/onion
/**
 * @short Free and closes the listen point
 * @memberof onion_listen_point_t
 * 
 * Calls the custom listen_stop mathod, and frees all common structures.
 * 
 * @param op the listen point
 */
void onion_listen_point_free(onion_listen_point *op){
	ONION_DEBUG("Free listen point %d", op->listenfd);
	onion_listen_point_listen_stop(op);
	if (op->free_user_data)
		op->free_user_data(op);
	if (op->hostname)
		onion_low_free(op->hostname);
	if (op->port)
		onion_low_free(op->port);
	onion_low_free(op);
}
コード例 #2
0
ファイル: onion.c プロジェクト: KokaKiwi/onion
/**
 * @short Advises the listener to stop.
 * 
 * The listener is advised to stop listening. After this call no listening is still open, and listen could be
 * called again, or the onion server freed.
 * 
 * If there is any pending connection, it can finish if onion not freed before.
 */
void onion_listen_stop(onion* server){
	/// Start listening
	onion_listen_point **lp=server->listen_points;
	while (*lp){
		onion_listen_point_listen_stop(*lp);
		lp++;
	}	
	if (server->poller){
		ONION_DEBUG("Stop listening");
		onion_poller_stop(server->poller);
	}
#ifdef HAVE_PTHREADS
	if (server->flags&O_DETACHED)
		pthread_join(server->listen_thread, NULL);
#endif
}