Browse code

modules_k/*: moved k modules in directory modules/

Daniel-Constantin Mierla authored on 20/01/2013 11:57:52
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,450 +0,0 @@
1
-/* $Id$
2
- *
3
- * Copyright (C) 2006-2007 VozTelecom Sistemas S.L
4
- *
5
- * This file is part of Kamailio, a free SIP server.
6
- *
7
- * Kamailio is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published by
9
- * the Free Software Foundation; either version 2 of the License, or
10
- * (at your option) any later version
11
- *
12
- * Kamailio is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
- * GNU General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU General Public License 
18
- * along with this program; if not, write to the Free Software 
19
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
- */
21
-
22
-#include <stdlib.h>
23
-#include <time.h>
24
-#include <netdb.h>
25
-#include <sys/types.h>
26
-#include <sys/socket.h>
27
-#include <sys/time.h>
28
-#include <netinet/in.h>
29
-#include <netinet/in_systm.h>
30
-#include <netinet/ip.h> /* superset of previous */
31
-#include <string.h>
32
-#include <unistd.h>
33
-#include <stdio.h>
34
-#include <signal.h>
35
-
36
-#include "statistics.h"
37
-#include "seas.h" /*SLOG*/
38
-#include "../../mem/shm_mem.h"
39
-#include "../../resolve.h"
40
-#include "../../ut.h"
41
-#include "../../dprint.h"
42
-#include "../../locking.h"
43
-#define STATS_PAY 101
44
-
45
-struct statstable*  seas_stats_table;
46
-int stats_fd;
47
-char use_stats=0;
48
-pid_t pid;
49
-
50
-static void sig_handler(int signo)
51
-{
52
-   switch(signo){
53
-      case SIGTERM:
54
-	 LM_ERR("stats process caught SIGTERM, shutting down..\n");
55
-	 close(stats_fd);
56
-	 destroy_seas_stats_table();
57
-	 exit(0);
58
-      default:
59
-	 LM_DBG("caught signal %d\n",signo);
60
-   }
61
-   LM_WARN("statistics process:caught signal (%d)\n",signo);
62
-}
63
-
64
-struct statstable* init_seas_stats_table(void)
65
-{
66
-   /*allocs the table*/
67
-   seas_stats_table= (struct statstable*)shm_malloc( sizeof( struct statstable ) );
68
-   if (!seas_stats_table) {
69
-      LM_ERR("no shmem for stats table (%d bytes)\n",(int)sizeof(struct statstable));
70
-      return 0;
71
-   }
72
-   memset(seas_stats_table, 0, sizeof(struct statstable) );
73
-   if(0==(seas_stats_table->mutex=lock_alloc())){
74
-      LM_ERR("couldn't alloc mutex (get_lock_t)\n");
75
-      shm_free(seas_stats_table);
76
-      return 0;
77
-   }
78
-   lock_init(seas_stats_table->mutex);
79
-   return seas_stats_table;
80
-}
81
-
82
-inline void destroy_seas_stats_table(void)
83
-{
84
-   /*deallocs the table*/
85
-   if(seas_stats_table){
86
-      lock_destroy(seas_stats_table->mutex);
87
-      shm_free(seas_stats_table);
88
-      seas_stats_table=(struct statstable *)0;
89
-   }
90
-}
91
-
92
-/** This will be called from within w_as_relay()
93
- *
94
- * TODO handle locking ?
95
- */
96
-inline void as_relay_stat(struct cell *t)
97
-{
98
-   struct statscell *s;
99
-   struct totag_elem *to;
100
-   if(t==0)
101
-      return;
102
-   if(t->fwded_totags != 0){
103
-      LM_DBG("seas:as_relay_stat() unable to put a payload "
104
-			  "in fwded_totags because it is being used !!\n");
105
-      return;
106
-   }
107
-   if(!(s=shm_malloc(sizeof(struct statscell)))){
108
-      return;
109
-   }
110
-   if(!(to=shm_malloc(sizeof(struct totag_elem)))){
111
-      shm_free(s);
112
-      return;
113
-   }
114
-   memset(s,0,sizeof(struct statscell));
115
-   gettimeofday(&(s->u.uas.as_relay),NULL);
116
-   s->type=UAS_T;
117
-   to->tag.len=0;
118
-   to->tag.s=(char *)s;
119
-   to->next=0;
120
-   to->acked=STATS_PAY;
121
-   t->fwded_totags=to;
122
-   lock_get(seas_stats_table->mutex);
123
-   (seas_stats_table->started_transactions)++;
124
-   lock_release(seas_stats_table->mutex);
125
-}
126
-
127
-/** this will be called from the SEAS event dispatcher
128
- * when it writes the event to the socket
129
- *
130
- * Parameters: a cell OR its hash_index and its label
131
- *
132
- * TODO handle locking/mutexing ?
133
- */
134
-inline void event_stat(struct cell *t)
135
-{
136
-   struct statscell *s;
137
-   struct totag_elem *to;
138
-   if(t==0){
139
-      /*seas_f.tmb.t_lookup_ident(&t,hash_index,label); BAD bcos it refcounts,
140
-	   * and there's no way to simply unrefcount from outside TM*/
141
-      return;
142
-   }
143
-   if(t->fwded_totags == 0){
144
-      LM_DBG("seas:event_stat() unabe to set the event_stat timeval:"
145
-			  " no payload found at cell!! (fwded_totags=0)\n");
146
-      return;
147
-   }
148
-   /*esto da un CORE DUMP cuando hay mucha carga.. warning*/
149
-   to=t->fwded_totags;
150
-   while(to){
151
-      if(to->acked==STATS_PAY){
152
-	 s=(struct statscell *)to->tag.s;
153
-	 gettimeofday(&(s->u.uas.event_sent),NULL);
154
-	 return;
155
-      }else
156
-	 to=to->next;
157
-   }
158
-   return;
159
-}
160
-
161
-/** param i is in milliseconds*/
162
-static inline int assignIndex(int i)
163
-{
164
-   return (i/100)>14?14:(i/100);
165
-}
166
-
167
-/** this will be called from the SEAS action dispatcher
168
- * when it receives the action from the socket
169
- */
170
-inline void action_stat(struct cell *t)
171
-{
172
-   unsigned int seas_dispatch,as_delay;
173
-   struct timeval *t1,*t2,*t3;
174
-   struct statscell *s;
175
-   struct totag_elem *to;
176
-   if(t==0)
177
-      return;
178
-   if(t->fwded_totags == 0){
179
-      LM_DBG("seas:event_stat() unable to set the event_stat timeval:"
180
-			  " no payload found at cell!! (fwded_totags=0)\n");
181
-      return;
182
-   }
183
-   to=t->fwded_totags;
184
-   while(to){
185
-      if(to->acked==STATS_PAY){
186
-	 s=(struct statscell *)to->tag.s;
187
-	 gettimeofday(&(s->u.uas.action_recvd),NULL);
188
-	 break;
189
-      }else
190
-	 to=to->next;
191
-   }
192
-   /**no statistics found**/
193
-   if(to==0)
194
-      return;
195
-   t1=&(s->u.uas.as_relay);
196
-   t2=&(s->u.uas.event_sent);
197
-   t3=&(s->u.uas.action_recvd);
198
-   seas_dispatch = (t2->tv_sec - t1->tv_sec)*1000 + (t2->tv_usec-t1->tv_usec)/1000;
199
-   as_delay = (t3->tv_sec - t2->tv_sec)*1000 + (t3->tv_usec-t2->tv_usec)/1000;
200
-
201
-   lock_get(seas_stats_table->mutex);
202
-   {
203
-      seas_stats_table->dispatch[assignIndex(seas_dispatch)]++;
204
-      seas_stats_table->event[assignIndex(seas_dispatch)]++;
205
-      (seas_stats_table->finished_transactions)++;
206
-   }
207
-   lock_release(seas_stats_table->mutex);
208
-}
209
-
210
-
211
-/**
212
- * stats socket sould be an IP_address:port or unix://path/to_file
213
- * TODO handling unix sockets and IPv6 !!
214
- *
215
- * returns 
216
- * 0 if no stats
217
- * 1 if stats properly started
218
- * -1 if error
219
- */
220
-int start_stats_server(char *stats_socket)
221
-{
222
-   char *p,*port;
223
-   unsigned short stats_port;
224
-   struct hostent *he;
225
-   /*use sockaddr_storage ??*/
226
-   struct sockaddr_in su;
227
-   int optval;
228
-
229
-   use_stats=0;
230
-   port=(char *)0;
231
-   he=(struct hostent *)0;
232
-   stats_fd=-1;
233
-   p=stats_socket;
234
-
235
-   if(p==0 || *p==0)
236
-      return 0;
237
-
238
-   if(!init_seas_stats_table()){
239
-      LM_ERR("unable to init stats table, disabling statistics\n");
240
-      return -1;
241
-   }
242
-   while(*p){
243
-      if(*p == ':'){
244
-	 *p=0;
245
-	 port=p+1;
246
-	 break;
247
-      }
248
-   }
249
-   if(!(he=resolvehost(stats_socket)))
250
-      goto error;
251
-   if(port==(char*)0 || *port==0)
252
-      stats_port=5088;
253
-   else if(!(stats_port=str2s(port,strlen(port),0))){
254
-	 LM_ERR("invalid port %s\n",port);
255
-	 goto error;
256
-      }
257
-   if((stats_fd=socket(he->h_addrtype, SOCK_STREAM, 0))==-1){
258
-      LM_ERR("trying to open server socket (%s)\n",strerror(errno));
259
-      goto error;
260
-   }
261
-   optval=1;
262
-   if (setsockopt(stats_fd, SOL_SOCKET, SO_REUSEADDR, (void*)&optval, sizeof(optval))==-1) {
263
-      LM_ERR("setsockopt (%s)\n",strerror(errno));
264
-      goto error;
265
-   }
266
-   su.sin_family = he->h_addrtype;
267
-   su.sin_port=htons(stats_port);
268
-   memcpy(&su.sin_addr,he->h_addr_list[0],4);
269
-   if((bind(stats_fd,(struct sockaddr*)&su,sizeof(struct sockaddr_in)))==-1){
270
-      LM_ERR( "bind (%s)\n",strerror(errno));
271
-      goto error;
272
-   }
273
-   if(listen(stats_fd, 10)==-1){
274
-      LM_ERR( "listen (%s)\n",strerror(errno));
275
-      goto error;
276
-   }
277
-   if(!(pid=fork())){/*child*/
278
-      signal(SIGTERM,sig_handler);
279
-      serve_stats(stats_fd);
280
-      printf("statistics Server Process exits !!\n");
281
-      exit(0);
282
-   }else if(pid>0){/*parent*/
283
-      close(stats_fd);
284
-   }else{/*error*/
285
-      LM_ERR("failed to create stats server process\n");
286
-      goto error;
287
-   }
288
-   use_stats=1;
289
-   return 1;
290
-error:
291
-   if(stats_fd!=-1)
292
-      close(stats_fd);
293
-   destroy_seas_stats_table();
294
-   return -1;
295
-}
296
-
297
-/**
298
- * stats socket sould be an IP_address:port or unix://path/to_file
299
- * TODO handling unix sockets and IPv6 !!
300
- *
301
- * returns 
302
- * 0 if no stats
303
- * 1 if stats properly started
304
- * -1 if error
305
- */
306
-inline int stop_stats_server(void)
307
-{
308
-   if(pid)
309
-      kill(SIGTERM,pid);
310
-   return 0;
311
-}
312
-
313
-void serve_stats(int fd)
314
-{
315
-   union sockaddr_union su;
316
-   int sock,i,retrn;
317
-   socklen_t su_len;
318
-   char f;
319
-   /* we install our signal handler..*/
320
-   signal(SIGTERM,sig_handler);
321
-   signal(SIGHUP,sig_handler);
322
-   signal(SIGPIPE,sig_handler);
323
-   signal(SIGQUIT,sig_handler);
324
-   signal(SIGINT,sig_handler);
325
-   signal(SIGCHLD,sig_handler);
326
-
327
-   while(1){
328
-      su_len = sizeof(union sockaddr_union);
329
-      sock=-1;
330
-      sock=accept(fd, &su.s, &su_len);
331
-      if(sock==-1){
332
-	 if(errno==EINTR){
333
-	    continue;
334
-	 }else{
335
-	    LM_ERR("failed to accept connection: %s\n", strerror(errno));
336
-	    return ;
337
-	 }
338
-      }
339
-      while(0!=(i=read(sock,&f,1))){
340
-	 if(i==-1){
341
-	    if(errno==EINTR){
342
-	       continue;
343
-	    }else{
344
-	       LM_ERR("unknown error reading from socket\n"); 
345
-	       close(sock);
346
-	       /** and continue accept()'ing*/
347
-	       break;
348
-	    }
349
-	 }
350
-	 retrn=print_stats_info(f,sock);
351
-	 if(retrn==-1){
352
-	    /**simple error happened, dont worry*/
353
-	       LM_ERR("printing statisticss \n");
354
-	       continue;
355
-	 }else if(retrn==-2){
356
-	    /**let's go to the outer loop, and receive more Statistics clients*/
357
-	    LM_ERR("statistics client left\n");
358
-	    close(sock);
359
-	    break;
360
-	 }
361
-      }
362
-   }
363
-}
364
-
365
-/**
366
- * (from snprintf manual)
367
- * "The  functions  snprintf()  and vsnprintf() do not write more than size bytes (including the trailing '\\0').  If the output was truncated due to
368
- * this limit then the return value is the number of characters (not including the trailing '\\0') which would have been written to the final string
369
- * if  enough space had been available. Thus, a return value of size or more means that the output was truncated."
370
- */
371
-inline int print_stats_info(int f,int sock)
372
-{
373
-#define STATS_BUF_SIZE  400
374
-   int j,k,writen;
375
-   char buf[STATS_BUF_SIZE];
376
-
377
-   writen=0;
378
-   if(0>(k=snprintf(buf,STATS_BUF_SIZE, "Timings:      0-1   1-2   2-3   3-4   4-5   5-6   6-7   7-8   8-9   9-10  10-11 11-12 12-13 13-14 14+\n"))){
379
-      goto error;
380
-   }else{
381
-      if(k>STATS_BUF_SIZE){
382
-	 j=STATS_BUF_SIZE;
383
-	 goto send;
384
-      }
385
-      j=k;
386
-   }
387
-   lock_get(seas_stats_table->mutex);
388
-   if(0>(k=snprintf(&buf[j],STATS_BUF_SIZE-j,"UAS:dispatch: %-5d %-5d %-5d %-5d %-5d %-5d %-5d %-5d %-5d %-5d %-5d %-5d %-5d %-5d %-5d\n",\
389
-	       seas_stats_table->dispatch[0],seas_stats_table->dispatch[1],seas_stats_table->dispatch[2],seas_stats_table->dispatch[3],seas_stats_table->dispatch[4]\
390
-	       ,seas_stats_table->dispatch[5],seas_stats_table->dispatch[6],seas_stats_table->dispatch[7],seas_stats_table->dispatch[8],seas_stats_table->dispatch[9],\
391
-	       seas_stats_table->dispatch[10],seas_stats_table->dispatch[11],seas_stats_table->dispatch[12],seas_stats_table->dispatch[13],seas_stats_table->dispatch[14]))){
392
-      goto error;
393
-   }else{
394
-      if(k>(STATS_BUF_SIZE-j)){
395
-	 j=STATS_BUF_SIZE;
396
-	 goto send;
397
-      }
398
-      j+=k;
399
-   }
400
-   if(0>(k=snprintf(&buf[j],STATS_BUF_SIZE-j,"UAS:event:    %-5d %-5d %-5d %-5d %-5d %-5d %-5d %-5d %-5d %-5d %-5d %-5d %-5d %-5d %-5d\n",\
401
-	       seas_stats_table->event[0],seas_stats_table->event[1],seas_stats_table->event[2],seas_stats_table->event[3],seas_stats_table->event[4]\
402
-	       ,seas_stats_table->event[5],seas_stats_table->event[6],seas_stats_table->event[7],seas_stats_table->event[8],seas_stats_table->event[9],\
403
-	       seas_stats_table->event[10],seas_stats_table->event[11],seas_stats_table->event[12],seas_stats_table->event[13],seas_stats_table->event[14]))){
404
-      goto error;
405
-   }else{
406
-      if(k>STATS_BUF_SIZE-j){
407
-	 j=STATS_BUF_SIZE;
408
-	 goto send;
409
-      }
410
-      j+=k;
411
-   }
412
-   if(0>(k=snprintf(&buf[j],STATS_BUF_SIZE-j,"Started Transactions: %d\nTerminated Transactions:%d\nReceived replies:%d\nReceived:%d\n",\
413
-	       seas_stats_table->started_transactions,seas_stats_table->finished_transactions,seas_stats_table->received_replies,seas_stats_table->received))){
414
-      goto error;
415
-   }else{
416
-      if(k>STATS_BUF_SIZE-j){
417
-	 j=STATS_BUF_SIZE;
418
-	 goto send;
419
-      }
420
-      j+=k;
421
-   }
422
-send:
423
-   lock_release(seas_stats_table->mutex);
424
-again:/*mutex is released*/
425
-   k=write(sock,buf,j);
426
-   if(k<0){
427
-      switch(errno){
428
-	 case EINTR:
429
-	    goto again;
430
-	 case EPIPE:
431
-	    return -2;
432
-      }
433
-   }
434
-   writen+=k;
435
-   if(writen<j)
436
-      goto again;
437
-   return writen;
438
-error:/*mutex is locked*/
439
-   lock_release(seas_stats_table->mutex);
440
-   return -1;
441
-}
442
-
443
-inline void stats_reply(void)
444
-{
445
-   lock_get(seas_stats_table->mutex);
446
-   seas_stats_table->received_replies++;
447
-   lock_release(seas_stats_table->mutex);
448
-}
449
-
450
-
Browse code

