From 9fc261c45952ec8bedceec689ea8b5a734c86b7d Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Tue, 19 Feb 2013 16:27:37 +0000 Subject: More #1613: fixed bugs in the 'fixes' above: - the socket was closed when ioctl() is called - the 'iff' structure was not initialized git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4355 74dad513-b988-da41-8d7b-12977e46ad98 --- pjlib/src/pj/ip_helper_generic.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'pjlib') diff --git a/pjlib/src/pj/ip_helper_generic.c b/pjlib/src/pj/ip_helper_generic.c index 0adefebb..b85e336d 100644 --- a/pjlib/src/pj/ip_helper_generic.c +++ b/pjlib/src/pj/ip_helper_generic.c @@ -165,9 +165,6 @@ static pj_status_t if_enum_by_af(int af, return PJ_RETURN_OS_ERROR(oserr); } - /* Done with socket */ - pj_sock_close(sock); - /* Interface interfaces */ ifr = (struct ifreq*) ifc.ifc_req; count = ifc.ifc_len / sizeof(struct ifreq); @@ -177,7 +174,7 @@ static pj_status_t if_enum_by_af(int af, *p_cnt = 0; for (i=0; iifr_addr; TRACE_((THIS_FILE, " checking interface %s", itf->ifr_name)); @@ -227,10 +224,14 @@ static pj_status_t if_enum_by_af(int af, (*p_cnt)++; } + /* Done with socket */ + pj_sock_close(sock); + TRACE_((THIS_FILE, "done, found %d address(es)", *p_cnt)); return (*p_cnt != 0) ? PJ_SUCCESS : PJ_ENOTFOUND; } + #elif defined(PJ_HAS_NET_IF_H) && PJ_HAS_NET_IF_H != 0 /* Note: this does not work with IPv6 */ static pj_status_t if_enum_by_af(int af, unsigned *p_cnt, pj_sockaddr ifs[]) -- cgit v1.2.3