| 328 | } |
| 329 | |
| 330 | void unsafe_insert_ping_timer(struct dlg_ping_list *node,int new_timeout) |
| 331 | { |
| 332 | struct dlg_ping_list *it; |
| 333 | |
| 334 | node->timeout = get_ticks() + new_timeout; |
| 335 | |
| 336 | if (ping_timer->first == 0) { |
| 337 | ping_timer->first = node; |
| 338 | ping_timer->last = node; |
| 339 | } else { |
| 340 | /* quick optimisation, always check if our timeout is bigger than last |
| 341 | if not, lookup our position, might be useful in the future if we want |
| 342 | to set different ping intervals per dialog */ |
| 343 | if (node->timeout >= ping_timer->last->timeout) { |
| 344 | node->prev = ping_timer->last; |
| 345 | ping_timer->last->next = node; |
| 346 | ping_timer->last = node; |
| 347 | } else { |
| 348 | for (it=ping_timer->first;it;it=it->next) { |
| 349 | if (it->timeout >= node->timeout) |
| 350 | break; |
| 351 | } |
| 352 | |
| 353 | /* we need to insert ourselves before the found node */ |
| 354 | if (it == NULL) { |
| 355 | /* we're going to be the last node |
| 356 | should never get here due to the above optimisation ... paranoia */ |
| 357 | node->prev = ping_timer->last; |
| 358 | ping_timer->last->next = node; |
| 359 | ping_timer->last = node; |
| 360 | } else { |
| 361 | it->prev->next=node; |
| 362 | node->prev = it->prev; |
| 363 | node->next = it; |
| 364 | it->prev = node; |
| 365 | } |
| 366 | |
| 367 | } |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | int insert_ping_timer(struct dlg_cell* dlg) |
| 372 | { |
no test coverage detected