seas: fixed header-encoding for longest headers

-refactorings for newer sip-router TM apis
-some headers longer than 255 bytes were wrongly encoded

Elias Baixas authored on 04/10/2010 10:39:46
Showing 1 changed files
... ...
@@ -246,7 +246,7 @@ int start_stats_server(char *stats_socket)
246 246
 	 break;
247 247
       }
248 248
    }
249
-   if(!(he=resolvehost(stats_socket,0)))
249
+   if(!(he=resolvehost(stats_socket)))
250 250
       goto error;
251 251
    if(port==(char*)0 || *port==0)
252 252
       stats_port=5088;
Browse code

- change name in copyright headers

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@4518 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt authored on 28/07/2008 15:39:28
Showing 1 changed files
... ...
@@ -2,14 +2,14 @@
2 2
  *
3 3
  * Copyright (C) 2006-2007 VozTelecom Sistemas S.L
4 4
  *
5
- * This file is part of openser, a free SIP server.
5
+ * This file is part of Kamailio, a free SIP server.
6 6
  *
7
- * openser is free software; you can redistribute it and/or modify
7
+ * Kamailio is free software; you can redistribute it and/or modify
8 8
  * it under the terms of the GNU General Public License as published by
9 9
  * the Free Software Foundation; either version 2 of the License, or
