Browse code

- logstderror works now with more than 1 process - played a little with the locks

Andrei Pelinescu-Onciul authored on 11/12/2001 09:30:41
Showing 7 changed files
... ...
@@ -46,7 +46,7 @@ ARCH = $(shell uname -s)
46 46
 #		malloc etc.)
47 47
 DEFS= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
48 48
 	 -DDNS_IP_HACK  -DPKG_MALLOC -DSHM_MEM  -DSHM_MMAP \
49
-	 -DNO_DEBUG -DDBG_QM_MALLOC 
49
+	 -DDBG_QM_MALLOC #-DNO_DEBUG #
50 50
 #-DEXTRA_DEBUG
51 51
 # -DUSE_SHM_MEM
52 52
 #-DNO_DEBUG 
... ...
@@ -48,7 +48,7 @@
48 48
 #define PKG_MEM_POOL_SIZE 1024*1024
49 49
 
50 50
 /*used is SH_MEM is defined*/
51
-#define SHM_MEM_SIZE 8*1024*1024
51
+#define SHM_MEM_SIZE 128*1024*1024
52 52
 
53 53
 #define TIMER_TICK 1
54 54
 #define LONG_SLEEP	3600
... ...
@@ -223,10 +223,11 @@ int daemonize(char*  name)
223 223
 	}
224 224
 	
225 225
 	/* close any open file descriptors */
226
-	for (r=0;r<MAX_FD; r++){
227
-		if ((r==3) && log_stderr)  continue;
228
-		close(r);
229
-	}
226
+	if (log_stderr==0)
227
+		for (r=0;r<MAX_FD; r++){
228
+			if ((r==3) && log_stderr)  continue;
229
+			close(r);
230
+		}
230 231
 	return  0;
231 232
 
232 233
 error:
... ...
@@ -286,7 +287,7 @@ int main_loop()
286 286
 					return udp_rcv_loop();
287 287
 				}
288 288
 			}
289
-			close(udp_sock); /*parent*/
289
+			/*close(udp_sock);*/ /*parent*/
290 290
 		}
291 291
 	}
292 292
 	/*this is the main process*/
... ...
@@ -257,7 +257,7 @@ void ref_cell( struct cell* p_cell)
257 257
 {
258 258
    lock( p_cell->mutex );
259 259
    p_cell->ref_counter++;
260
-   unlock( p_cell->mutex );
260
+  unlock( p_cell->mutex );
261 261
 }
262 262
 
263 263
 
... ...
@@ -172,6 +172,7 @@ void lock_cleanup()
172 172
 
173 173
 }
174 174
 
175
+
175 176
 /* lock sempahore s */
176 177
 int lock( ser_lock_t s )
177 178
 {
... ...
@@ -33,13 +33,15 @@
33 33
 
34 34
 
35 35
 #define insert_into_timer(hash_table,new_tl,list_id,time_out) \
36
-	insert_into_timer_list(hash_table,new_tl,list_id,(get_ticks()+time_out))
36
+	insert_into_timer_list((hash_table), (new_tl), (list_id), \
37
+			(get_ticks()+(time_out)))
37 38
 
38 39
 #define add_to_tail_of_timer(hash_table,new_tl,list_id,time_out) \
39
-	add_to_tail_of_timer_list(hash_table,new_tl,list_id,(get_ticks()+time_out))
40
+	add_to_tail_of_timer_list((hash_table), (new_tl), (list_id), \
41
+			(get_ticks()+(time_out)))
40 42
 
41 43
 #define remove_from_timer(hash_table,tl,list_id) \
42
-	remove_from_timer_list( hash_table , tl , list_id)\
44
+	remove_from_timer_list( (hash_table), (tl) , (list_id))
43 45
 
44 46
 
45 47
 
... ...
@@ -59,9 +61,9 @@ int tm_startup()
59 59
 
60 60
    /* installing handlers for timers */
61 61
    hash_table->timers[RETRASMISSIONS_LIST].timeout_handler = retransmission_handler;
62
-   hash_table->timers[FR_TIMER_LIST].timeout_handler              = final_response_handler;
63
-   hash_table->timers[WT_TIMER_LIST].timeout_handler             = wait_handler;
64
-   hash_table->timers[DELETE_LIST].timeout_handler                 = delete_handler;
62
+   hash_table->timers[FR_TIMER_LIST].timeout_handler = final_response_handler;
63
+   hash_table->timers[WT_TIMER_LIST].timeout_handler = wait_handler;
64
+   hash_table->timers[DELETE_LIST].timeout_handler = delete_handler;
65 65
 
66 66
    /* register the timer function */
67 67
    register_timer( timer_routine , hash_table , 1 );
... ...
@@ -100,7 +102,8 @@ void tm_shutdown()
100 100
     /* destroy the hash table */
101 101
     DBG("DEBUG: tm_shutdown : empting hash table\n");
102 102
     free_hash_table( hash_table );
103
-
103
+    DBG("DEBUG: tm_shutdown : removing semaphores\n");
104
+	lock_cleanup();
104 105
     DBG("DEBUG: tm_shutdown : done\n");
105 106
 }
106 107
 
... ...
@@ -2,11 +2,11 @@ debug=9          # debug level (cmd line: -dddddddddd)
2 2
 check_via=yes     # (cmd. line: -v)
3 3
 dns=on           # (cmd. line: -r)
4 4
 rev_dns=yes      # (cmd. line: -R)
5
-fork=no          # (cmd. line: -D)
6
-#children=4
5
+fork=yes          # (cmd. line: -D)
6
+children=4
7 7
 log_stderror=yes # (cmd line: -E)
8 8
 #port=5080
9
-#listen=127.0.0.1
9
+listen=127.0.0.1
10 10
 loop_checks=1
11 11
 # for more info: sip_router -h
12 12
 
... ...
@@ -24,7 +24,7 @@ route{
24 24
 	if ( t_lookup_request()) {
25 25
 		if ( method=="ACK" )	{
26 26
 			log("SER: ACK received -> t_release\n");
27
-			if (! t_forward("195.37.78.233", "6666" )) {
27
+			if (! t_forward("127.0.0.1", "5090" )) {
28 28
 				log("SER: WARNING: bad forward\n");
29 29
 			};
30 30
 			if (! t_release()) {
... ...
@@ -58,12 +58,12 @@ route{
58 58
 		#t_forward("benetnash.fokus.gmd.de", "5080" );
59 59
 		if (method=="BYE") {
60 60
 			log("SER: BYE received, HACK: forwarding to client\n");
61
-			if (! t_forward("195.37.78.233", "5555")){
61
+			if (! t_forward("127.0.0.1", "5000")){
62 62
 				log("SER:ERROR: t_forward (..., 5555)\n");
63 63
 			};
64 64
 
65 65
 		}else{
66
-			if (! t_forward("195.37.78.233", "6666" )){
66
+			if (! t_forward("127.0.0.1", "5090" )){
67 67
 				log("SER:ERROR: t_forward (..., 6666)\n");
68 68
 			};
69 69
 		};