Yate server > Yate bugs

[fix] Wrong killing of extmodule

<< < (2/2)

andr04:
Yes, I use extmodule command flow but it must (can) be improved.

--- Quote ---If an external script wants to know when yate is going to stop it may install a handler for engine.stop message.
--- End quote ---

--- Quote ---For channel scripts you may install message handlers to check termination (see chan.disconnected)
--- End quote ---

Why do you think 2 different methods better than 1 in my solution? In my view it looks like a crutch. First one (engine.stop message) doesn't cover script restarting from CLI. Second one (chan.disconnected message) doesn't work at all due to CallEndpoint destruction. I installed handler for it (extmodule.cpp from 5.5.0 version without changes), but it doesn't work:
--- Code: ---2017-05-15_09:48:27.212239 <sip:INFO> 'udp:0.0.0.0:5060' received 418 bytes SIP message from 85.142.148.80:5060 [0x140add0]
------
BYE sip:200@37.140.188.160:5060 SIP/2.0
Via: SIP/2.0/UDP 85.142.148.80:5060;rport;branch=z9hG4bKPj11500195-5795-455d-8971-2d13f3b0faf1
From: "laptop" <sip:laptop@talk37.ru>;tag=97bbbc5f-41bb-4abe-a293-775d02e33440
To: <sip:200@37.140.188.160>;tag=1893302431
Call-ID: b98b4e73-cd84-4a69-b4dc-a1430ce5af6a
CSeq: 32719 BYE
Reason: Q.850;cause=16
Max-Forwards: 70
User-Agent: ruVoIP.net PBX
Content-Length:  0

------
2017-05-15_09:48:27.222087 <sip:INFO> 'udp:0.0.0.0:5060' sending code 100 0x7f3590012180 to 85.142.148.80:5060 [0x140add0]
------
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 85.142.148.80:5060;rport=5060;branch=z9hG4bKPj11500195-5795-455d-8971-2d13f3b0faf1;received=85.142.148.80
From: "laptop" <sip:laptop@talk37.ru>;tag=97bbbc5f-41bb-4abe-a293-775d02e33440
To: <sip:200@37.140.188.160>;tag=1893302431
Call-ID: b98b4e73-cd84-4a69-b4dc-a1430ce5af6a
CSeq: 32719 BYE
Server: YATE/5.5.0
Content-Length: 0

------
2017-05-15_09:48:27.222179 <yrtp:INFO> YRTPWrapper::terminate() [0x7f358c011fc0]
2017-05-15_09:48:27.222205 >>> DataTranslator::detachChain(0x7f358c012610,0x7f358c014190)
2017-05-15_09:48:27.222212   >>> DataTranslator::detachChain(0x7f358c012610,0x7f3590012820)
2017-05-15_09:48:27.222216   <<< DataTranslator::detachChain
2017-05-15_09:48:27.222225 <<< DataTranslator::detachChain
2017-05-15_09:48:27.222229 >>> DataTranslator::detachChain(0x7f358c011840,0x7f358c017340)
2017-05-15_09:48:27.222234   >>> DataTranslator::detachChain(0x7f358c011840,0x7f3590013950)
2017-05-15_09:48:27.222238   <<< DataTranslator::detachChain
2017-05-15_09:48:27.222242 <<< DataTranslator::detachChain
2017-05-15_09:48:27.222253 <ALL> Cleaning up RTP 0x7f358c012170 [0x7f358c011fc0]
2017-05-15_09:48:27.222333 <ALL> ExtModChan::disconnected() '(null)' [0x7f358c014040]
2017-05-15_09:48:27.222345 <ALL> ExtModConsumer::~ExtModConsumer() [0x7f358c014190] total=53120
2017-05-15_09:48:27.222358 >>> ExtModChan::~ExtModChan() [0x7f358c014040]
2017-05-15_09:48:27.222374   <ALL> ExtModReceiver::die() pid=9064 dead=no [0x7f358c013d80]
2017-05-15_09:48:27.222382   <ALL> ExtModReceiver::die() waiting for pid=9064 to die [0x7f358c013d80]
2017-05-15_09:48:27.228405   <INFO> ExtModReceiver::die() pid=9064 did not exit? [0x7f358c013d80]
2017-05-15_09:48:27.232148   <ExtModule:WARN> Read error 9 on 0x7f35840011f0 [0x7f358c013d80]
2017-05-15_09:48:27.232287   <WARN> Process 9064 has not exited on closing stdin - we'll kill it
2017-05-15_09:48:27.232379   <WARN> Process 9064 has still not exited yet?
2017-05-15_09:48:27.233520   <ALL> ExtModSource [0x7f358c011840] end of data total=16000
2017-05-15_09:48:27.233550   <ALL> ExtModSource::~ExtModSource() [0x7f358c011840] total=16000
2017-05-15_09:48:27.233581   <ALL> ExtModReceiver::~ExtModReceiver() pid=0 [0x7f358c013d80]
2017-05-15_09:48:27.233589   <ALL> ExtModReceiver::die() pid=0 dead=yes [0x7f358c013d80]
2017-05-15_09:48:27.233595 <<< ExtModChan::~ExtModChan()
2017-05-15_09:48:27.233654 <sip:INFO> 'udp:0.0.0.0:5060' sending code 200 0x7f3590013950 to 85.142.148.80:5060 [0x140add0]
------
SIP/2.0 200 OK
Via: SIP/2.0/UDP 85.142.148.80:5060;rport=5060;branch=z9hG4bKPj11500195-5795-455d-8971-2d13f3b0faf1;received=85.142.148.80
From: "laptop" <sip:laptop@talk37.ru>;tag=97bbbc5f-41bb-4abe-a293-775d02e33440
To: <sip:200@37.140.188.160>;tag=1893302431
Call-ID: b98b4e73-cd84-4a69-b4dc-a1430ce5af6a
CSeq: 32719 BYE
P-RTP-Stat: PS=60,OS=7500,PR=166,OR=26560,PL=0
Server: YATE/5.5.0
Allow: ACK, INVITE, BYE, CANCEL, REGISTER, REFER, OPTIONS, INFO
Content-Length: 0

------
--- End code ---

And I believe Process 9064 has not exited on closing stdin - we'll kill it -- it's not what we want to see in log on the normal case.

My solution allows to write extmodules in a common case more likely to cpp modules: you can do some operations on module constructor and module destructor as well. Moreover I fixed catching chan.disconnected message as well.

Navigation

[0] Message Index

[*] Previous page

Go to full version