10 10
  * (at your option) any later version
11 11
  *
12
- * openser is distributed in the hope that it will be useful,
12
+ * Kamailio is distributed in the hope that it will be useful,
13 13
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 14
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 15
  * GNU General Public License for more details.
Browse code

- fix some doxygen errors in comments, \0 -> \\0, #return -> return

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@4396 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt authored on 17/06/2008 10:47:00
Showing 1 changed files
... ...
@@ -364,8 +364,8 @@ void serve_stats(int fd)
364 364
 
365 365
 /**
366 366
  * (from snprintf manual)
367
- * "The  functions  snprintf()  and vsnprintf() do not write more than size bytes (including the trailing '\0').  If the output was truncated due to
368
- * this limit then the return value is the number of characters (not including the trailing '\0') which would have been written to the final string
367
+ * "The  functions  snprintf()  and vsnprintf() do not write more than size bytes (including the trailing '\\0').  If the output was truncated due to
368
+ * this limit then the return value is the number of characters (not including the trailing '\\0') which would have been written to the final string
369 369
  * if  enough space had been available. Thus, a return value of size or more means that the output was truncated."
370 370
  */
371 371
 inline int print_stats_info(int f,int sock)
Browse code

- changed LOG with LM_*

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@2943 689a6050-402a-0410-94f2-e92a70836424

