Browse code

core: repaced the two pkg update event callbacks with one

- simplified usage as can be executed at the end of memory operations
(malloc, free, realloc)

Daniel-Constantin Mierla authored on 03/05/2014 18:02:47
Showing 2 changed files
... ...
@@ -117,14 +117,9 @@ int sr_event_register_cb(int type, sr_event_cb_f f)
117 117
 					_sr_events_list.run_action = f;
118 118
 				else return -1;
119 119
 			break;
120
-		case SREV_PKG_SET_USED:
121
-				if(_sr_events_list.pkg_set_used==0)
122
-					_sr_events_list.pkg_set_used = f;
123
-				else return -1;
124
-			break;
125
-		case SREV_PKG_SET_REAL_USED:
126
-				if(_sr_events_list.pkg_set_real_used==0)
127
-					_sr_events_list.pkg_set_real_used = f;
120
+		case SREV_PKG_UPDATE_STATS:
121
+				if(_sr_events_list.pkg_update_stats==0)
122
+					_sr_events_list.pkg_update_stats = f;
128 123
 				else return -1;
129 124
 			break;
130 125
 		case SREV_NET_DGRAM_IN:
... ...
@@ -218,16 +213,10 @@ int sr_event_exec(int type, void *data)
218 218
 					ret = _sr_events_list.run_action(data);
219 219
 					return ret;
220 220
 				} else return 1;
221
-		case SREV_PKG_SET_USED:
222
-				if(unlikely(_sr_events_list.pkg_set_used!=0))
223
-				{
224
-					ret = _sr_events_list.pkg_set_used(data);
225
-					return ret;
226
-				} else return 1;
227
-		case SREV_PKG_SET_REAL_USED:
228
-				if(unlikely(_sr_events_list.pkg_set_real_used!=0))
221
+		case SREV_PKG_UPDATE_STATS:
222
+				if(unlikely(_sr_events_list.pkg_update_stats!=0))
229 223
 				{
230
-					ret = _sr_events_list.pkg_set_real_used(data);
224
+					ret = _sr_events_list.pkg_update_stats(data);
231 225
 					return ret;
232 226
 				} else return 1;
233 227
 		case SREV_NET_DGRAM_IN:
... ...
@@ -285,10 +274,8 @@ int sr_event_enabled(int type)
285 285
 				return (_sr_events_list.core_stats!=0)?1:0;
286 286
 		case SREV_CFG_RUN_ACTION:
287 287
 				return (_sr_events_list.run_action!=0)?1:0;
288
-		case SREV_PKG_SET_USED:
289
-				return (_sr_events_list.pkg_set_used!=0)?1:0;
290
-		case SREV_PKG_SET_REAL_USED:
291
-				return (_sr_events_list.pkg_set_real_used!=0)?1:0;
288
+		case SREV_PKG_UPDATE_STATS:
289
+				return (_sr_events_list.pkg_update_stats!=0)?1:0;
292 290
 		case SREV_NET_DGRAM_IN:
293 291
 				return (_sr_events_list.net_dgram_in!=0)?1:0;
294 292
 		case SREV_TCP_HTTP_100C:
... ...
@@ -27,8 +27,8 @@
27 27
 #define SREV_NET_DATA_OUT		2
28 28
 #define SREV_CORE_STATS			3
29 29
 #define SREV_CFG_RUN_ACTION		4
30
-#define SREV_PKG_SET_USED		5
31
-#define SREV_PKG_SET_REAL_USED		6
30
+#define SREV_PKG_UPDATE_STATS	5
31
+/*		6 - not used anymore */
32 32
 #define SREV_NET_DGRAM_IN		7
33 33
 #define SREV_TCP_HTTP_100C		8
34 34
 #define SREV_TCP_MSRP_FRAME		9
... ...
@@ -44,8 +44,7 @@ typedef struct sr_event_cb {
44 44
 	sr_event_cb_f net_data_out;
45 45
 	sr_event_cb_f core_stats;
46 46
 	sr_event_cb_f run_action;
47
-	sr_event_cb_f pkg_set_used;
48
-	sr_event_cb_f pkg_set_real_used;
47
+	sr_event_cb_f pkg_update_stats;
49 48
 	sr_event_cb_f net_dgram_in;
50 49
 	sr_event_cb_f tcp_http_100c;
51 50
 	sr_event_cb_f tcp_msrp_frame;