Browse code

minor fixes

Jiri Kuthan authored on 29/11/2001 00:32:49
Showing 4 changed files
... ...
@@ -39,8 +39,8 @@ DEFS=-DNOCR -DMACROEATER -DDNS_IP_HACK  -DSHM_MEM -DUSE_SHM_MEM #-DNO_DEBUG
39 39
 #-DNO_LOG
40 40
 
41 41
 PROFILE=  # -pg #set this if you want profiling
42
-#mode = debug
43
-mode = release
42
+mode = debug
43
+#mode = release
44 44
 
45 45
 # platform dependent settings
46 46
 
47 47
new file mode 100644
... ...
@@ -0,0 +1,6 @@
0
+file ./ser
1
+set args -f debug.cfg 
2
+break main
3
+#break dump_all_statistic
4
+break lock_initialize
5
+run
... ...
@@ -12,7 +12,7 @@ depends= $(sources:.c=.d)
12 12
 
13 13
 NAME=tm.so
14 14
 
15
-LDFLAGS=-O2 -shared
15
+SHLIB_LD_FLAGS= -shared
16 16
 LIBS= -lpthread
17 17
 
18 18
 ifeq ($(ARCH), SunOS)
... ...
@@ -28,7 +28,7 @@ endif
28 28
 
29 29
 
30 30
 $(NAME): $(objs)
31
-	$(LD) $(LDFLAGS) $(objs) $(LIBS) -o $(NAME)
31
+	$(LD) $(LDFLAGS) $(SHLIB_LD_FLAGS) $(objs) $(LIBS) -o $(NAME)
32 32
 
33 33
 
34 34
 .PHONY: all
... ...
@@ -54,13 +54,13 @@ int lock_initialize()
54 54
 
55 55
 	/* transaction timers */
56 56
 	if ((transaction_timer_semaphore=init_semaphore_set( NR_OF_TIMER_LISTS) ) < 0) {
57
-		DBG("DEBUG: lock_initialize: transaction timer semaphore allocation failure\n");
57
+                LOG(L_ERR, "ERROR: lock_initialize:  transaction timer semaphore initialization failure\n");
58 58
 		goto error;
59 59
 	}
60 60
 
61 61
 	/* message retransmission timers
62 62
         if ((retrasmission_timer_semaphore=init_semaphore_set( NR_OF_RT_LISTS) ) < 0) {
63
-                DBG("DEBUG: lock_initialize:  retransmission timer semaphore initialization failure\n");
63
+                LOG(L_ERR, "ERROR: lock_initialize:  retransmission timer semaphore initialization failure\n");
64 64
                 goto error;
65 65
         } */
66 66
 
... ...
@@ -73,7 +73,7 @@ int lock_initialize()
73 73
 			semctl( entry_semaphore, 0 , IPC_RMID , 0 );
74 74
 		entry_semaphore=init_semaphore_set( i );
75 75
 		if (entry_semaphore==-1) {
76
-                        printf("ERROR: entry semaphore initialization failure:  %s\n", strerror( errno ) );
76
+			DBG("DEBUG: lock_initialize: entry semaphore initialization failure:  %s\n", strerror( errno ) );
77 77
 			/* Solaris: EINVAL, Linux: ENOSPC */
78 78
                         if (errno==EINVAL || errno==ENOSPC ) {
79 79
                                 /* first time: step back and try again */
... ...
@@ -84,7 +84,7 @@ int lock_initialize()
84 84
                                         continue;
85 85
 				/* failure after we stepped back; give up */
86 86
                                 } else {
87
-					DBG("DEBUG: lock_initialize: second time sempahore allocation failure\n");
87
+				 	LOG(L_ERR, "ERROR: lock_initialize:   second time sempahore allocation failure\n");
88 88
 					goto error;
89 89
 				}
90 90
                         }
... ...
@@ -119,7 +119,7 @@ int init_semaphore_set( int size )
119 119
 
120 120
 	new_semaphore=semget ( IPC_PRIVATE, size, IPC_CREAT | IPC_PERMISSIONS );
