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 81
 	i=SEM_MIN;
81 82
 	/* probing phase: 0=initial, 1=after the first failure */
82 83
 	probe_run=0;
84
+again:
83 85
 	do {
84 86
 		if (entry_semaphore>0) /* clean-up previous attempt */
85 87
 			semctl( entry_semaphore, 0 , IPC_RMID , 0 );
88
+		if (reply_semaphore>0)
89
+			semctl(reply_semaphore, 0 , IPC_RMID , 0 );
90
+		if (ack_semaphore>0)
91
+			semctl(reply_semaphore, 0 , IPC_RMID , 0 );
92
+
93
+		if (i==0){
94
+			LOG(L_CRIT, "lock_initialize: could not allocate semaphore"
95
+					" sets\n");
96
+			goto error;
97
+		}
98
+
86 99
 		entry_semaphore=init_semaphore_set( i );
87 100
 		if (entry_semaphore==-1) {
88
-			DBG("DEBUG: lock_initialize: entry semaphore initialization failure:  %s\n", strerror( errno ) );
101
+			DBG("DEBUG: lock_initialize: entry semaphore "
102
+					"initialization failure:  %s\n", strerror( errno ) );
89 103
 			/* Solaris: EINVAL, Linux: ENOSPC */
90 104
                         if (errno==EINVAL || errno==ENOSPC ) {
91 105
                                 /* first time: step back and try again */
92 106
                                 if (probe_run==0) {
93
-					DBG("DEBUG: lock_initialize: first time sempahore allocation failure\n");
107
+					DBG("DEBUG: lock_initialize: first time "
108
+								"semaphore allocation failure\n");
94 109
                                         i--;
95 110
                                         probe_run=1;
96 111
                                         continue;
97 112
 				/* failure after we stepped back; give up */
98 113
                                 } else {
99
-				 	LOG(L_ERR, "ERROR: lock_initialize:   second time sempahore allocation failure\n");
114
+				 	DBG("DEBUG: lock_initialize:   second time sempahore allocation failure\n");
100 115
 					goto error;
101 116
 				}
102 117
                         }
... ...
@@ -116,8 +131,34 @@ int lock_initialize()
116 131
 	} while(1);
117 132
 	sem_nr=i;	
118 133
 
119
-	reply_semaphore=init_semaphore_set( sem_nr );
120
-	ack_semaphore=init_semaphore_set(sem_nr);
134
+	if ((reply_semaphore=init_semaphore_set( sem_nr ))<0){
135
+		if (errno==EINVAL || errno==ENOSPC ) {
136
+			DBG("DEBUG:lock_initialize: reply semaphore initialization"
137
+				" failure: %s\n", strerror(errno));
138
+			probe_run==1;
139
+			i--;
140
+			goto again;
141
+		}else{
142
+			LOG(L_CRIT, "ERROR:lock_initialize: reply semaphore initialization"
143
+				" failure: %s\n", strerror(errno));
144
+			goto error;
145
+		}
146
+	}
147
+	
148
+	if ((ack_semaphore=init_semaphore_set(sem_nr))<0){
149
+		if (errno==EINVAL || errno==ENOSPC ) {
150
+			DBG( "DEBUG:lock_initialize: ack semaphore initialization"
151
+				" failure: %s\n", strerror(errno));
152
+			probe_run==1;
153
+			i--;
154
+			goto again;
155
+		}else{
156
+			LOG(L_CRIT, "ERROR:lock_initialize: ack semaphore initialization"
157
+				" failure: %s\n", strerror(errno));
158
+			goto error;
159
+		}
160
+	}
161
+
121 162
 
122 163
 
123 164
 	/* return success */
... ...
@@ -135,8 +176,8 @@ static int init_semaphore_set( int size )
135 176
 
136 177
 	new_semaphore=semget ( IPC_PRIVATE, size, IPC_CREAT | IPC_PERMISSIONS );
137 178
 	if (new_semaphore==-1) {
138
-		LOG(L_CRIT, "ERROR: init_semaphore_set:  failure to allocate a"
139
-					" semaphore: %s\n", strerror(errno));
179
+		DBG("DEBUG: init_semaphore_set(%d):  failure to allocate a"
180
+					" semaphore: %s\n", size, strerror(errno));
140 181
 		return -1;
141 182
 	}
142 183
 	for (i=0; i<size; i++) {
... ...
@@ -148,7 +189,7 @@ static int init_semaphore_set( int size )
148 189
                 /* binary lock */
149 190
                 argument.val = +1;
150 191
                 if (semctl( new_semaphore, i , SETVAL , argument )==-1) {
151
-			LOG(L_CRIT, "ERROR: init_semaphore_set:  failure to "
192
+			DBG("DEBUG: init_semaphore_set:  failure to "
152 193
 						"initialize a semaphore: %s\n", strerror(errno));
153 194
 			if (semctl( entry_semaphore, 0 , IPC_RMID , 0 )==-1)
154 195
 				DBG("DEBUG: init_semaphore_set:  failure to release"
... ...
@@ -235,9 +276,9 @@ tryagain:
235 276
 			goto tryagain;
236 277
 		} else {
237 278
 			LOG(L_CRIT, "ERROR: change_semaphore(%x, %x, 1) : %s\n",
238
-					s.semaphore.set, &pbuf,
279
+					s.semaphore_set, &pbuf,
239 280
 					strerror(errno));
240
-			
281
+		}
241 282
 	}
242 283
 	return r;
243 284
 }
... ...
@@ -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)