Summary:ASTERISK-05306: Unable to re-load chan_iax2
Reporter:James Lyons (james)Labels:
Date Opened:2005-10-18 02:07:10Date Closed:2008-01-15 15:53:05.000-0600
Versions:Frequency of
Environment:Attachments:( 0) 5454.txt
( 1) bug-5454.netstat
Description:After connecting remotely to CVS Head 10-17-05, issue unload chan_iax2.so in console, then load chan_iax2.so. IAX fails to reload and iax is removed from command list as well (of course)


debbie*CLI> unload chan_iax2.so
 == Unregistered custom function IAXPEER
 == Manager unregistered action IAXpeers
 == Manager unregistered action IAXnetstats
 == Unregistered application 'IAX2Provision'
 == Unregistered channel type 'IAX2'
debbie*CLI> load chan_iax2.so
Unable to load module chan_iax2.so
Loaded /usr/lib/asterisk/modules/chan_iax2.so => (Inter Asterisk eXchange (Ver 2))
 == Registered custom function IAXPEER
 == Registered application 'IAX2Provision'
 == Manager registered action IAXpeers
 == Manager registered action IAXnetstats
 == Parsing '/etc/asterisk/iax.conf': Found
   -- doing lookup for 'misery.digium.internal'
 == Registered channel type 'IAX2' (Inter Asterisk eXchange Driver (Ver 2))
Oct 18 02:05:02 ERROR[32088]: netsock.c:140 ast_netsock_bindaddr: Unable to bind to port 4569: Address already in use
Oct 18 02:05:02 ERROR[32088]: chan_iax2.c:9519 load_module: Unable to create network socket: Address already in use
Oct 18 02:05:02 WARNING[32088]: loader.c:414 __load_resource: chan_iax2.so: load_module failed, returning -1
 == Unregistered custom function IAXPEER
 == Manager unregistered action IAXpeers
 == Manager unregistered action IAXnetstats
 == Unregistered application 'IAX2Provision'
 == Unregistered channel type 'IAX2'
Comments:By: BJ Weschke (bweschke) 2005-10-18 02:34:49

what does a netstat -na look like on the box between the time you've unloaded chan_iax2 and then attempt to load it again?

By: Tilghman Lesher (tilghman) 2005-10-18 10:45:24

If you're attempting to initiate a reload, why aren't you using the "reload chan_iax2.so" command?

By: Serge Vecher (serge-v) 2005-10-18 11:54:55

Given this is a kludgy way to reload, it should still work, no?
chan_sip.so deals with a "reload" this way ok...

By: Clod Patry (junky) 2005-10-18 12:01:36

deptaudio@asterisk:/etc/asterisk$ netstat -na |grep 4569
udp        0      0  *

after an unload chan_iax2.so
im still getting the same error as the reporter said.

fyi: im using HEAD 2005-10-17 15:55:17 UTC

By: BJ Weschke (bweschke) 2005-10-18 12:03:42

One would think so, yes. I'm interested to see what's happening with the sockets though after an unload because from the initial snapshot, it doesn't look like ast_netsock_release(netsock); is shutting doing the job for shutting down the socket??

By: Tilghman Lesher (tilghman) 2005-10-18 12:11:38

It is (or appears to be) calling close() on netsock.  I'm wondering if perhaps it would be better to call shutdown(netsock, 2), instead.

Since this is a generic routine involved, you should see the same issue with chan_sip.so and any other channel that uses a network socket.

By: Clod Patry (junky) 2005-10-18 12:13:58

i dont have that error on chan_sip, i'll take a deeper look tonight.

By: James Lyons (james) 2005-10-18 17:38:23

unix  2      [ ACC ]     STREAM     LISTENING     229515   /var/run/asterisk.ctl
unix  3      [ ]         STREAM     CONNECTED     232748
unix  3      [ ]         STREAM     CONNECTED     232747
unix  3      [ ]         STREAM     CONNECTED     232746   /var/run/asterisk.ctl
unix  3      [ ]         STREAM     CONNECTED     232745
unix  2      [ ]         DGRAM                    224232
unix  3      [ ]         STREAM     CONNECTED     224229
unix  3      [ ]         STREAM     CONNECTED     224228

This is the only thing related to asterisk in the list, i have a lot of stuff running. This is on my personal machine. I have attached the full length output though.

Could it be that asterisk is not ignoring the bindport on attempting to 'load chan_iax2.so' on effectively a reload?

By: Clod Patry (junky) 2005-10-19 11:31:21

Try that patch, seems to work fine here.

Btw, why use ast_netsock_release(netsock) exactly?
I mean, only that driver (chan_iax2.c) uses it.

Disclaimer on file.

By: Olle Johansson (oej) 2005-10-20 01:40:15

junky: chan_iax2 has a bit improved netsocket interface, the model for the generic model kpfleming is implementing for all channels. That's why you see things in chan_iax2 that does not exist anywhere else.

By: Kevin P. Fleming (kpfleming) 2005-10-31 18:25:32.000-0600

Fixed in CVS HEAD.

By: Digium Subversion (svnbot) 2008-01-15 15:53:05.000-0600

Repository: asterisk
Revision: 6913

U   trunk/channels/chan_iax2.c
U   trunk/include/asterisk/netsock.h
U   trunk/netsock.c

r6913 | kpfleming | 2008-01-15 15:53:04 -0600 (Tue, 15 Jan 2008) | 2 lines

allow netsock objects to be unref'd so they can disappear when needed (issue ASTERISK-5306)