mirror of
https://github.com/nmap/nmap.git
synced 2026-08-03 22:29:06 +00:00
Process all fds in last select before quitting. Fixes #1672
Some checks are pending
nmap multiplatform autobuilds / build (arm64, gcc, ubuntu-latest-gcc-arm64, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, freebsd-15-clang, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, macos-15-clang, macos-15) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, macos-26-clang, macos-26) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, netbsd-10-clang, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, openbsd-7-clang, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, solaris-11-clang, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, ubuntu-latest-clang, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (egcc, openbsd-7-gcc, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (gcc, freebsd-15-gcc, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (gcc, netbsd-10-gcc, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (gcc, solaris-11-gcc, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (gcc, ubuntu-latest-gcc, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (msvc, windows-latest-msvc, windows-latest) (push) Waiting to run
Some checks are pending
nmap multiplatform autobuilds / build (arm64, gcc, ubuntu-latest-gcc-arm64, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, freebsd-15-clang, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, macos-15-clang, macos-15) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, macos-26-clang, macos-26) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, netbsd-10-clang, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, openbsd-7-clang, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, solaris-11-clang, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, ubuntu-latest-clang, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (egcc, openbsd-7-gcc, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (gcc, freebsd-15-gcc, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (gcc, netbsd-10-gcc, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (gcc, solaris-11-gcc, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (gcc, ubuntu-latest-gcc, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (msvc, windows-latest-msvc, windows-latest) (push) Waiting to run
This commit is contained in:
parent
5688bd25ed
commit
0e6e731b01
1 changed files with 11 additions and 7 deletions
|
|
@ -211,6 +211,10 @@ int ncat_listen()
|
|||
unsigned int num_sockets;
|
||||
int proto = o.proto;
|
||||
int type = o.proto == IPPROTO_UDP ? SOCK_DGRAM : SOCK_STREAM;
|
||||
#define BREAKLOOP_ERROR 2
|
||||
#define BREAKLOOP_SUCCESS 1
|
||||
#define BREAKLOOP_CONTINUE 0
|
||||
int breakloop = BREAKLOOP_CONTINUE;
|
||||
|
||||
if (o.httpserver)
|
||||
return ncat_http_server();
|
||||
|
|
@ -300,7 +304,7 @@ int ncat_listen()
|
|||
|
||||
init_fdlist(&broadcast_fdlist, o.conn_limit);
|
||||
|
||||
while (client_fdlist.nfds > 1 || get_conn_count() > 0) {
|
||||
while (!breakloop && (client_fdlist.nfds > 1 || get_conn_count() > 0)) {
|
||||
long usec_wait = -1;
|
||||
tvp = NULL;
|
||||
/* We pass these temporary descriptor sets to fselect, since fselect
|
||||
|
|
@ -388,7 +392,7 @@ restart_fd_loop:
|
|||
/* Are we in single listening mode(without -k)? If so
|
||||
then we should quit also. */
|
||||
if (!o.keepopen && !o.broker)
|
||||
return 1;
|
||||
breakloop = BREAKLOOP_ERROR;
|
||||
--conn_inc;
|
||||
break;
|
||||
}
|
||||
|
|
@ -407,16 +411,16 @@ restart_fd_loop:
|
|||
if (o.quitafter == 0 && (o.proto != IPPROTO_TCP || (o.proto == IPPROTO_TCP && o.sendonly))) {
|
||||
/* There will be nothing more to send. If we're not
|
||||
receiving anything, we can quit here. */
|
||||
return 0;
|
||||
breakloop = BREAKLOOP_SUCCESS;
|
||||
}
|
||||
}
|
||||
if (rc < 0)
|
||||
return 1;
|
||||
else if (rc < 0)
|
||||
breakloop = BREAKLOOP_ERROR;
|
||||
} else {
|
||||
/* Read from a client and write to stdout. */
|
||||
rc = read_socket(cfd, o.sendonly ? Ignore : Write);
|
||||
if (rc <= 0 && !o.keepopen)
|
||||
return rc == 0 ? 0 : 1;
|
||||
breakloop = (rc == 0 ? BREAKLOOP_SUCCESS : BREAKLOOP_ERROR);
|
||||
}
|
||||
|
||||
fds_ready--;
|
||||
|
|
@ -436,7 +440,7 @@ restart_fd_loop:
|
|||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return (breakloop == BREAKLOOP_ERROR ? 1 : 0);
|
||||
}
|
||||
|
||||
/* Accept a connection on a listening socket. Allow or deny the connection.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue