Change async DNS resolver code to register its file descriptor with the IO

core.  This fixes /nslookup.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@147 13b04d17-f746-0410-82c6-800466cd88b0
This commit is contained in:
Kevin Easton
2012-02-08 11:24:48 +00:00
parent ed16081a2b
commit 7978a87c9f
2 changed files with 41 additions and 36 deletions

View File

@@ -1,5 +1,7 @@
[Changes 1.2c01]
* Fix /nslookup command. (caf)
* Improve /detach error handling and remove bogus F_SETOWN use, reported
by madsage. (caf)

View File

@@ -2094,8 +2094,9 @@ int ar_init(int op)
*/
int ar_open(void)
{
if (ar_resfd == -1)
{
if (ar_resfd > -1)
return ar_resfd;
if (_res.options & RES_USEVC)
{
struct sockaddr_in *sip;
@@ -2123,18 +2124,21 @@ int ar_open(void)
{
int on = 0;
ar_resfd = socket(AF_INET, SOCK_DGRAM, 0);
if (ar_resfd > -1)
(void) setsockopt(ar_resfd, SOL_SOCKET, SO_BROADCAST,(char *)&on, sizeof(on));
}
}
if (ar_resfd >= 0)
{ /* Need one of these two here - and it MUST work!! */
if (ar_resfd < 0)
return -1;
if (set_non_blocking(ar_resfd) < 0)
{
(void)close(ar_resfd);
ar_resfd = -1;
}
}
return ar_resfd;
return new_open(ar_resfd);
}
/*
@@ -2144,7 +2148,7 @@ int ar_open(void)
*/
void ar_close(void)
{
(void)close(ar_resfd);
new_close(ar_resfd);
ar_resfd = -1;
return;
}
@@ -2361,9 +2365,8 @@ static int ar_send_res_msg(char *msg, int len, int rcount)
if (write(ar_resfd, msg, len) == -1)
{
int errtmp = errno;
(void)close(ar_resfd);
ar_close();
errno = errtmp;
ar_resfd = -1;
}
}
else