- use if (unlikely(...)) when executing the callbacks (optimize
for the case where there are no callbacks)
- debugging info printed only #if EXTRA_DEBUG
... | ... |
@@ -60,26 +60,34 @@ int sr_event_exec(int type, void *data) |
60 | 60 |
str *p; |
61 | 61 |
switch(type) { |
62 | 62 |
case SREV_NET_DATA_IN: |
63 |
- if(_sr_events_list.net_data_in!=0) |
|
63 |
+ if(unlikely(_sr_events_list.net_data_in!=0)) |
|
64 | 64 |
{ |
65 | 65 |
p = (str*)data; |
66 |
+#ifdef EXTRA_DEBUG |
|
66 | 67 |
LM_DBG("PRE-IN ++++++++++++++++++++++++++++++++\n" |
67 | 68 |
"%.*s\n+++++\n", p->len, p->s); |
69 |
+#endif /* EXTRA_DEBUG */ |
|
68 | 70 |
ret = _sr_events_list.net_data_in(data); |
71 |
+#ifdef EXTRA_DEBUG |
|
69 | 72 |
LM_DBG("POST-IN ++++++++++++++++++++++++++++++++\n" |
70 | 73 |
"%.*s\n+++++\n", p->len, p->s); |
74 |
+#endif /* EXTRA_DEBUG */ |
|
71 | 75 |
return ret; |
72 | 76 |
} else return 1; |
73 | 77 |
break; |
74 | 78 |
case SREV_NET_DATA_OUT: |
75 |
- if(_sr_events_list.net_data_out!=0) |
|
79 |
+ if(unlikely(_sr_events_list.net_data_out!=0)) |
|
76 | 80 |
{ |
77 | 81 |
p = (str*)data; |
82 |
+#ifdef EXTRA_DEBUG |
|
78 | 83 |
LM_DBG("PRE-OUT ++++++++++++++++++++\n" |
79 | 84 |
"%.*s\n+++++++++++++++++++\n", p->len, p->s); |
85 |
+#endif /* EXTRA_DEBUG */ |
|
80 | 86 |
ret = _sr_events_list.net_data_out(data); |
87 |
+#ifdef EXTRA_DEBUG |
|
81 | 88 |
LM_DBG("POST-OUT ++++++++++++++++++++\n" |
82 | 89 |
"%.*s\n+++++++++++++++++++\n", p->len, p->s); |
90 |
+#endif /* EXTRA_DEBUG */ |
|
83 | 91 |
return ret; |
84 | 92 |
} else return 1; |
85 | 93 |
break; |