Anca Vamanu authored on 19/10/2007 15:15:01
Showing 1 changed files
... ...
@@ -51,14 +51,14 @@ static void sig_handler(int signo)
51 51
 {
52 52
    switch(signo){
53 53
       case SIGTERM:
54
-	 LOG(L_ERR,"Stats process caught SIGTERM, shutting down..\n");
54
+	 LM_ERR("stats process caught SIGTERM, shutting down..\n");
55 55
 	 close(stats_fd);
56 56
 	 destroy_seas_stats_table();
57 57
 	 exit(0);
58 58
       default:
59
-	 LOG(L_DBG,"caught signal %d\n",signo);
59
+	 LM_DBG("caught signal %d\n",signo);
60 60
    }
61
-   LOG(L_WARN,"Statistics process:caught signal (%d)\n",signo);
61
+   LM_WARN("statistics process:caught signal (%d)\n",signo);
62 62
 }
63 63
 
64 64
 struct statstable* init_seas_stats_table(void)
... ...
@@ -66,12 +66,12 @@ struct statstable* init_seas_stats_table(void)
66 66
    /*allocs the table*/
67 67
    seas_stats_table= (struct statstable*)shm_malloc( sizeof( struct statstable ) );
68 68
    if (!seas_stats_table) {
69
-      LOG(L_ERR, "no shmem for stats table (%d bytes)\n",(int)sizeof(struct statstable));
69
+      LM_ERR("no shmem for stats table (%d bytes)\n",(int)sizeof(struct statstable));
70 70
       return 0;
71 71
    }
