search for: pollfd

Displaying 20 results from an estimated 183 matches for "pollfd".

2019 May 31
4
[libnbd] Simultaneous read and write
..., or whenever you call nbd_aio_notify_*. You therefore have to call nbd_aio_get_direction frequently. A typical loop using poll might look like: fd = nbd_aio_get_fd (nbd); for (;;) { /* <-- If you need to issue more commands, do that here. */ dir = nbd_aio_get_direction (nbd); pollfd[0].fd = fd; pollfd[0].events = 0; if (dir & LIBNBD_AIO_DIRECTION_READ) pollfd[0].events |= POLLIN; if (dir & LIBNBD_AIO_DIRECTION_WRITE) pollfd[0].events |= POLLOUT; poll (pollfd, 1, -1); if (pollfd[0].revents & LIBNBD_AIO_DIRECTION_READ) nbd_aio_notify_read ()...
2019 May 31
0
[libnbd] Simultaneous read and write
...therefore have to call > nbd_aio_get_direction frequently. > > A typical loop using poll might look like: > > fd = nbd_aio_get_fd (nbd); > for (;;) { > /* <-- If you need to issue more commands, do that here. */ > dir = nbd_aio_get_direction (nbd); > pollfd[0].fd = fd; > pollfd[0].events = 0; > if (dir & LIBNBD_AIO_DIRECTION_READ) pollfd[0].events |= POLLIN; > if (dir & LIBNBD_AIO_DIRECTION_WRITE) pollfd[0].events |= POLLOUT; > poll (pollfd, 1, -1); > if (pollfd[0].revents & LIBNBD_AIO_DIRECTION_READ) Ra...
2013 Jan 03
20
[PATCH] Switch to poll in xenconsoled's io loop.
...ERO(&readfds); - FD_ZERO(&writefds); - - FD_SET(xs_fileno(xs), &readfds); - 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]; \ +...
2019 Jul 15
0
[PATCH libnbd] examples: Include an example of integrating with the glib main loop.
...the first element in this struct. */ + GSource source; + + /* The underlying libnbd handle. */ + struct nbd_handle *nbd; + bool debug; /* true if handle has debug set */ + + /* The poll file descriptor, only valid when poll_registered == true. */ + bool poll_registered; + GPollFD pollfd; + + /* You can optionally register callbacks to be called when the + * handle changes state: + * + * connecting_callback is called once when the handle moves from + * created to connecting state. + * + * connected_callback is called once when the handle moves from + * connect...
2019 Jul 15
2
[PATCH libnbd] examples: Include an example of integrating with the glibc main loop.
** NOT WORKING ** This patch shows how to integrate libnbd and the glib main loop. Posted mainly as a point of discussion as it doesn't quite work yet. Rich.
2018 Feb 06
1
Segmentation fault in "make check" test_istream_multiplex for 2.3.0 on Solaris Sparc
...g "make check" for version 2.3.0 on Solaris Sparc. The build was done with gcc 7.3.0. The crash happens in ioloop-poll.c line 181 when running test_istream_multiplex.c: #0 io_loop_handler_run_internal (ioloop=ioloop at entry=0x130dd0) at ioloop-poll.c:181 181 if (pollfd->revents != 0) { Due to the code 180 pollfd = &ctx->fds[ctx->fd_index[io->fd]]; 181 if (pollfd->revents != 0) { I can see in gdb, that io->fd is "-1", so using it as an array index doesn't make much sense: (gdb) prin...
2019 Jul 17
1
Re: [PATCH libnbd] examples: Include an example of integrating with the glib main loop.
...> +prepare (GSource *sp, gint *timeout_) > +{ > + struct NBDSource *source = (struct NBDSource *) sp; > + > + /* When the NBD handle moves out of the created state (which means > + * that it first has a socket associated with it) we must initialize > + * and register the pollfd. > + */ > + if (!source->poll_registered && !nbd_aio_is_created (source->nbd)) { > + int fd; > + > + if (source->connecting_callback) { > + DEBUG (source, "calling connecting_callback"); > + source->connecting_callback (source);...
2020 Aug 11
3
[PATCH v3] virtio-rng: return available data with O_NONBLOCK
...to use non-blocking mode in a task, problem occurs if CONDITION is 1 */ > //#define CONDITION (getpid() % 2 != 0) > > static volatile sig_atomic_t stop; > static void handler(int sig __attribute__((unused))) { stop = 1; } > > static void loop(int fd, int sec) > { > struct pollfd pfd = { .fd = fd, .events = POLLIN, }; > unsigned long errors = 0, eagains = 0, bytes = 0, succ = 0; > int size, rc, rd; > > srandom(getpid()); > if (CONDITION && fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK) == -1) > perror("fcntl"); > size = M...
2020 Aug 11
3
[PATCH v3] virtio-rng: return available data with O_NONBLOCK
...to use non-blocking mode in a task, problem occurs if CONDITION is 1 */ > //#define CONDITION (getpid() % 2 != 0) > > static volatile sig_atomic_t stop; > static void handler(int sig __attribute__((unused))) { stop = 1; } > > static void loop(int fd, int sec) > { > struct pollfd pfd = { .fd = fd, .events = POLLIN, }; > unsigned long errors = 0, eagains = 0, bytes = 0, succ = 0; > int size, rc, rd; > > srandom(getpid()); > if (CONDITION && fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK) == -1) > perror("fcntl"); > size = M...
2019 Sep 05
2
[PATCH nbdkit] Ban use of stack Variable Length Arrays (VLAs).
...tem (cmd); free (script); } diff --git a/server/sockets.c b/server/sockets.c index 26d65c6..dfaa3ea 100644 --- a/server/sockets.c +++ b/server/sockets.c @@ -366,10 +366,16 @@ accept_connection (int listen_sock) static void check_sockets_and_quit_fd (int *socks, size_t nr_socks) { - struct pollfd fds[nr_socks + 1]; size_t i; int r; + CLEANUP_FREE struct pollfd *fds = + malloc (sizeof (struct pollfd) * (nr_socks+1)); + if (fds == NULL) { + perror ("malloc"); + exit (EXIT_FAILURE); + } + for (i = 0; i < nr_socks; ++i) { fds[i].fd = socks[i]; fds[i...
2013 Feb 19
13
[PATCH] mini-os: implement poll(2)
...+#include <poll.h> #include <sys/types.h> #include <sys/unistd.h> @@ -678,6 +679,29 @@ static void dump_set(int nfds, fd_set *readfds, fd_set *writefds, fd_set *except #define dump_set(nfds, readfds, writefds, exceptfds, timeout) #endif +#ifdef LIBC_DEBUG +static void dump_pollfds(struct pollfd *pfd, int nfds, int timeout) +{ + int i, comma, fd; + + printk("["); + comma = 0; + for (i = 0; i < nfds; i++) { + fd = pfd[i].fd; + if (comma) + printk(", "); + printk("%d(%c)/%02x", fd, file_types[files[fd...
1999 Dec 14
0
1.2pre17 fails to compile on RedHat 4.2/i386 (libc5)
...In later versions (glibc), daemon is defined in unistd.h as: unistd.h:extern int daemon __P ((int __nochdir, int __noclose)); Notes, configure DOES check for daemon: checking for daemon... yes If I create this manually, it seems to compile. And poll.h just includes sys/poll.h which defines struct pollfd, and the functions: extern int __poll __P ((struct pollfd *__fds, unsigned long int __nfds, int __timeout)); extern int poll __P ((struct pollfd *__fds, unsigned long int __nfds, int __timeout)); If I copy in a poll.h, I get (obvi...
2006 Dec 10
2
segfault in RC15
...t (context=0x80db000) at client.c:433 client = (struct client *) 0x80db000 cmd = (struct client_command_context *) 0x80db044 ret = 2 #9 0x80a9608 in io_loop_handler_run (ioloop=0x80d7000) at ioloop-poll.c:199 ctx = (struct ioloop_handler_context *) 0x80cb0a0 pollfd = (struct pollfd *) 0x2 tv = {tv_sec = 0, tv_usec = 888475} io = (struct io *) 0x80cb4a0 t_id = 2 msecs = 135099072 ret = 0 call = 135099072 #10 0x80a901d in io_loop_run (ioloop=0x80d7000) at ioloop.c:281 ioloop = (struct ioloop *) 0x80d7000 #...
2019 Sep 05
0
Re: [PATCH nbdkit] Ban use of stack Variable Length Arrays (VLAs).
...tead of /tmp/nbdkitshXXXXXX), then we'd need shell quoting here. But doesn't change this patch. > +++ b/server/sockets.c > @@ -366,10 +366,16 @@ accept_connection (int listen_sock) > static void > check_sockets_and_quit_fd (int *socks, size_t nr_socks) > { > - struct pollfd fds[nr_socks + 1]; > size_t i; > int r; > > + CLEANUP_FREE struct pollfd *fds = > + malloc (sizeof (struct pollfd) * (nr_socks+1)); This is indeed safer, but adds a malloc() in a loop. Thankfully, the loop of accept_incoming_connections() doesn't cycle that quickly...
2023 Jan 14
1
[klibc:time64] time: Use 64-bit time types on all architectures
...const struct __pselect6 *); +<32> int pselect6_time64::__pselect6(int, fd_set *, fd_set *, fd_set *, struct timespec *, const struct __pselect6 *); +<64> int pselect6::__pselect6(int, fd_set *, fd_set *, fd_set *, struct timespec *, const struct __pselect6 *); <?> int poll(struct pollfd *, nfds_t, long); -<?> int ppoll::__ppoll(struct pollfd *, nfds_t, struct timespec *, const sigset_t *, size_t); +<32> int ppoll_time64::__ppoll(struct pollfd *, nfds_t, struct timespec *, const sigset_t *, size_t); +<64> int ppoll::__ppoll(struct pollfd *, nfds_t, struct timespec...
2018 Dec 09
2
[PATCH] Enable ConnectTimeout with ConnectionAttempts
...tps://bugzilla.mindrot.org/show_bug.cgi?id=2918 --- sshconnect.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sshconnect.c b/sshconnect.c index 4862da5e..b837a83a 100644 --- a/sshconnect.c +++ b/sshconnect.c @@ -454,11 +454,12 @@ waitrfd(int fd, int *timeoutp) { struct pollfd pfd; struct timeval t_start; - int oerrno, r; + int oerrno, r, next_timeout; monotime_tv(&t_start); pfd.fd = fd; pfd.events = POLLIN; + next_timeout = *timeoutp; for (; *timeoutp >= 0;) { r = poll(&pfd, 1, *timeoutp); oerrno = errno; @@ -473,6 +474,7 @@ waitrfd(int fd,...
2017 Feb 04
0
[PATCH] ipconfig: handle multiple interfaces correctly
...g(dev); print_device_config(dev); + packet_close(dev); ++configured; @@ -374,34 +376,36 @@ struct netdev *ifaces; * 0 = No dhcp/bootp packet was received * 1 = A packet was received and handled */ -static int do_pkt_recv(int pkt_fd, time_t now) +static int do_pkt_recv(int nr, struct pollfd *fds, time_t now) { - int ret = 0; + int i, ret = 0; struct state *s; - 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...
2019 Jan 18
0
[klibc:master] ipconfig: handle multiple interfaces correctly
...g(dev); print_device_config(dev); + packet_close(dev); ++configured; @@ -374,34 +376,36 @@ struct netdev *ifaces; * 0 = No dhcp/bootp packet was received * 1 = A packet was received and handled */ -static int do_pkt_recv(int pkt_fd, time_t now) +static int do_pkt_recv(int nr, struct pollfd *fds, time_t now) { - int ret = 0; + int i, ret = 0; struct state *s; - 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...
2020 Aug 11
0
[PATCH v2] virtio-rng: return available data with O_NONBLOCK
...to use non-blocking mode in a task, problem occurs if CONDITION is 1 */ > //#define CONDITION (getpid() % 2 != 0) > > static volatile sig_atomic_t stop; > static void handler(int sig __attribute__((unused))) { stop = 1; } > > static void loop(int fd, int sec) > { > struct pollfd pfd = { .fd = fd, .events = POLLIN, }; > unsigned long errors = 0, eagains = 0, bytes = 0, succ = 0; > int size, rc, rd; > > srandom(getpid()); > if (CONDITION && fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK) == -1) > perror("fcntl"); > size = M...
2020 Aug 11
0
[PATCH v2] virtio-rng: return available data with O_NONBLOCK
...task, problem occurs if CONDITION is 1 */ >> //#define CONDITION (getpid() % 2 != 0) >> >> static volatile sig_atomic_t stop; >> static void handler(int sig __attribute__((unused))) { stop = 1; } >> >> static void loop(int fd, int sec) >> { >> struct pollfd pfd = { .fd = fd, .events = POLLIN, }; >> unsigned long errors = 0, eagains = 0, bytes = 0, succ = 0; >> int size, rc, rd; >> >> srandom(getpid()); >> if (CONDITION && fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK) == -1) >> perror("fcntl...