Browse code

*** empty log message ***

Andrei Pelinescu-Onciul authored on 31/01/2002 22:46:59
Showing 5 changed files
... ...
@@ -66,8 +66,9 @@ int lock_initialize()
66 66
 
67 67
 	/* transaction timers */
68 68
 	if ((timer_semaphore= init_semaphore_set( TG_NR ) ) < 0) {
69
-                LOG(L_ERR, "ERROR: lock_initialize:  "
70
-			"transaction timer semaphore initialization failure\n");
69
+		LOG(L_CRIT, "ERROR: lock_initialize:  "
70
+			"transaction timer semaphore initialization failure: %s\n",
71
+				strerror(errno));
71 72
 		goto error;
72 73
 	}
73 74
 
... ...
@@ -80,23 +81,37 @@ int lock_initialize()
80 80
 	i=SEM_MIN;
81 81
 	/* probing phase: 0=initial, 1=after the first failure */
82 82
 	probe_run=0;
83
+again:
83 84
 	do {
84 85
 		if (entry_semaphore>0) /* clean-up previous attempt */
85 86
 			semctl( entry_semaphore, 0 , IPC_RMID , 0 );
87
+		if (reply_semaphore>0)
88
+			semctl(reply_semaphore, 0 , IPC_RMID , 0 );
89
+		if (ack_semaphore>0)
90
+			semctl(reply_semaphore, 0 , IPC_RMID , 0 );
91
+
92
+		if (i==0){
93
+			LOG(L_CRIT, "lock_initialize: could not allocate semaphore"
94
+					" sets\n");
95
+			goto error;
96
+		}
97
+
86 98
 		entry_semaphore=init_semaphore_set( i );
87 99
 		if (entry_semaphore==-1) {
88
-			DBG("DEBUG: lock_initialize: entry semaphore initialization failure:  %s\n", strerror( errno ) );
100
+			DBG("DEBUG: lock_initialize: entry semaphore "
101
+					"initialization failure:  %s\n", strerror( errno ) );
89 102
 			/* Solaris: EINVAL, Linux: ENOSPC */
90 103
                         if (errno==EINVAL || errno==ENOSPC ) {
91 104
                                 /* first time: step back and try again */
92 105
                                 if (probe_run==0) {
93
-					DBG("DEBUG: lock_initialize: first time sempahore allocation failure\n");
106
+					DBG("DEBUG: lock_initialize: first time "
107
+								"semaphore allocation failure\n");
94 108
                                         i--;
95 109
                                         probe_run=1;
96 110
                                         continue;
97 111
 				/* failure after we stepped back; give up */
98 112
                                 } else {
99
-				 	LOG(L_ERR, "ERROR: lock_initialize:   second time sempahore allocation failure\n");
113
+				 	DBG("DEBUG: lock_initialize:   second time sempahore allocation failure\n");
100 114
 					goto error;
101 115
 				}
102 116
                         }
... ...
@@ -116,8 +131,34 @@ int lock_initialize()
116 116
 	} while(1);
117 117
 	sem_nr=i;	
118 118
 
119
-	reply_semaphore=init_semaphore_set( sem_nr );
120
-	ack_semaphore=init_semaphore_set(sem_nr);
119
+	if ((reply_semaphore=init_semaphore_set( sem_nr ))<0){
120
+		if (errno==EINVAL || errno==ENOSPC ) {
121
+			DBG("DEBUG:lock_initialize: reply semaphore initialization"
122
+				" failure: %s\n", strerror(errno));
123
+			probe_run==1;
124
+			i--;
125
+			goto again;
126
+		}else{
127
+			LOG(L_CRIT, "ERROR:lock_initialize: reply semaphore initialization"
128
+				" failure: %s\n", strerror(errno));
129
+			goto error;
130
+		}
131
+	}
132
+	
133
+	if ((ack_semaphore=init_semaphore_set(sem_nr))<0){
134
+		if (errno==EINVAL || errno==ENOSPC ) {
135
+			DBG( "DEBUG:lock_initialize: ack semaphore initialization"
136
+				" failure: %s\n", strerror(errno));
137
+			probe_run==1;
138
+			i--;
139
+			goto again;
140
+		}else{
141
+			LOG(L_CRIT, "ERROR:lock_initialize: ack semaphore initialization"
142
+				" failure: %s\n", strerror(errno));
143
+			goto error;
144
+		}
145
+	}
146
+
121 147
 
122 148
 
123 149
 	/* return success */
... ...
@@ -135,8 +176,8 @@ static int init_semaphore_set( int size )
135 135
 
136 136
 	new_semaphore=semget ( IPC_PRIVATE, size, IPC_CREAT | IPC_PERMISSIONS );
137 137
 	if (new_semaphore==-1) {
138
-		LOG(L_CRIT, "ERROR: init_semaphore_set:  failure to allocate a"
139
-					" semaphore: %s\n", strerror(errno));
138
+		DBG("DEBUG: init_semaphore_set(%d):  failure to allocate a"
139
+					" semaphore: %s\n", size, strerror(errno));
140 140
 		return -1;
141 141
 	}
142 142
 	for (i=0; i<size; i++) {
... ...
@@ -148,7 +189,7 @@ static int init_semaphore_set( int size )
148 148
                 /* binary lock */
149 149
                 argument.val = +1;
150 150
                 if (semctl( new_semaphore, i , SETVAL , argument )==-1) {
151
-			LOG(L_CRIT, "ERROR: init_semaphore_set:  failure to "
151
+			DBG("DEBUG: init_semaphore_set:  failure to "
152 152
 						"initialize a semaphore: %s\n", strerror(errno));
153 153
 			if (semctl( entry_semaphore, 0 , IPC_RMID , 0 )==-1)
154 154
 				DBG("DEBUG: init_semaphore_set:  failure to release"
... ...
@@ -235,9 +276,9 @@ tryagain:
235 235
 			goto tryagain;
236 236
 		} else {
237 237
 			LOG(L_CRIT, "ERROR: change_semaphore(%x, %x, 1) : %s\n",
238
-					s.semaphore.set, &pbuf,
238
+					s.semaphore_set, &pbuf,
239 239
 					strerror(errno));
240
-			
240
+		}
241 241
 	}
242 242
 	return r;
243 243
 }
... ...
@@ -18,7 +18,7 @@ dns=on           # (cmd. line: -r)
18 18
 rev_dns=yes      # (cmd. line: -R)
19 19
 #port=5070
20 20
 #listen=127.0.0.1
21
-#listen=195.37.77.101
21
+listen=192.168.57.33
22 22
 loop_checks=0
23 23
 # for more info: sip_router -h
24 24
 
... ...
@@ -5,7 +5,7 @@
5 5
 #
6 6
 
7 7
 
8
-debug=1          # debug level (cmd line: -dddddddddd)
8
+debug=3          # debug level (cmd line: -dddddddddd)
9 9
 #fork=yes          # (cmd. line: -D)
10 10
 fork=yes
11 11
 log_stderror=yes # (cmd line: -E)
... ...
@@ -17,8 +17,8 @@ check_via=no     # (cmd. line: -v)
17 17
 dns=on           # (cmd. line: -r)
18 18
 rev_dns=yes      # (cmd. line: -R)
19 19
 #port=5070
20
-listen=127.0.0.1
21
-#listen=195.37.77.101
20
+#listen=127.0.0.1
21
+listen=192.168.57.33
22 22
 loop_checks=0
23 23
 # for more info: sip_router -h
24 24
 
... ...
@@ -5,7 +5,7 @@
5 5
 #
6 6
 
7 7
 
8
-debug=1          # debug level (cmd line: -dddddddddd)
8
+debug=3          # debug level (cmd line: -dddddddddd)
9 9
 #fork=yes          # (cmd. line: -D)
10 10
 fork=yes
11 11
 log_stderror=yes # (cmd line: -E)
... ...
@@ -17,8 +17,8 @@ check_via=no     # (cmd. line: -v)
17 17
 dns=on           # (cmd. line: -r)
18 18
 rev_dns=yes      # (cmd. line: -R)
19 19
 #port=5070
20
-listen=127.0.0.1
21
-#listen=195.37.77.101
20
+#listen=127.0.0.1
21
+listen=192.168.57.33
22 22
 loop_checks=0
23 23
 # for more info: sip_router -h
24 24
 
... ...
@@ -5,7 +5,7 @@
5 5
 #
6 6
 
7 7
 
8
-debug=1          # debug level (cmd line: -dddddddddd)
8
+debug=3          # debug level (cmd line: -dddddddddd)
9 9
 #fork=yes          # (cmd. line: -D)
10 10
 fork=no
11 11
 log_stderror=yes # (cmd line: -E)