Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#1616 closed enhancement (fixed)

Group lock and other foundation in PJLIB for fixing synchronization issues — at Version 4

Reported by: bennylp Owned by: bennylp
Priority: normal Milestone: release-2.1
Component: pjlib Version: trunk
Keywords: Cc:
Backport to 1.x milestone: Backported: no

Description (last modified by bennylp)

This ticket contains works to be/that have been done in PJLIB to lay foundation for fixing various synchronization issues in upper layers such as PJNATH (see #1617). The details of the work are as follow.

Group Lock

Implement Group Lock, a new synchronization object for dealing with deadlock and session management. Please see the link for more info.

More robust timer heap

  • Integration of group lock to the timer heap. A new API is introduced: pj_timer_heap_schedule_w_grp_lock(), which adds reference counter to the group lock when timer is scheduled, and automatically decrements it after the timer expires or cancelled, to prevent the group lock from being destroyed when a timer callback is about to be executed. This API also sets the timer "id" automatically and atomically.
  • New convenience API: pj_timer_heap_cancel_if_active() to cancel a timer without having to firstly check if it is active or not.

Changes is ioqueue and active socket

  • New API pj_ioqueue_register_sock2() that takes group lock argument. The group lock would be incremented before callback is called to prevent it from being destroyed while callback is about to run.
  • Added grp_lock in pj_activesock_cfg, to specify which group lock to use by the ioqueue key.

Miscellaneous

  • New PJ_EGONE error code. It is used when pj_grp_lock_dec_ref() or pj_grp_lock_release() causes the group lock to be destroyed.
  • New PJ_RACE_ME(x) macro which can be inserted in various strategic locations. During testing, the macro can be replaced with pj_thread_sleep(x) in order to trigger race condition to happen.
  • Event object (similar to Windows event) implementation for os_core_unix.c based on Pthread condition variable. This is used by the pjnath-test testing program to synchronize the tests.

Change History (4)

comment:1 Changed 12 years ago by bennylp

  • Description modified (diff)

comment:2 Changed 12 years ago by bennylp

  • Resolution set to fixed
  • Status changed from new to closed

In 4359:

Fixed #1616: Implementation of Group lock and other foundation in PJLIB for fixing synchronization issues

comment:3 Changed 12 years ago by bennylp

  • Description modified (diff)

comment:4 Changed 12 years ago by bennylp

  • Description modified (diff)
Note: See TracTickets for help on using tickets.