core: added new event SREV_CORE_STATS
authorDaniel-Constantin Mierla <miconda@gmail.com>
Tue, 13 Oct 2009 18:47:35 +0000 (20:47 +0200)
committerAndrei Pelinescu-Onciul <andrei@iptel.org>
Mon, 1 Feb 2010 15:51:13 +0000 (16:51 +0100)
- to be used by Kamailio core statistics not included in stock SR core
(cherry picked from commit 47c89177ce276cdf8f6a2d06fdd3359ba283fe4c)

events.c
events.h

index 0d07395..be98221 100644 (file)
--- a/events.c
+++ b/events.c
@@ -48,6 +48,11 @@ int sr_event_register_cb(int type, sr_event_cb_f f)
                                        _sr_events_list.net_data_out = f;
                                else return -1;
                        break;
+               case SREV_CORE_STATS:
+                               if(_sr_events_list.core_stats==0)
+                                       _sr_events_list.core_stats = f;
+                               else return -1;
+                       break;
                default:
                        return -1;
        }
@@ -91,6 +96,13 @@ int sr_event_exec(int type, void *data)
                                        return ret;
                                } else return 1;
                        break;
+               case SREV_CORE_STATS:
+                               if(unlikely(_sr_events_list.core_stats!=0))
+                               {
+                                       ret = _sr_events_list.core_stats(data);
+                                       return ret;
+                               } else return 1;
+                       break;
                default:
                        return -1;
        }
index 9fda619..9af0d71 100644 (file)
--- a/events.h
+++ b/events.h
 
 #define SREV_NET_DATA_IN       1
 #define SREV_NET_DATA_OUT      2
+#define SREV_CORE_STATS                3
 
 typedef int (*sr_event_cb_f)(void *data);
 
 typedef struct sr_event_cb {
        sr_event_cb_f net_data_in;
        sr_event_cb_f net_data_out;
+       sr_event_cb_f core_stats;
 } sr_event_cb_t;
 
 void sr_event_cb_init(void);