Index: pjproject/trunk/pjnath/src/pjturn-srv/server.c
===================================================================
--- pjproject/trunk/pjnath/src/pjturn-srv/server.c	(revision 4360)
+++ pjproject/trunk/pjnath/src/pjturn-srv/server.c	(revision 4728)
@@ -1,4 +1,4 @@
 /* $Id$ */
-/* 
+/*
  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
@@ -16,5 +16,5 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include "turn.h"
@@ -77,5 +77,5 @@
  * Create server.
  */
-PJ_DEF(pj_status_t) pj_turn_srv_create(pj_pool_factory *pf, 
+PJ_DEF(pj_status_t) pj_turn_srv_create(pj_pool_factory *pf,
 				       pj_turn_srv **p_srv)
 {
@@ -95,5 +95,5 @@
     srv->core.pool = pool;
     srv->core.tls_key = srv->core.tls_data = -1;
-    
+
     /* Create ioqueue */
     status = pj_ioqueue_create(pool, MAX_HANDLES, &srv->core.ioqueue);
@@ -102,5 +102,5 @@
 
     /* Server mutex */
-    status = pj_lock_create_recursive_mutex(pool, srv->obj_name, 
+    status = pj_lock_create_recursive_mutex(pool, srv->obj_name,
 					    &srv->core.lock);
     if (status != PJ_SUCCESS)
@@ -115,5 +115,5 @@
     if (status != PJ_SUCCESS)
 	goto on_error;
-    
+
     /* Create timer heap */
     status = pj_timer_heap_create(pool, MAX_TIMER, &srv->core.timer_heap);
@@ -126,5 +126,5 @@
     /* Array of listeners */
     srv->core.listener = (pj_turn_listener**)
-			 pj_pool_calloc(pool, MAX_LISTENERS, 
+			 pj_pool_calloc(pool, MAX_LISTENERS,
 					sizeof(srv->core.listener[0]));
 
@@ -170,10 +170,10 @@
     srv->core.thread_cnt = MAX_THREADS;
     srv->core.thread = (pj_thread_t**)
-		       pj_pool_calloc(pool, srv->core.thread_cnt, 
+		       pj_pool_calloc(pool, srv->core.thread_cnt,
 				      sizeof(pj_thread_t*));
 
     /* Start the worker threads */
     for (i=0; i<srv->core.thread_cnt; ++i) {
-	status = pj_thread_create(pool, srv->obj_name, &server_thread_proc, 
+	status = pj_thread_create(pool, srv->obj_name, &server_thread_proc,
 				  srv, 0, 0, &srv->core.thread[i]);
 	if (status != PJ_SUCCESS)
@@ -182,5 +182,5 @@
 
     /* We're done. Application should add listeners now */
-    PJ_LOG(4,(srv->obj_name, "TURN server v%s is running", 
+    PJ_LOG(4,(srv->obj_name, "TURN server v%s is running",
 	      pj_get_version()));
 
@@ -194,6 +194,6 @@
 
 
-/* 
- * Handle timer and network events 
+/*
+ * Handle timer and network events
  */
 static void srv_handle_events(pj_turn_srv *srv, const pj_time_val *max_timeout)
@@ -204,6 +204,6 @@
     int c;
 
-    /* Poll the timer. The timer heap has its own mutex for better 
-     * granularity, so we don't need to lock the server. 
+    /* Poll the timer. The timer heap has its own mutex for better
+     * granularity, so we don't need to lock the server.
      */
     timeout.sec = timeout.msec = 0;
@@ -223,5 +223,5 @@
     }
 
-    /* Poll ioqueue. 
+    /* Poll ioqueue.
      * Repeat polling the ioqueue while we have immediate events, because
      * timer heap may process more than one events, so if we only process
@@ -293,5 +293,5 @@
 	}
     }
-    
+
     /* Destroy all listeners. */
     for (i=0; i<srv->core.lis_cnt; ++i) {
@@ -313,5 +313,5 @@
 	srv->tables.res = NULL;
     }
-    
+
     /* Destroy timer heap */
     if (srv->core.timer_heap) {
@@ -461,5 +461,5 @@
 
 
-/* Callback from our own STUN session whenever it needs to send 
+/* Callback from our own STUN session whenever it needs to send
  * outgoing STUN packet.
  */
@@ -472,10 +472,10 @@
 {
     pj_turn_transport *transport = (pj_turn_transport*) token;
-    
+
     PJ_ASSERT_RETURN(transport!=NULL, PJ_EINVALIDOP);
 
     PJ_UNUSED_ARG(sess);
 
-    return transport->sendto(transport, pdu, pdu_size, 0, 
+    return transport->sendto(transport, pdu, pdu_size, 0,
 			     dst_addr, addr_len);
 }
@@ -483,11 +483,11 @@
 
 /* Respond to STUN request */
-static pj_status_t stun_respond(pj_stun_session *sess, 
+static pj_status_t stun_respond(pj_stun_session *sess,
 				pj_turn_transport *transport,
 				const pj_stun_rx_data *rdata,
-				unsigned code, 
+				unsigned code,
 				const char *errmsg,
-				pj_bool_t cache, 
-				const pj_sockaddr_t *dst_addr, 
+				pj_bool_t cache,
+				const pj_sockaddr_t *dst_addr,
 				unsigned addr_len)
 {
@@ -497,5 +497,5 @@
 
     /* Create response */
-    status = pj_stun_session_create_res(sess, rdata, code, 
+    status = pj_stun_session_create_res(sess, rdata, code,
 					(errmsg?pj_cstr(&reason,errmsg):NULL),
 					&tdata);
@@ -504,5 +504,5 @@
 
     /* Send the response */
-    return pj_stun_session_send_msg(sess, transport, cache, PJ_FALSE, 
+    return pj_stun_session_send_msg(sess, transport, cache, PJ_FALSE,
 				    dst_addr,  addr_len, tdata);
 }
@@ -523,5 +523,4 @@
     pj_turn_transport *transport;
     const pj_stun_msg *msg = rdata->msg;
-    pj_turn_srv *srv;
     pj_turn_allocation *alloc;
     pj_status_t status;
@@ -531,5 +530,4 @@
 
     transport = (pj_turn_transport*) token;
-    srv = transport->listener->server;
 
     /* Respond any requests other than ALLOCATE with 437 response */
@@ -570,5 +568,5 @@
 
     /* Create response */
-    status = pj_stun_msg_create_response(pkt->pool, request, 0, NULL, 
+    status = pj_stun_msg_create_response(pkt->pool, request, 0, NULL,
 					 &response);
     if (status != PJ_SUCCESS)
@@ -576,5 +574,5 @@
 
     /* Add XOR-MAPPED-ADDRESS */
-    pj_stun_msg_add_sockaddr_attr(pkt->pool, response, 
+    pj_stun_msg_add_sockaddr_attr(pkt->pool, response,
 				  PJ_STUN_ATTR_XOR_MAPPED_ADDR,
 				  PJ_TRUE,
@@ -588,5 +586,5 @@
 
     /* Send response */
-    pkt->transport->sendto(pkt->transport, pdu, len, 0, 
+    pkt->transport->sendto(pkt->transport, pdu, len, 0,
 			   &pkt->src.clt_addr, pkt->src_addr_len);
 }
@@ -599,5 +597,5 @@
  * if an allocation is not found.
  */
-PJ_DEF(void) pj_turn_srv_on_rx_pkt(pj_turn_srv *srv, 
+PJ_DEF(void) pj_turn_srv_on_rx_pkt(pj_turn_srv *srv,
 				   pj_turn_pkt *pkt)
 {
@@ -639,5 +637,5 @@
 	    if ((*pkt->pkt != 0x00 && *pkt->pkt != 0x01) ||
 		pkt->len > 1600 ||
-		(options & PJ_STUN_IS_DATAGRAM)) 
+		(options & PJ_STUN_IS_DATAGRAM))
 	    {
 		char errmsg[PJ_ERR_MSG_SIZE];
@@ -647,5 +645,5 @@
 
 		pj_strerror(status, errmsg, sizeof(errmsg));
-		PJ_LOG(5,(srv->obj_name, 
+		PJ_LOG(5,(srv->obj_name,
 			  "Non-STUN packet from %s is dropped: %s",
 			  pj_sockaddr_print(&pkt->src.clt_addr, ip, sizeof(ip), 3),
@@ -655,5 +653,5 @@
 	}
 
-	/* Special handling for Binding Request. We won't give it to the 
+	/* Special handling for Binding Request. We won't give it to the
 	 * STUN session since this request is not authenticated.
 	 */
@@ -669,7 +667,7 @@
 	options &= ~PJ_STUN_CHECK_PACKET;
 	parsed_len = 0;
-	status = pj_stun_session_on_rx_pkt(srv->core.stun_sess, pkt->pkt, 
+	status = pj_stun_session_on_rx_pkt(srv->core.stun_sess, pkt->pkt,
 					   pkt->len, options, pkt->transport,
-					   &parsed_len, &pkt->src.clt_addr, 
+					   &parsed_len, &pkt->src.clt_addr,
 					   pkt->src_addr_len);
 	if (status != PJ_SUCCESS) {
@@ -678,5 +676,5 @@
 
 	    pj_strerror(status, errmsg, sizeof(errmsg));
-	    PJ_LOG(5,(srv->obj_name, 
+	    PJ_LOG(5,(srv->obj_name,
 		      "Error processing STUN packet from %s: %s",
 		      pj_sockaddr_print(&pkt->src.clt_addr, ip, sizeof(ip), 3),
