| 115 | } |
| 116 | |
| 117 | static inline void profiling_raise_event(int data_type, char *verb, |
| 118 | const char *name, int type, int depth, const char *file, int line, |
| 119 | int *status, void *payload) |
| 120 | { |
| 121 | int idx; |
| 122 | profiling_event_handle_t *ev; |
| 123 | struct timeval tv; |
| 124 | int sec; |
| 125 | int usec; |
| 126 | int session = 0; |
| 127 | struct sip_msg *msg; |
| 128 | str verb_s, name_s, file_s; |
| 129 | |
| 130 | idx = profiling_data_type_to_idx(data_type); |
| 131 | if (idx < 0) |
| 132 | return; |
| 133 | |
| 134 | ev = &profiling_events[idx]; |
| 135 | if (ev->id == EVI_ERROR || !ev->params) |
| 136 | return; |
| 137 | |
| 138 | if (!evi_probe_event(ev->id)) |
| 139 | return; |
| 140 | |
| 141 | if (!name) |
| 142 | name = "<root>"; |
| 143 | |
| 144 | if (!verb) |
| 145 | verb = ""; |
| 146 | verb_s.s = verb; |
| 147 | verb_s.len = strlen(verb); |
| 148 | |
| 149 | if (gettimeofday(&tv, NULL) < 0) { |
| 150 | LM_ERR("failed to get current time\n"); |
| 151 | return; |
| 152 | } |
| 153 | sec = (int)tv.tv_sec; |
| 154 | usec = (int)tv.tv_usec; |
| 155 | |
| 156 | switch (data_type) { |
| 157 | case PROFILING_DATA_TYPE_SCRIPT: |
| 158 | msg = (struct sip_msg *)payload; |
| 159 | if (msg && msg != FAKED_REPLY) |
| 160 | session = (int)msg->id; |
| 161 | break; |
| 162 | case PROFILING_DATA_TYPE_PROC: |
| 163 | session = my_pid(); |
| 164 | break; |
| 165 | } |
| 166 | |
| 167 | name_s.s = (char *)name; |
| 168 | name_s.len = strlen(name); |
| 169 | |
| 170 | if (file) { |
| 171 | file_s.s = (char *)file; |
| 172 | file_s.len = strlen(file); |
| 173 | } |
| 174 | // This is for debugging only |
no test coverage detected