-
-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
posix pollers: expose pfd structures (for sizes) and fix poller selec…
…tion The poller selection in the previous poller changes for select were not quite functional. Also, while testing poll() based poller, there were problems where it simply did not work correctly, so this addresses those, and it seems to work now. The pfd structures are exposed as we intend to allow inlining them to eliminate the separate allocation and potential for failure during initialization. We also want to have plans afoot to eliminate a lot of the extra locking done done on each I/O iteration, and this is setting the foundation for that.
- Loading branch information
Showing
12 changed files
with
239 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech> | ||
// Copyright 2018 Capitar IT Group BV <info@capitar.com> | ||
// | ||
// This software is supplied under the terms of the MIT License, a | ||
// copy of which should be located in the distribution where this | ||
// file was obtained (LICENSE.txt). A copy of the license may also be | ||
// found online at https://opensource.org/licenses/MIT. | ||
// | ||
|
||
#ifndef PLATFORM_POSIX_POLLQ_EPOLL_H | ||
#define PLATFORM_POSIX_POLLQ_EPOLL_H | ||
|
||
#include <poll.h> | ||
|
||
// nni_posix_pfd is the handle used by the poller. It's internals are private | ||
// to the poller. | ||
struct nni_posix_pfd { | ||
nni_list_node node; | ||
struct nni_posix_pollq *pq; | ||
int fd; | ||
nni_posix_pfd_cb cb; | ||
void *arg; | ||
bool closed; | ||
bool closing; | ||
bool reap; | ||
unsigned events; | ||
nni_mtx mtx; | ||
nni_cv cv; | ||
}; | ||
|
||
#define NNI_POLL_IN ((unsigned) POLLIN) | ||
#define NNI_POLL_OUT ((unsigned) POLLOUT) | ||
#define NNI_POLL_HUP ((unsigned) POLLHUP) | ||
#define NNI_POLL_ERR ((unsigned) POLLERR) | ||
#define NNI_POLL_INVAL ((unsigned) POLLNVAL) | ||
|
||
#endif // PLATFORM_POSIX_POLLQ_EPOLL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech> | ||
// Copyright 2018 Capitar IT Group BV <info@capitar.com> | ||
// | ||
// This software is supplied under the terms of the MIT License, a | ||
// copy of which should be located in the distribution where this | ||
// file was obtained (LICENSE.txt). A copy of the license may also be | ||
// found online at https://opensource.org/licenses/MIT. | ||
// | ||
|
||
#ifndef PLATFORM_POSIX_POLLQ_KQUEUE_H | ||
#define PLATFORM_POSIX_POLLQ_KQUEUE_H | ||
|
||
// nni_posix_pfd is the handle used by the poller. It's internals are private | ||
// to the poller. | ||
struct nni_posix_pfd { | ||
nni_list_node node; // linkage into the reap list | ||
struct nni_posix_pollq *pq; // associated pollq | ||
int fd; // file descriptor to poll | ||
void *arg; // user data | ||
nni_posix_pfd_cb cb; // user callback on event | ||
bool closed; | ||
unsigned events; | ||
nni_cv cv; // signaled when poller has unregistered | ||
nni_mtx mtx; | ||
}; | ||
|
||
#define NNI_POLL_IN (0x0001) | ||
#define NNI_POLL_OUT (0x0010) | ||
#define NNI_POLL_HUP (0x0004) | ||
#define NNI_POLL_ERR (0x0008) | ||
#define NNI_POLL_INVAL (0x0020) | ||
|
||
#endif // PLATFORM_POSIX_POLLQ_KQUEUE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech> | ||
// Copyright 2018 Capitar IT Group BV <info@capitar.com> | ||
// | ||
// This software is supplied under the terms of the MIT License, a | ||
// copy of which should be located in the distribution where this | ||
// file was obtained (LICENSE.txt). A copy of the license may also be | ||
// found online at https://opensource.org/licenses/MIT. | ||
// | ||
|
||
#ifndef PLATFORM_POSIX_POLLQ_POLL_H | ||
#define PLATFORM_POSIX_POLLQ_POLL_H | ||
|
||
#include <poll.h> | ||
|
||
typedef struct nni_posix_pollq nni_posix_pollq; | ||
|
||
// nni_posix_pfd is the handle used by the poller. It's internals are private | ||
// to the poller. | ||
struct nni_posix_pfd { | ||
nni_posix_pollq *pq; | ||
int fd; | ||
nni_list_node node; | ||
nni_cv cv; | ||
nni_mtx mtx; | ||
unsigned events; | ||
nni_posix_pfd_cb cb; | ||
void *arg; | ||
}; | ||
|
||
#define NNI_POLL_IN ((unsigned) POLLIN) | ||
#define NNI_POLL_OUT ((unsigned) POLLOUT) | ||
#define NNI_POLL_HUP ((unsigned) POLLHUP) | ||
#define NNI_POLL_ERR ((unsigned) POLLERR) | ||
#define NNI_POLL_INVAL ((unsigned) POLLNVAL) | ||
|
||
#endif // PLATFORM_POSIX_POLLQ_POLL_H |
Oops, something went wrong.