121 121
 	if (new_semaphore==-1) {
122
-		DBG("DEBUG: lock_initialize:  failure to allocate a semaphore\n");
122
+		DBG("DEBUG: init_semaphore_set:  failure to allocate a semaphore\n");
123 123
 		return -1;
124 124
 	}
125 125
 	for (i=0; i<size; i++) {
... ...
@@ -131,9 +131,9 @@ int init_semaphore_set( int size )
131 131
                 /* binary lock */
132 132
                 argument.val = +1;
133 133
                 if (semctl( new_semaphore, i , SETVAL , argument )==-1) {
134
-			DBG("DEBUG: lock_initialize:  failure to initialize a semaphore\n");
134
+			DBG("DEBUG: init_semaphore_set:  failure to initialize a semaphore\n");
135 135
 			if (semctl( entry_semaphore, 0 , IPC_RMID , 0 )==-1)
136
-				DBG("DEBUG: lock_initialize:  failure to release a semaphore\n");
136
+				DBG("DEBUG: init_semaphore_set:  failure to release a semaphore\n");
137 137
 			return -2;
138 138
                 }
139 139
         }
... ...
@@ -150,30 +150,35 @@ void lock_cleanup()
150 150
 	   no other process lives 
151 151
 	*/
152 152
 
153
-	DBG("DEBUG: lock_initialize:  clean-up still not implemented properly\n");
153
+	LOG(L_INFO, "INFO: lock_cleanup:  clean-up still not implemented properly (no sibling check)\n");
154 154
 	/* sibling double-check missing here; install a signal handler */
155 155
 
156 156
 	if (entry_semaphore > 0 && 
157 157
 	    semctl( entry_semaphore, 0 , IPC_RMID , 0 )==-1)
158
-		DBG("ERROR: entry_semaphore cleanup failed\n"); 
158
+		LOG(L_ERR, "ERROR: lock_cleanup, entry_semaphore cleanup failed\n");
159 159
 	if (transaction_timer_semaphore > 0 && 
160 160
 	    semctl( transaction_timer_semaphore, 0 , IPC_RMID , 0 )==-1)
161
-		DBG("ERROR: transaction_timer_semaphore cleanup failed\n"); 
161
+		LOG(L_ERR, "ERROR: lock_cleanup, transaction_timer_semaphore cleanup failed\n");
162 162
 	if (retrasmission_timer_semaphore > 0 &&
163 163
 	    semctl( retrasmission_timer_semaphore, 0 , IPC_RMID , 0 )==-1)
164 164
 		DBG("ERROR: retrasmission_timer_semaphore cleanup failed\n"); 
165
+		LOG(L_ERR, "ERROR: lock_cleanup, retrasmission_timer_semaphore cleanup failed\n");
165 166
 	
166 167
 }
167 168
 
168 169
 /* lock sempahore s */
169 170
 int lock( ser_lock_t s )
170 171
 {
172
+	DBG("DEBUG: lock: entering lock\n");
171 173
 	return change_semaphore( s, -1 );
174
+	DBG("DEBUG: lock: leaving lock\n");
172 175
 }
173 176
 	
174 177
 int unlock( ser_lock_t s )
175 178
 {
179
+	DBG("DEBUG: unlock: entering unlock\n");
176 180
 	return change_semaphore( s, +1 );
181
+	DBG("DEBUG: unlock: leaving unlock\n");
177 182
 }
178 183
 
179 184
 
... ...
@@ -190,12 +195,10 @@ tryagain:
190 190
    r=semop( s.semaphore_set, &pbuf ,  1 /* just 1 op */ );
191 191
 
192 192
    if (r==-1) {
193
-	printf("ERROR occured in change_semaphore: %s\n", 
194
-		strerror(errno));
195 193
 	if (errno=EINTR) {
196 194
 		DBG("signal received in a semaphore\n");
197 195
 		goto tryagain;
198
-	}
196
+	} else LOG(L_ERR, "ERROR: change_semaphore: %s\n", strerror(errno));
199 197
     }
200 198
    return r;
201 199
 }