allow netsock objects to be unref'd so they can disappear when needed (issue #5454)
authorKevin P. Fleming <kpfleming@digium.com>
Mon, 31 Oct 2005 23:16:27 +0000 (23:16 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Mon, 31 Oct 2005 23:16:27 +0000 (23:16 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6913 65c4cc65-6c06-0410-ace0-fbb531ad65f3

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

index 2ff97ca..e4695d8 100755 (executable)
@@ -8640,6 +8640,7 @@ static int set_config(char *config_file, int reload)
                                        }
                                        if (defaultsockfd < 0) 
                                                defaultsockfd = ast_netsock_sockfd(ns);
+                                       ast_netsock_unref(ns);
                                }
                        }
                } else if (!strcasecmp(v->name, "authdebug"))
@@ -9568,6 +9569,7 @@ int load_module(void)
                        if (option_verbose > 1)
                                ast_verbose(VERBOSE_PREFIX_2 "Binding IAX2 to default address 0.0.0.0:%d\n", IAX_DEFAULT_PORTNO);
                        defaultsockfd = ast_netsock_sockfd(ns);
+                       ast_netsock_unref(ns);
                }
        }
        
index dd1c3a8..73a2dd2 100755 (executable)
@@ -59,6 +59,8 @@ const struct sockaddr_in *ast_netsock_boundaddr(const struct ast_netsock *ns);
 
 void *ast_netsock_data(const struct ast_netsock *ns);
 
+void ast_netsock_unref(struct ast_netsock *ns);
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif
index da22c54..386f156 100755 (executable)
--- a/netsock.c
+++ b/netsock.c
@@ -214,3 +214,8 @@ void *ast_netsock_data(const struct ast_netsock *ns)
 {
        return ns->data;
 }
+
+void ast_netsock_unref(struct ast_netsock *ns)
+{
+       ASTOBJ_UNREF(ns, ast_netsock_destroy);
+}