drachtio / drachtio-freeswitch-modules

A collection of open-sourced freeswitch modules that I use in various drachtio applications
MIT License
171 stars 119 forks source link

Closing connection gracefully #91

Open hhadzem opened 1 year ago

hhadzem commented 1 year ago

Hi Dave,

Seems like this part:

case AudioPipe::CONNECTION_CLOSED_GRACEFULLY:
                            tech_pvt->responseHandler(session, EVENT_WSS_CLOSED_GRACEFULLY, NULL);
                            tech_pvt->pAudioPipe = nullptr;
                            switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
                                              "connection closed gracefully\n");

is never reachable. If the connection is closed gracefully (by stopping the module on a selected channel), destroy_tech_pvt function is called before lws callback is called, causing the tech_pvt to become nullptr.

I'm not sure how to solve this problem other than calling responseHandler with EVENT_WSS_CLOSED_GRACEFULLY as soon as stop command is issued, even though it doesn't mean that connection is already closed (but should be).

Thanks in advance.