72 72
    memset(seas_stats_table, 0, sizeof(struct statstable) );
73 73
    if(0==(seas_stats_table->mutex=lock_alloc())){
74
-      LOG(L_ERR,"couldn't alloc mutex (get_lock_t)\n");
74
+      LM_ERR("couldn't alloc mutex (get_lock_t)\n");
75 75
       shm_free(seas_stats_table);
76 76
       return 0;
77 77
    }
... ...
@@ -100,7 +100,8 @@ inline void as_relay_stat(struct cell *t)
100 100
    if(t==0)
101 101
       return;
102 102
    if(t->fwded_totags != 0){
103
-      LOG(L_DBG,"seas:as_relay_stat() unable to put a payload in fwded_totags because it is being used !!\n");
103
+      LM_DBG("seas:as_relay_stat() unable to put a payload "
104
+			  "in fwded_totags because it is being used !!\n");
104 105
       return;
105 106
    }
106 107
    if(!(s=shm_malloc(sizeof(struct statscell)))){
... ...
@@ -135,11 +136,13 @@ inline void event_stat(struct cell *t)
135 136
    struct statscell *s;
136 137
    struct totag_elem *to;
137 138
    if(t==0){
138
-      /*seas_f.tmb.t_lookup_ident(&t,hash_index,label); BAD bcos it refcounts, and there's no way to simply unrefcount from outside TM*/
139
+      /*seas_f.tmb.t_lookup_ident(&t,hash_index,label); BAD bcos it refcounts,
140
+	   * and there's no way to simply unrefcount from outside TM*/
139 141
       return;
140 142
    }
141 143
    if(t->fwded_totags == 0){
142
-      LOG(L_DBG,"seas:event_stat() unabe to set the event_stat timeval: no payload found at cell!! (fwded_totags=0)\n");
144
+      LM_DBG("seas:event_stat() unabe to set the event_stat timeval:"
145
+			  " no payload found at cell!! (fwded_totags=0)\n");
143 146
       return;
144 147
    }
145 148
    /*esto da un CORE DUMP cuando hay mucha carga.. warning*/
... ...
@@ -173,7 +176,8 @@ inline void action_stat(struct cell *t)
173 176
    if(t==0)
174 177
       return;
175 178
    if(t->fwded_totags == 0){
176
-      LOG(L_DBG,"seas:event_stat() unable to set the event_stat timeval: no payload found at cell!! (fwded_totags=0)\n");
179
+      LM_DBG("seas:event_stat() unable to set the event_stat timeval:"
180
+			  " no payload found at cell!! (fwded_totags=0)\n");
177 181
       return;
178 182
    }
179 183
    to=t->fwded_totags;
... ...
@@ -232,7 +236,7 @@ int start_stats_server(char *stats_socket)
232 236
       return 0;
233 237
 
234 238
    if(!init_seas_stats_table()){
235
-      LOG(L_ERR,"unable to init stats table, disabling statistics\n");
239
+      LM_ERR("unable to init stats table, disabling statistics\n");
236 240
       return -1;
237 241
    }
238 242
    while(*p){
... ...
@@ -247,38 +251,38 @@ int start_stats_server(char *stats_socket)
247 251
    if(port==(char*)0 || *port==0)
248 252
       stats_port=5088;
249 253
    else if(!(stats_port=str2s(port,strlen(port),0))){
250
-	 LOG(L_ERR,"invalid port %s\n",port);
254
+	 LM_ERR("invalid port %s\n",port);
251 255
 	 goto error;
252 256
       }
253 257
    if((stats_fd=socket(he->h_addrtype, SOCK_STREAM, 0))==-1){
254
-      LOG(L_ERR,"trying to open server socket (%s)\n",strerror(errno));
258
+      LM_ERR("trying to open server socket (%s)\n",strerror(errno));
255 259
       goto error;
256 260
    }
257 261
    optval=1;
258 262
    if (setsockopt(stats_fd, SOL_SOCKET, SO_REUSEADDR, (void*)&optval, sizeof(optval))==-1) {
259
-      LOG(L_ERR,"setsockopt (%s)\n",strerror(errno));
263
+      LM_ERR("setsockopt (%s)\n",strerror(errno));
260 264
       goto error;
261 265
    }
262 266
    su.sin_family = he->h_addrtype;
263 267
    su.sin_port=htons(stats_port);
264 268
    memcpy(&su.sin_addr,he->h_addr_list[0],4);
265 269
    if((bind(stats_fd,(struct sockaddr*)&su,sizeof(struct sockaddr_in)))==-1){
266
-      LOG(L_ERR, "bind (%s)\n",strerror(errno));
270
+      LM_ERR( "bind (%s)\n",strerror(errno));
267 271
       goto error;
268 272
    }
269 273
    if(listen(stats_fd, 10)==-1){
270
-      LOG(L_ERR, "listen (%s)\n",strerror(errno));
274
+      LM_ERR( "listen (%s)\n",strerror(errno));
271 275
       goto error;
272 276
    }
273 277
    if(!(pid=fork())){/*child*/
274 278
       signal(SIGTERM,sig_handler);
275 279
       serve_stats(stats_fd);
276
-      printf("Statistics Server Process exits !!\n");
280
+      printf("statistics Server Process exits !!\n");
277 281
       exit(0);
278 282
    }else if(pid>0){/*parent*/
279 283
       close(stats_fd);
280 284
    }else{/*error*/
281
-      LOG(L_ERR,"Unable to create stats server process\n");
285
+      LM_ERR("failed to create stats server process\n");
282 286
       goto error;
283 287
    }
284 288
    use_stats=1;
... ...
@@ -328,7 +332,7 @@ void serve_stats(int fd)
328 332
 	 if(errno==EINTR){
329 333
 	    continue;
330 334
 	 }else{
331
-	    LOG(L_ERR,  "error while accepting connection: %s\n", strerror(errno));
335
+	    LM_ERR("failed to accept connection: %s\n", strerror(errno));
332 336
 	    return ;
333 337
 	 }
334 338
       }
... ...
@@ -337,7 +341,7 @@ void serve_stats(int fd)
337 341
 	    if(errno==EINTR){
338 342
 	       continue;
339 343
 	    }else{
340
-	       LOG(L_ERR,"unknown error reading from socket\n"); 
344
+	       LM_ERR("unknown error reading from socket\n"); 
341 345
 	       close(sock);
342 346
 	       /** and continue accept()'ing*/
343 347
 	       break;
... ...
@@ -346,11 +350,11 @@ void serve_stats(int fd)
346 350
 	 retrn=print_stats_info(f,sock);
347 351
 	 if(retrn==-1){
348 352
 	    /**simple error happened, dont worry*/
349
-	       LOG(L_ERR,"printing statistics \n");
353
+	       LM_ERR("printing statisticss \n");
350 354
 	       continue;
351 355
 	 }else if(retrn==-2){
352 356
 	    /**let's go to the outer loop, and receive more Statistics clients*/
353
-	    LOG(L_ERR,"Statistics client left\n");
357
+	    LM_ERR("statistics client left\n");
354 358
 	    close(sock);
355 359
 	    break;
356 360
 	 }
... ...
@@ -371,7 +375,7 @@ inline int print_stats_info(int f,int sock)
371 375
    char buf[STATS_BUF_SIZE];
372 376
 
373 377
    writen=0;
374
-   if(0>(k=snprintf(buf,STATS_BUF_SIZE,      "Timings:      0-1   1-2   2-3   3-4   4-5   5-6   6-7   7-8   8-9   9-10  10-11 11-12 12-13 13-14 14+\n"))){
378
+   if(0>(k=snprintf(buf,STATS_BUF_SIZE, "Timings:      0-1   1-2   2-3   3-4   4-5   5-6   6-7   7-8   8-9   9-10  10-11 11-12 12-13 13-14 14+\n"))){
375 379
       goto error;
376 380
    }else{
377 381
       if(k>STATS_BUF_SIZE){
Browse code

- add -Wold-style-definition to Makefile.defs, to warn about ancient C syntax - fix old definitions in core and default modules (mostly add missing void) - change really old syntax in md5.c - increase devel version

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@2657 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt authored on 28/08/2007 15:03:09
Showing 1 changed files
... ...
@@ -61,7 +61,7 @@ static void sig_handler(int signo)
61 61
    LOG(L_WARN,"Statistics process:caught signal (%d)\n",signo);
62 62
 }
63 63
 
64
-struct statstable* init_seas_stats_table()
64
+struct statstable* init_seas_stats_table(void)
65 65
 {
66 66
    /*allocs the table*/
67 67
    seas_stats_table= (struct statstable*)shm_malloc( sizeof( struct statstable ) );
... ...
@@ -79,7 +79,7 @@ struct statstable* init_seas_stats_table()
79 79
    return seas_stats_table;
80 80
 }
81 81
 
82
-inline void destroy_seas_stats_table()
82
+inline void destroy_seas_stats_table(void)
83 83
 {
84 84
    /*deallocs the table*/
85 85
    if(seas_stats_table){
... ...
@@ -299,7 +299,7 @@ error:
299 299
  * 1 if stats properly started
300 300
  * -1 if error
301 301
  */
302
-inline int stop_stats_server()
302
+inline int stop_stats_server(void)
303 303
 {
304 304
    if(pid)
305 305
       kill(SIGTERM,pid);
... ...
@@ -436,7 +436,7 @@ error:/*mutex is locked*/
436 436
    return -1;
437 437
 }
438 438
 
439
-inline void stats_reply()
439
+inline void stats_reply(void)
440 440
 {
441 441
    lock_get(seas_stats_table->mutex);
442 442
    seas_stats_table->received_replies++;
Browse code

- added license and copyright

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@1819 689a6050-402a-0410-94f2-e92a70836424

Daniel-Constantin Mierla authored on 11/03/2007 19:20:59
Showing 1 changed files
... ...
@@ -1,4 +1,24 @@
1
-/* $Id$ */
1
+/* $Id$
2
+ *
3
+ * Copyright (C) 2006-2007 VozTelecom Sistemas S.L
4
+ *
5
+ * This file is part of openser, a free SIP server.
6
+ *
7
+ * openser is free software; you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation; either version 2 of the License, or
10
+ * (at your option) any later version
11
+ *
12
+ * openser is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License 
18
+ * along with this program; if not, write to the Free Software 
19
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
+ */
21
+
2 22
 #include <stdlib.h>
3 23
 #include <time.h>
4 24
 #include <netdb.h>
Browse code

fixed several warning and incomplete initializers

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@1808 689a6050-402a-0410-94f2-e92a70836424

Bogdan-Andrei Iancu authored on 10/03/2007 17:36:19
Showing 1 changed files
... ...
@@ -59,7 +59,7 @@ struct statstable* init_seas_stats_table()
59 59
    return seas_stats_table;
60 60
 }
61 61
 
62
-void inline destroy_seas_stats_table()
62
+inline void destroy_seas_stats_table()
63 63
 {
64 64
    /*deallocs the table*/
65 65
    if(seas_stats_table){
... ...
@@ -279,7 +279,7 @@ error:
279 279
  * 1 if stats properly started
280 280
  * -1 if error
281 281
  */
282
-int inline stop_stats_server()
282
+inline int stop_stats_server()
283 283
 {
284 284
    if(pid)
285 285
       kill(SIGTERM,pid);
Browse code

- fixed compile error on solaris

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@1785 689a6050-402a-0410-94f2-e92a70836424

Bogdan-Andrei Iancu authored on 09/03/2007 16:49:40
Showing 1 changed files
... ...
@@ -6,6 +6,7 @@
6 6
 #include <sys/socket.h>
7 7
 #include <sys/time.h>
8 8
 #include <netinet/in.h>
9
+#include <netinet/in_systm.h>
9 10
 #include <netinet/ip.h> /* superset of previous */
10 11
 #include <string.h>
11 12
 #include <unistd.h>
Browse code

reverted to old logging system. fixed a couple of warnings regarding printf("%d",(int)sizeof(something))

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@1767 689a6050-402a-0410-94f2-e92a70836424

Elias Baixas authored on 08/03/2007 11:08:03
Showing 1 changed files
... ...
@@ -30,14 +30,14 @@ static void sig_handler(int signo)
30 30
 {
31 31
    switch(signo){
32 32
       case SIGTERM:
33
-	 SLOG(L_ERR,"Stats process caught SIGTERM, shutting down..\n");
33
+	 LOG(L_ERR,"Stats process caught SIGTERM, shutting down..\n");
34 34
 	 close(stats_fd);
35 35
 	 destroy_seas_stats_table();
36 36
 	 exit(0);
37 37
       default:
38
-	 SLOG(L_DBG,"caught signal %d\n",signo);
38
+	 LOG(L_DBG,"caught signal %d\n",signo);
39 39
    }
40
-   SLOG(L_WARN,"Statistics process:caught signal (%d)\n",signo);
40
+   LOG(L_WARN,"Statistics process:caught signal (%d)\n",signo);
41 41
 }
42 42
 
43 43
 struct statstable* init_seas_stats_table()
... ...
@@ -45,12 +45,12 @@ struct statstable* init_seas_stats_table()
45 45
    /*allocs the table*/
46 46
    seas_stats_table= (struct statstable*)shm_malloc( sizeof( struct statstable ) );
47 47
    if (!seas_stats_table) {
48
-      SLOG(L_ERR, "no shmem for stats table (%d bytes)\n",sizeof(struct statstable));
48
+      LOG(L_ERR, "no shmem for stats table (%d bytes)\n",(int)sizeof(struct statstable));
49 49
       return 0;
50 50
    }
51 51
    memset(seas_stats_table, 0, sizeof(struct statstable) );
52 52
    if(0==(seas_stats_table->mutex=lock_alloc())){
53
-      SLOG(L_ERR,"couldn't alloc mutex (get_lock_t)\n");
53
+      LOG(L_ERR,"couldn't alloc mutex (get_lock_t)\n");
54 54
       shm_free(seas_stats_table);
55 55
       return 0;
56 56
    }
... ...
@@ -79,7 +79,7 @@ inline void as_relay_stat(struct cell *t)
79 79
    if(t==0)
80 80
       return;
81 81
    if(t->fwded_totags != 0){
82
-      SLOG(L_DBG,"seas:as_relay_stat() unable to put a payload in fwded_totags because it is being used !!\n");
82
+      LOG(L_DBG,"seas:as_relay_stat() unable to put a payload in fwded_totags because it is being used !!\n");
83 83
       return;
84 84
    }
85 85
    if(!(s=shm_malloc(sizeof(struct statscell)))){
... ...
@@ -118,7 +118,7 @@ inline void event_stat(struct cell *t)
118 118
       return;
119 119
    }
120 120
    if(t->fwded_totags == 0){
121
-      SLOG(L_DBG,"seas:event_stat() unabe to set the event_stat timeval: no payload found at cell!! (fwded_totags=0)\n");
121
+      LOG(L_DBG,"seas:event_stat() unabe to set the event_stat timeval: no payload found at cell!! (fwded_totags=0)\n");
122 122
       return;
123 123
    }
124 124
    /*esto da un CORE DUMP cuando hay mucha carga.. warning*/
... ...
@@ -152,7 +152,7 @@ inline void action_stat(struct cell *t)
152 152
    if(t==0)
153 153
       return;
154 154
    if(t->fwded_totags == 0){
155
-      SLOG(L_DBG,"seas:event_stat() unable to set the event_stat timeval: no payload found at cell!! (fwded_totags=0)\n");
155
+      LOG(L_DBG,"seas:event_stat() unable to set the event_stat timeval: no payload found at cell!! (fwded_totags=0)\n");
156 156
       return;
157 157
    }
158 158
    to=t->fwded_totags;
... ...
@@ -211,7 +211,7 @@ int start_stats_server(char *stats_socket)
211 211
       return 0;
212 212
 
213 213
    if(!init_seas_stats_table()){
214
-      SLOG(L_ERR,"unable to init stats table, disabling statistics\n");
214
+      LOG(L_ERR,"unable to init stats table, disabling statistics\n");
215 215
       return -1;
216 216
    }
217 217
    while(*p){
... ...
@@ -226,27 +226,27 @@ int start_stats_server(char *stats_socket)
226 226
    if(port==(char*)0 || *port==0)
227 227
       stats_port=5088;
228 228
    else if(!(stats_port=str2s(port,strlen(port),0))){
229
-	 SLOG(L_ERR,"invalid port %s\n",port);
229
+	 LOG(L_ERR,"invalid port %s\n",port);
230 230
 	 goto error;
231 231
       }
232 232
    if((stats_fd=socket(he->h_addrtype, SOCK_STREAM, 0))==-1){
233
-      SLOG(L_ERR,"trying to open server socket (%s)\n",strerror(errno));
233
+      LOG(L_ERR,"trying to open server socket (%s)\n",strerror(errno));
234 234
       goto error;
235 235
    }
236 236
    optval=1;
237 237
    if (setsockopt(stats_fd, SOL_SOCKET, SO_REUSEADDR, (void*)&optval, sizeof(optval))==-1) {
238
-      SLOG(L_ERR,"setsockopt (%s)\n",strerror(errno));
238
+      LOG(L_ERR,"setsockopt (%s)\n",strerror(errno));
239 239
       goto error;
240 240
    }
241 241
    su.sin_family = he->h_addrtype;
242 242
    su.sin_port=htons(stats_port);
243 243
    memcpy(&su.sin_addr,he->h_addr_list[0],4);
244 244
    if((bind(stats_fd,(struct sockaddr*)&su,sizeof(struct sockaddr_in)))==-1){
245
-      SLOG(L_ERR, "bind (%s)\n",strerror(errno));
245
+      LOG(L_ERR, "bind (%s)\n",strerror(errno));
246 246
       goto error;
247 247
    }
248 248
    if(listen(stats_fd, 10)==-1){
249
-      SLOG(L_ERR, "listen (%s)\n",strerror(errno));
249
+      LOG(L_ERR, "listen (%s)\n",strerror(errno));
250 250
       goto error;
251 251
    }
252 252
    if(!(pid=fork())){/*child*/
... ...
@@ -257,7 +257,7 @@ int start_stats_server(char *stats_socket)
257 257
    }else if(pid>0){/*parent*/
258 258
       close(stats_fd);
259 259
    }else{/*error*/
260
-      SLOG(L_ERR,"Unable to create stats server process\n");
260
+      LOG(L_ERR,"Unable to create stats server process\n");
261 261
       goto error;
262 262
    }
263 263
    use_stats=1;
... ...
@@ -307,7 +307,7 @@ void serve_stats(int fd)
307 307
 	 if(errno==EINTR){
308 308
 	    continue;
309 309
 	 }else{
310
-	    SLOG(L_ERR,  "error while accepting connection: %s\n", strerror(errno));
310
+	    LOG(L_ERR,  "error while accepting connection: %s\n", strerror(errno));
311 311
 	    return ;
312 312
 	 }
313 313
       }
... ...
@@ -316,7 +316,7 @@ void serve_stats(int fd)
316 316
 	    if(errno==EINTR){
317 317
 	       continue;
318 318
 	    }else{
319
-	       SLOG(L_ERR,"unknown error reading from socket\n"); 
319
+	       LOG(L_ERR,"unknown error reading from socket\n"); 
320 320
 	       close(sock);
321 321
 	       /** and continue accept()'ing*/
322 322
 	       break;
... ...
@@ -325,11 +325,11 @@ void serve_stats(int fd)
325 325
 	 retrn=print_stats_info(f,sock);
326 326
 	 if(retrn==-1){
327 327
 	    /**simple error happened, dont worry*/
328
-	       SLOG(L_ERR,"printing statistics \n");
328
+	       LOG(L_ERR,"printing statistics \n");
329 329
 	       continue;
330 330
 	 }else if(retrn==-2){
331 331
 	    /**let's go to the outer loop, and receive more Statistics clients*/
332
-	    SLOG(L_ERR,"Statistics client left\n");
332
+	    LOG(L_ERR,"Statistics client left\n");
333 333
 	    close(sock);
334 334
 	    break;
335 335
 	 }
Browse code

Changed the logging system

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@1725 689a6050-402a-0410-94f2-e92a70836424

Elias Baixas authored on 01/03/2007 17:25:55
Showing 1 changed files
... ...
@@ -13,6 +13,7 @@
13 13
 #include <signal.h>
14 14
 
15 15
 #include "statistics.h"
16
+#include "seas.h" /*SLOG*/
16 17
 #include "../../mem/shm_mem.h"
17 18
 #include "../../resolve.h"
18 19
 #include "../../ut.h"
... ...
@@ -29,14 +30,14 @@ static void sig_handler(int signo)
29 30
 {
30 31
    switch(signo){
31 32
       case SIGTERM:
32
-	 LOG(L_ERR,"Stats process caught SIGTERM, shutting down..\n");
33
+	 SLOG(L_ERR,"Stats process caught SIGTERM, shutting down..\n");
33 34
 	 close(stats_fd);
34 35