mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-07-08 03:03:13 +02:00
this is probably a better idea.
This commit is contained in:
@@ -24,6 +24,7 @@ extern MODVAR FDEntry fd_table[MAXCONNECTIONS + 1];
|
||||
|
||||
extern int fd_open(int fd, const char *desc);
|
||||
extern void fd_close(int fd);
|
||||
extern int fd_unmap(int fd);
|
||||
extern void fd_unnotify(int fd);
|
||||
extern int fd_socket(int family, int type, int protocol, const char *desc);
|
||||
extern int fd_accept(int sockfd);
|
||||
|
||||
+14
-3
@@ -89,7 +89,7 @@ int fd_fileopen(const char *path, unsigned int flags)
|
||||
return fd_open(fd, comment);
|
||||
}
|
||||
|
||||
void fd_close(int fd)
|
||||
int fd_unmap(int fd)
|
||||
{
|
||||
FDEntry *fde;
|
||||
unsigned int befl;
|
||||
@@ -100,7 +100,7 @@ void fd_close(int fd)
|
||||
fd, MAXCONNECTIONS);
|
||||
ircd_log(LOG_ERROR, "[BUG] trying to close fd #%d in fd table, but MAXCONNECTIONS is %d",
|
||||
fd, MAXCONNECTIONS);
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
fde = &fd_table[fd];
|
||||
@@ -110,7 +110,7 @@ void fd_close(int fd)
|
||||
fd);
|
||||
ircd_log(LOG_ERROR, "[BUG] trying to close fd #%d in fd table, but this FD isn't reported open",
|
||||
fd);
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
befl = fde->backend_flags;
|
||||
@@ -121,6 +121,17 @@ void fd_close(int fd)
|
||||
/* only notify the backend if it is actively tracking the FD */
|
||||
if (befl)
|
||||
fd_refresh(fd);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void fd_close(int fd)
|
||||
{
|
||||
FDEntry *fde;
|
||||
unsigned int befl;
|
||||
|
||||
if (!fd_unmap(fd))
|
||||
return;
|
||||
|
||||
CLOSE_SOCK(fd);
|
||||
}
|
||||
|
||||
@@ -105,6 +105,15 @@ static void unrealdns_sock_state_cb(void *data, ares_socket_t fd, int read, int
|
||||
{
|
||||
int selflags = 0;
|
||||
|
||||
if (!read && !write)
|
||||
{
|
||||
/* Socket is going to be closed *BY C-ARES*..
|
||||
* so don't call fd_close() but fd_unmap().
|
||||
*/
|
||||
fd_close(fd);
|
||||
// return;
|
||||
}
|
||||
|
||||
if (read)
|
||||
selflags |= FD_SELECT_READ;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user