[PATCH] PJSIP: Don't sleep after error in pj_ioqueue_poll().

BC
b17 c0de
Tue, Sep 26, 2017 8:00 PM

Hi PJ peeps,
Please apply this patch which removes the pj_thread_sleep() call from
pjsip_endpt_handle_events2(). I think it makes more sense just to
return the error to the user immediately and let them decide if they
want to sleep (like pjsua-lib does).

One concrete case when this sleep is problematic is when a signal
occurs. In this case, the call to pj_ioqueue_poll() will return
because of EINTR which will cause the main loop to additionally sleep
for the full timeout. This means, if pjsip_endpt_handle_events2() is
called with a large timeout, the signal/interrupt will block the app
for the full timeout interval if a signal happens. This is a problem.

Thanks,
Kal

Hi PJ peeps, Please apply this patch which removes the pj_thread_sleep() call from pjsip_endpt_handle_events2(). I think it makes more sense just to return the error to the user immediately and let them decide if they want to sleep (like pjsua-lib does). One concrete case when this sleep is problematic is when a signal occurs. In this case, the call to pj_ioqueue_poll() will return because of EINTR which will cause the main loop to additionally sleep for the full timeout. This means, if pjsip_endpt_handle_events2() is called with a large timeout, the signal/interrupt will block the app for the full timeout interval if a signal happens. This is a problem. Thanks, Kal
M
Ming
Wed, Sep 27, 2017 8:27 AM

Hi Kal,

We're thinking to reduce the delay to max 10 ms instead of removing it
completely. This should allow for error recovery. Please let us know
your opinion/feedback. Patch attached.

Regards,
Ming

On Wed, Sep 27, 2017 at 4:00 AM, b17 c0de b17c0de@gmail.com wrote:

Hi PJ peeps,
Please apply this patch which removes the pj_thread_sleep() call from
pjsip_endpt_handle_events2(). I think it makes more sense just to
return the error to the user immediately and let them decide if they
want to sleep (like pjsua-lib does).

One concrete case when this sleep is problematic is when a signal
occurs. In this case, the call to pj_ioqueue_poll() will return
because of EINTR which will cause the main loop to additionally sleep
for the full timeout. This means, if pjsip_endpt_handle_events2() is
called with a large timeout, the signal/interrupt will block the app
for the full timeout interval if a signal happens. This is a problem.

Thanks,
Kal


Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

Hi Kal, We're thinking to reduce the delay to max 10 ms instead of removing it completely. This should allow for error recovery. Please let us know your opinion/feedback. Patch attached. Regards, Ming On Wed, Sep 27, 2017 at 4:00 AM, b17 c0de <b17c0de@gmail.com> wrote: > Hi PJ peeps, > Please apply this patch which removes the pj_thread_sleep() call from > pjsip_endpt_handle_events2(). I think it makes more sense just to > return the error to the user immediately and let them decide if they > want to sleep (like pjsua-lib does). > > One concrete case when this sleep is problematic is when a signal > occurs. In this case, the call to pj_ioqueue_poll() will return > because of EINTR which will cause the main loop to additionally sleep > for the full timeout. This means, if pjsip_endpt_handle_events2() is > called with a large timeout, the signal/interrupt will block the app > for the full timeout interval if a signal happens. This is a problem. > > Thanks, > Kal > > _______________________________________________ > Visit our blog: http://blog.pjsip.org > > pjsip mailing list > pjsip@lists.pjsip.org > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org >
M
Ming
Fri, Sep 29, 2017 2:47 AM

Hi Kal,

We have committed the patch, with some modifications, in ticket #2048
(https://trac.pjsip.org/repos/ticket/2048). Thanks for the patch and
the discussion that followed.

Best regards,
Ming

On Wed, Sep 27, 2017 at 4:27 PM, Ming ming@teluu.com wrote:

Hi Kal,

We're thinking to reduce the delay to max 10 ms instead of removing it
completely. This should allow for error recovery. Please let us know
your opinion/feedback. Patch attached.

Regards,
Ming

On Wed, Sep 27, 2017 at 4:00 AM, b17 c0de b17c0de@gmail.com wrote:

Hi PJ peeps,
Please apply this patch which removes the pj_thread_sleep() call from
pjsip_endpt_handle_events2(). I think it makes more sense just to
return the error to the user immediately and let them decide if they
want to sleep (like pjsua-lib does).

One concrete case when this sleep is problematic is when a signal
occurs. In this case, the call to pj_ioqueue_poll() will return
because of EINTR which will cause the main loop to additionally sleep
for the full timeout. This means, if pjsip_endpt_handle_events2() is
called with a large timeout, the signal/interrupt will block the app
for the full timeout interval if a signal happens. This is a problem.

Thanks,
Kal


Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

Hi Kal, We have committed the patch, with some modifications, in ticket #2048 (https://trac.pjsip.org/repos/ticket/2048). Thanks for the patch and the discussion that followed. Best regards, Ming On Wed, Sep 27, 2017 at 4:27 PM, Ming <ming@teluu.com> wrote: > Hi Kal, > > We're thinking to reduce the delay to max 10 ms instead of removing it > completely. This should allow for error recovery. Please let us know > your opinion/feedback. Patch attached. > > Regards, > Ming > > On Wed, Sep 27, 2017 at 4:00 AM, b17 c0de <b17c0de@gmail.com> wrote: >> Hi PJ peeps, >> Please apply this patch which removes the pj_thread_sleep() call from >> pjsip_endpt_handle_events2(). I think it makes more sense just to >> return the error to the user immediately and let them decide if they >> want to sleep (like pjsua-lib does). >> >> One concrete case when this sleep is problematic is when a signal >> occurs. In this case, the call to pj_ioqueue_poll() will return >> because of EINTR which will cause the main loop to additionally sleep >> for the full timeout. This means, if pjsip_endpt_handle_events2() is >> called with a large timeout, the signal/interrupt will block the app >> for the full timeout interval if a signal happens. This is a problem. >> >> Thanks, >> Kal >> >> _______________________________________________ >> Visit our blog: http://blog.pjsip.org >> >> pjsip mailing list >> pjsip@lists.pjsip.org >> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org >>