search for: nr_fds

Displaying 20 results from an estimated 32 matches for "nr_fds".

2020 Feb 26
2
[PATCH] lib: command: switch from select() to poll()
...; -#include <sys/select.h> +#include <poll.h> #ifdef HAVE_SYS_TIME_H #include <sys/time.h> @@ -650,37 +649,41 @@ run_child (struct command *cmd) static int loop (struct command *cmd) { - fd_set rset, rset2; - int maxfd = -1, r; + struct pollfd fds[2]; + int r; size_t nr_fds = 0; CLEANUP_FREE char *buf = safe_malloc (cmd->g, BUFSIZ); ssize_t n; - FD_ZERO (&rset); + memset (&fds, 0, sizeof fds); + + fds[0].fd = cmd->errorfd; + fds[1].fd = cmd->outfd; if (cmd->errorfd >= 0) { - FD_SET (cmd->errorfd, &rset); - maxfd = M...
2020 Feb 26
0
Re: [PATCH] lib: command: switch from select() to poll()
...t; > #ifdef HAVE_SYS_TIME_H > #include <sys/time.h> > @@ -650,37 +649,41 @@ run_child (struct command *cmd) > static int > loop (struct command *cmd) > { > - fd_set rset, rset2; > - int maxfd = -1, r; > + struct pollfd fds[2]; > + int r; > size_t nr_fds = 0; > CLEANUP_FREE char *buf = safe_malloc (cmd->g, BUFSIZ); > ssize_t n; > > - FD_ZERO (&rset); > + memset (&fds, 0, sizeof fds); > + > + fds[0].fd = cmd->errorfd; > + fds[1].fd = cmd->outfd; > > if (cmd->errorfd >= 0) { > -...
2013 Jan 03
20
[PATCH] Switch to poll in xenconsoled's io loop.
...; - max_fd = MAX(xs_fileno(xs), max_fd); - - if (log_hv) { - FD_SET(xc_evtchn_fd(xce_handle), &readfds); - max_fd = MAX(xc_evtchn_fd(xce_handle), max_fd); - } +#define MAX_POLL_FDS 8192 + static struct pollfd fds[MAX_POLL_FDS]; + static struct pollfd *fd_to_pollfd[MAX_POLL_FDS]; + int nr_fds; +#define SET_FDS(_fd, _events) do { \ + if (_fd >= MAX_POLL_FDS) \ + break; \ + fds[nr_fds].fd = (_fd); \ + fds[nr_fds].events = (_events); \ + fd_to_pollfd[(_fd)] = &fds[nr_fds]; \ + nr_fds++; \ + } while (0) +#define FD_REVENTS(_fd) (((_fd) < MAX_POLL_FDS &am...
2020 Feb 26
1
Re: [PATCH] lib: command: switch from select() to poll()
...ude <sys/time.h> > > @@ -650,37 +649,41 @@ run_child (struct command *cmd) > > static int > > loop (struct command *cmd) > > { > > - fd_set rset, rset2; > > - int maxfd = -1, r; > > + struct pollfd fds[2]; > > + int r; > > size_t nr_fds = 0; > > CLEANUP_FREE char *buf = safe_malloc (cmd->g, BUFSIZ); > > ssize_t n; > > > > - FD_ZERO (&rset); > > + memset (&fds, 0, sizeof fds); > > + > > + fds[0].fd = cmd->errorfd; > > + fds[1].fd = cmd->outfd; > >...
2017 Feb 03
5
[PATCH 0/5] Support socket activation in virt-p2v.
As the subject says, support socket activation in virt-p2v. I have added upstream support for socket activation to nbdkit already: https://github.com/libguestfs/nbdkit/commit/7ff39d028c6359f5c0925ed2cf4a2c4c751af2e4 I posted a patch for qemu-nbd, still waiting on more reviews for that one: https://www.mail-archive.com/qemu-devel@nongnu.org/msg427246.html I tested this against old and new qemu
2017 Feb 04
0
[PATCH] ipconfig: handle multiple interfaces correctly
...- for (s = slist; s; s = s->next) - ret |= process_receive_event(s, now); + for (i = 0, s = slist; s && nr; s = s->next, i++) { + if (fds[i].revents & POLLRDNORM) { + ret |= process_receive_event(s, now); + nr--; + } + } return ret; } static int loop(void) { -#define NR_FDS 1 - struct pollfd fds[NR_FDS]; + struct pollfd *fds; struct state *s; - int pkt_fd; - int nr = 0, rc = 0; + int i, nr = 0, rc = 0; struct timeval now, prev; time_t start; - pkt_fd = packet_open(); - if (pkt_fd == -1) { - perror("packet_open"); - return -1; + fds = malloc(sizeof(...
2019 Jan 18
0
[klibc:master] ipconfig: handle multiple interfaces correctly
...- for (s = slist; s; s = s->next) - ret |= process_receive_event(s, now); + for (i = 0, s = slist; s && nr; s = s->next, i++) { + if (fds[i].revents & POLLRDNORM) { + ret |= process_receive_event(s, now); + nr--; + } + } return ret; } static int loop(void) { -#define NR_FDS 1 - struct pollfd fds[NR_FDS]; + struct pollfd *fds; struct state *s; - int pkt_fd; - int nr = 0, rc = 0; + int i, nr = 0, rc = 0; struct timeval now, prev; time_t start; - pkt_fd = packet_open(); - if (pkt_fd == -1) { - perror("packet_open"); - return -1; + fds = malloc(sizeof(...
2017 Jan 31
0
[PATCH nbdkit] Add support for socket activation.
...parsegroup (const char *id) return grp->gr_gid; } + +/* Returns 0 if no socket activation, or the number of FDs. + * See also virGetListenFDs in libvirt.org:src/util/virutil.c + */ +static unsigned int +get_socket_activation (void) +{ + const char *s; + unsigned int pid; + unsigned int nr_fds; + unsigned int i; + int fd; + + s = getenv ("LISTEN_PID"); + if (s == NULL) + return 0; + if (sscanf (s, "%u", &pid) != 1) { + fprintf (stderr, "%s: malformed %s environment variable (ignored)\n", + program_name, "LISTEN_PID"); +...
2003 Apr 29
0
[PATCH] Fix busy-looping behaviour in ipconfig
..._timeout_event(s, now.tv_sec); - if (timeout > s->expire - now) - timeout = s->expire - now; + if (timeout > s->expire - now.tv_sec) + timeout = s->expire - now.tv_sec; } if (pending == 0) break; - if (timeout < 0) - timeout = 0; - - nr = poll(fds, NR_FDS, timeout * 1000); - now = time(NULL); - - if (fds[0].revents & POLLRDNORM) - do_pkt_recv(pkt_fd, now); + timeout_ms = timeout * 1000; + + for (x = 0; x < 2; x++) { + int delta_ms; + + if (timeout_ms <= 0) + timeout_ms = 1; + + nr = poll(fds, NR_FDS, timeout_ms); + pr...
2019 Dec 03
7
[p2v PATCH 0/6] Use GLib a bit more
In an effort to reduce the code, start to use few bits of GLib: - replace the gnulib c-type module - replace the gnulib getprogname module - use g_spawn_sync to launch curl, and drop a file reading function Pino Toscano (6): Include glib.h in p2v.h Use g_ascii_isspace instead of c_isspace from gnulib Use g_get_prgname instead of getprogname from gnulib build: remove no more used gnulib
2017 Dec 31
4
[PATCH klibc 0/4] Fixes from Debian and Ubuntu
The following patches come from Debian and/or Ubuntu packages of klibc. Ben. Ben Hutchings (1): [klibc] run-init: Add dry-run mode Jay Vosburgh (1): [klibc] ipconfig: Use separate sockets for DHCP from multiple interfaces Mathieu Trudel-Lapierre (1): [klibc] ipconfig: Set broadcast when sending DHCPREQUEST and DHCPDISCOVER YunQiang Su (1): [klibc] mips: setjmp.S: don't
2005 Jan 06
0
skip unconnected interfaces
...f ((fd = open(t, O_RDONLY)) < 0) { + perror(t); + goto done; + } + + i = read(fd, &p, sizeof(p) - 1); + close(fd); + if (i < 0) { + perror(t); + goto done; + } + p[i] = '\0'; + *val = strtoul(p, NULL, 0); + + rc = 0; + done: + return rc; +} + static int loop(void) { #define NR_FDS 1 @@ -316,11 +349,27 @@ int pending = 0; int timeout_ms; int x; + unsigned long carrier; for (s = slist; s; s = s->next) { if (s->state == DEVST_COMPLETE) continue; + /* + * If we only want to configure net devices that + * are connected and it's been 10...
2003 Apr 29
0
[PATCH] Add configurable timeout to ipconfig
...ULL); + start = now.tv_sec; while (1) { int timeout = 60; int pending = 0; @@ -308,8 +311,8 @@ for (x = 0; x < 2; x++) { int delta_ms; - if (timeout_ms <= 0) - timeout_ms = 1; + if (timeout_ms <= 0 || loop_timeout == 0) + timeout_ms = 100; nr = poll(fds, NR_FDS, timeout_ms); prev = now; @@ -319,6 +322,14 @@ do_pkt_recv(pkt_fd, now.tv_sec) == 1) { break; } + + if (loop_timeout >= 0 && + now.tv_sec - start >= loop_timeout) { + printf("IP-Config: no response after %d " + "secs - giving up...
2018 Sep 08
0
[PATCH nbdkit v2 2/6] main: Tighten up characters permitted in config keys.
...;='); - if (p) { /* key=value */ + if (p && is_config_key (argv[optind], p - argv[optind])) { /* key=value */ *p = '\0'; backend->config (backend, argv[optind], p+1); } @@ -1281,3 +1282,32 @@ get_socket_activation (void) return nr_fds; } + +/* When parsing plugin and filter config key=value from the command + * line, check that the key is a simple alphanumeric with period, + * underscore or dash. + * + * Note this doesn't return an error. If the key is not valid then we + * return false and the parsing code will assume tha...
2018 Sep 10
0
[PATCH nbdkit v3 2/6] main: Tighten up characters permitted in config keys.
...;='); - if (p) { /* key=value */ + if (p && is_config_key (argv[optind], p - argv[optind])) { /* key=value */ *p = '\0'; backend->config (backend, argv[optind], p+1); } @@ -1281,3 +1282,36 @@ get_socket_activation (void) return nr_fds; } + +/* When parsing plugin and filter config key=value from the command + * line, check that the key is a simple alphanumeric with period, + * underscore or dash. + * + * Note this doesn't return an error. If the key is not valid then we + * return false and the parsing code will assume tha...
2012 Oct 18
10
[PATCH 0/10] Add a mini-library for running external commands.
Inspired by libvirt's virCommand* internal mini-library, this adds some internal APIs for running commands. The first patch contains the new APIs. The subsequent patches change various parts of the library over to use it. Rich.
2019 Sep 23
0
Re: [PATCH nbdkit] server: public: Add nbdkit_parse_* functions for safely parsing integers.
...(stderr, "%s: %s was not for us (ignored)\n", > program_name, "LISTEN_PID"); > @@ -73,11 +70,8 @@ get_socket_activation (void) > s = getenv ("LISTEN_FDS"); > if (s == NULL) > return 0; > - if (sscanf (s, "%u", &nr_fds) != 1) { > - fprintf (stderr, "%s: malformed %s environment variable (ignored)\n", > - program_name, "LISTEN_FDS"); > + if (nbdkit_parse_unsigned ("LISTEN_FDS", s, &nr_fds) == -1) > return 0; > - } and again > +++ b/server/...
2019 Sep 10
3
[PATCH 0/2] Remove virt-p2v from libguestfs
Now that virt-p2v has its own repository [1] and releases [2], it is time to remove it from libguestfs. [1] https://github.com/libguestfs/virt-p2v [2] http://download.libguestfs.org/virt-p2v/ Pino Toscano (2): Remove virt-p2v Remove remaining virt-p2v bits .gitignore | 4 - Makefile.am | 7 +- bash/Makefile.am
2010 Aug 25
0
[patch] ipconfig fixes + run-init nit
...changes - maks] Signed-off-by: maximilian attems <max at stro.at> diff --git a/usr/kinit/ipconfig/main.c b/usr/kinit/ipconfig/main.c index b014128..b392e6a 100644 --- a/usr/kinit/ipconfig/main.c +++ b/usr/kinit/ipconfig/main.c @@ -331,7 +331,7 @@ static int loop(void) struct pollfd fds[NR_FDS]; struct state *s; int pkt_fd; - int nr = 0; + int nr = 0, rc = 0; struct timeval now, prev; time_t start; @@ -396,6 +396,7 @@ static int loop(void) now.tv_sec - start >= loop_timeout) { printf("IP-Config: no response after %d " "secs - giving up...
2019 Sep 21
2
[PATCH nbdkit] server: public: Add nbdkit_parse_* functions for safely parsing integers.
...d != getpid ()) { fprintf (stderr, "%s: %s was not for us (ignored)\n", program_name, "LISTEN_PID"); @@ -73,11 +70,8 @@ get_socket_activation (void) s = getenv ("LISTEN_FDS"); if (s == NULL) return 0; - if (sscanf (s, "%u", &nr_fds) != 1) { - fprintf (stderr, "%s: malformed %s environment variable (ignored)\n", - program_name, "LISTEN_FDS"); + if (nbdkit_parse_unsigned ("LISTEN_FDS", s, &nr_fds) == -1) return 0; - } /* So these are not passed to any child processes...