Skip to content

Add compile-time flag to disable dialog event package#4810

Merged
sauwming merged 3 commits intomasterfrom
copilot/add-compile-time-setting-dialog-event
Feb 20, 2026
Merged

Add compile-time flag to disable dialog event package#4810
sauwming merged 3 commits intomasterfrom
copilot/add-compile-time-setting-dialog-event

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 20, 2026

Description

Introduces PJSUA_HAS_DLG_EVENT_PKG compile-time configuration to conditionally enable/disable RFC 4235 dialog event package initialization.

Changes:

  • Added PJSUA_HAS_DLG_EVENT_PKG macro in pjsip/include/pjsua-lib/pjsua.h (default: 1)
  • Wrapped pjsip_dlg_event_init_module() call in pjsip/src/pjsua-lib/pjsua_core.c with #if PJSUA_HAS_DLG_EVENT_PKG

Usage:

Users with existing dialog event server implementations can disable the built-in client:

// In pjlib/include/pj/config_site.h
#define PJSUA_HAS_DLG_EVENT_PKG 0

Motivation and Context

Dialog event package (RFC 4235) client support added in #3754 conflicts with existing user implementations of the server side. This flag allows users to opt-out while maintaining backward compatibility (enabled by default).

The configuration is placed at the PJSUA level (in pjsua.h) following the pattern of other PJSUA configuration macros like PJSUA_HAS_VIDEO and PJSUA_HAS_SIPREC, making it consistent with the high-level API architecture.

How Has This Been Tested?

  • Built successfully with default configuration (enabled)
  • Built successfully with PJSUA_HAS_DLG_EVENT_PKG=0 (disabled)
  • Verified pjsua runtime behavior in both configurations
  • Confirmed mod-dlg_event module registration reflects configuration state

Screenshots (if appropriate):

N/A

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the CODING STYLE of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
Original prompt

This section details on the original issue you should resolve

<issue_title>Dialog event client implementation conflicts with user's server implementation</issue_title>
<issue_description>### Describe the bug

In #3754, we add support for dialog event subscription, but for client only. But this will conflict with users that have already implemented the server side of the feature.

Steps to reproduce

N/A

PJSIP version

2.16

Context

N/A

Log, call stack, etc

N/A
```</issue_description>

<agent_instructions>Introduce a compile-time setting to enable/disable `pjsip_dlg_event_init_module()` (default is enabled).
</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

- Added PJSIP_HAS_DLG_EVENT_PKG macro in sip_config.h (default: 1)
- Wrapped pjsip_dlg_event_init_module() call with conditional compilation
- Allows users to disable dialog event package if they have their own implementation

Co-authored-by: sauwming <17044930+sauwming@users.noreply.github.com>
Copilot AI changed the title [WIP] Add compile-time setting for dialog event client implementation Add compile-time flag to disable dialog event package Feb 20, 2026
Copilot AI requested a review from sauwming February 20, 2026 01:12
*/
#ifndef PJSIP_HAS_DLG_EVENT_PKG
# define PJSIP_HAS_DLG_EVENT_PKG 1
#endif
Copy link
Copy Markdown
Member

@sauwming sauwming Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot: The setting should be at pjsua level (i.e. in pjsua.h)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot: The setting should be at pjsua level (i.e. in pjsua.h)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Moved the configuration macro from sip_config.h to pjsua.h and renamed it to PJSUA_HAS_DLG_EVENT_PKG. (commit 6a2dfba)

- Moved configuration macro from pjsip/include/pjsip/sip_config.h to pjsip/include/pjsua-lib/pjsua.h
- Updated conditional compilation in pjsua_core.c to use PJSUA_HAS_DLG_EVENT_PKG
- Tested both enabled (default) and disabled configurations successfully

Co-authored-by: sauwming <17044930+sauwming@users.noreply.github.com>
@sauwming sauwming marked this pull request as ready for review February 20, 2026 02:48
@sauwming
Copy link
Copy Markdown
Member

sauwming commented Feb 20, 2026

The failed CI test seems to be unrelated to the PR:

  • ioq read
==9966==ERROR: AddressSanitizer: heap-use-after-free on address 0x515000031230 at pc 0x7efcdf0fb42e bp 0x7efcd7be8b40 sp 0x7efcd7be82e8
READ of size 12 at 0x515000031230 thread T3
    #2 0x556e04b1cfd8 in pj_strdup ../include/pj/string_i.h:43
    #3 0x556e04415889 in pjrpid_add_element ../src/pjsip-simple/rpid.c:128
    #4 0x556e0440f964 in pjsip_pres_create_pidf ../src/pjsip-simple/presence_body.c:147
    #5 0x556e04409fda in pres_create_msg_body ../src/pjsip-simple/presence.c:494
    #6 0x556e0440a404 in pjsip_pres_notify ../src/pjsip-simple/presence.c:550
    #7 0x556e0440adba in pres_on_evsub_rx_refresh ../src/pjsip-simple/presence.c:697
    #8 0x556e04401c98 in on_tsx_state_uas ../src/pjsip-simple/evsub.c:2187
    #9 0x556e04402cac in mod_evsub_on_tsx_state ../src/pjsip-simple/evsub.c:2346
    #10 0x556e044ae01f in pjsip_dlg_on_tsx_state ../src/pjsip/sip_dialog.c:2252
    #11 0x556e044af654 in mod_ua_on_tsx_state ../src/pjsip/sip_ua_layer.c:186
    #12 0x556e04492c6b in tsx_set_state ../src/pjsip/sip_transaction.c:1481
    #13 0x556e0449ad70 in tsx_on_state_null ../src/pjsip/sip_transaction.c:2890
    #14 0x556e0449655c in pjsip_tsx_recv_msg ../src/pjsip/sip_transaction.c:2107
    #15 0x556e044ac040 in pjsip_dlg_on_rx_request ../src/pjsip/sip_dialog.c:1882
    #16 0x556e044b15d3 in mod_ua_on_rx_request ../src/pjsip/sip_ua_layer.c:745
    #17 0x556e0443fdde in pjsip_endpt_process_rx_data ../src/pjsip/sip_endpoint.c:961
    #18 0x556e0444071e in endpt_on_rx_msg ../src/pjsip/sip_endpoint.c:1113
    #19 0x556e0445e51d in pjsip_tpmgr_receive_packet ../src/pjsip/sip_transport.c:2465
    #20 0x556e04461827 in udp_on_read_complete ../src/pjsip/sip_transport_udp.c:193
    #21 0x556e04add168 in ioqueue_dispatch_read_event ../src/pj/ioqueue_common_abs.c:777
    #22 0x556e04ae320a in pj_ioqueue_poll ../src/pj/ioqueue_select.c:1093

0x515000031230 is located 176 bytes inside of 512-byte region [0x515000031180,0x515000031380)
freed by thread T3 here:
    #4 0x556e04af90ad in pj_pool_release ../include/pj/pool_i.h:155
    #5 0x556e0440a976 in pres_on_evsub_state ../src/pjsip-simple/presence.c:641
    #6 0x556e043f945a in set_state ../src/pjsip-simple/evsub.c:630
    #7 0x556e04401aba in on_tsx_state_uas ../src/pjsip-simple/evsub.c:2174
    #8 0x556e04402cac in mod_evsub_on_tsx_state ../src/pjsip-simple/evsub.c:2346
    #9 0x556e044ae01f in pjsip_dlg_on_tsx_state ../src/pjsip/sip_dialog.c:2252
    #10 0x556e044af654 in mod_ua_on_tsx_state ../src/pjsip/sip_ua_layer.c:186
    #11 0x556e04492c6b in tsx_set_state ../src/pjsip/sip_transaction.c:1481
    #12 0x556e0449ad70 in tsx_on_state_null ../src/pjsip/sip_transaction.c:2890
    #13 0x556e0449655c in pjsip_tsx_recv_msg ../src/pjsip/sip_transaction.c:2107
    #14 0x556e044ac040 in pjsip_dlg_on_rx_request ../src/pjsip/sip_dialog.c:1882
    #15 0x556e044b15d3 in mod_ua_on_rx_request ../src/pjsip/sip_ua_layer.c:745
    #16 0x556e0443fdde in pjsip_endpt_process_rx_data ../src/pjsip/sip_endpoint.c:961
    #17 0x556e0444071e in endpt_on_rx_msg ../src/pjsip/sip_endpoint.c:1113
    #18 0x556e0445e51d in pjsip_tpmgr_receive_packet ../src/pjsip/sip_transport.c:2465
    #19 0x556e04461827 in udp_on_read_complete ../src/pjsip/sip_transport_udp.c:193
    #20 0x556e04add168 in ioqueue_dispatch_read_event ../src/pj/ioqueue_common_abs.c:777
    #21 0x556e04ae320a in pj_ioqueue_poll ../src/pj/ioqueue_select.c:1093
  • ioq unreg
   3  Id: af0.ff0 Suspend: 0 Teb: 0075a000 Unfrozen "unittest00A29B14"
ChildEBP RetAddr      
02b8fad8 002c0ede     KERNELBASE!Sleep+0xf
02b8fae4 0029b345     pjlib_test_i386_Win32_vc14_Release!pj_thread_sleep+0x1e
02b8fb54 0029b643     pjlib_test_i386_Win32_vc14_Release!perform_unreg_test+0x335
02b8fbb0 0029b474     pjlib_test_i386_Win32_vc14_Release!udp_ioqueue_unreg_test_imp+0x1c3
02b8fbb8 002cde62     pjlib_test_i386_Win32_vc14_Release!udp_ioqueue_unreg_test+0x14
02b8fc14 002ce12f     pjlib_test_i386_Win32_vc14_Release!run_test_case+0xa2

@sauwming sauwming merged commit 9c3113d into master Feb 20, 2026
43 of 50 checks passed
@sauwming sauwming deleted the copilot/add-compile-time-setting-dialog-event branch February 20, 2026 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dialog event client implementation conflicts with user's server implementation

3 participants