Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
boazsegev committed Feb 8, 2025
1 parent ff382f5 commit 09cf377
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 26 deletions.
4 changes: 3 additions & 1 deletion fio-stl.h
Original file line number Diff line number Diff line change
Expand Up @@ -10861,7 +10861,9 @@ SFUNC size_t fio_sock_maximize_limits(size_t maximum_limit);
*
* A zero timeout returns immediately.
*
* Possible events are POLLIN | POLLOUT
* Possible events include POLLIN | POLLOUT
*
* Possible return values include POLLIN | POLLOUT | POLLHUP | POLLNVAL
*/
SFUNC short fio_sock_wait_io(int fd, short events, int timeout);

Expand Down
31 changes: 19 additions & 12 deletions fio-stl.md
Original file line number Diff line number Diff line change
Expand Up @@ -4168,33 +4168,40 @@ Uses `poll` to wait until an IO device has one or more of the evens listed in `e

Returns 0 on timeout, -1 on error or the events that are valid.

#### `FIO_SOCK_POLL_RW` (macro)
Possible valid return values also include `POLLIN | POLLOUT | POLLHUP | POLLNVAL`

#### `FIO_SOCK_WAIT_RW`

```c
#define FIO_SOCK_POLL_RW(fd_) \
(struct pollfd) { .fd = fd_, .events = (POLLIN | POLLOUT) }
#define FIO_SOCK_WAIT_RW(fd, timeout_) fio_sock_wait_io(fd, POLLIN | POLLOUT, timeout_)
```

This helper macro helps to author a `struct pollfd` member who's set to polling for both read and write events (data availability and/or space in the outgoing buffer).
A helper macro that waits on a single IO with no callbacks (0 = no event)

#### `FIO_SOCK_POLL_R` (macro)
#### `FIO_SOCK_WAIT_R`

```c
#define FIO_SOCK_POLL_R(fd_) \
(struct pollfd) { .fd = fd_, .events = POLLIN }
#define FIO_SOCK_WAIT_R(fd, timeout_) fio_sock_wait_io(fd, POLLIN, timeout_)
```

This helper macro helps to author a `struct pollfd` member who's set to polling for incoming data availability.
A helper macro that waits on a single IO with no callbacks (0 = no event)

#### `FIO_SOCK_WAIT_W`

```c
#define FIO_SOCK_WAIT_W(fd, timeout_) fio_sock_wait_io(fd, POLLOUT, timeout_)
```

A helper macro that waits on a single IO with no callbacks (0 = no event)

#### `FIO_SOCK_POLL_W` (macro)
#### `FIO_SOCK_IS_OPEN`

```c
#define FIO_SOCK_POLL_W(fd_) \
(struct pollfd) { .fd = fd_, .events = POLLOUT }
#define FIO_SOCK_IS_OPEN(fd) \
(!(fio_sock_wait_io(fd, POLLOUT, 0) & (POLLHUP | POLLNVAL)))
```

This helper macro helps to author a `struct pollfd` member who's set to polling for space in the outgoing `fd`'s buffer.
A helper macro that tests if a socket was remotely closed.

#### `fio_sock_address_new`

Expand Down
4 changes: 3 additions & 1 deletion fio-stl/004 sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ SFUNC size_t fio_sock_maximize_limits(size_t maximum_limit);
*
* A zero timeout returns immediately.
*
* Possible events are POLLIN | POLLOUT
* Possible events include POLLIN | POLLOUT
*
* Possible return values include POLLIN | POLLOUT | POLLHUP | POLLNVAL
*/
SFUNC short fio_sock_wait_io(int fd, short events, int timeout);

Expand Down
31 changes: 19 additions & 12 deletions fio-stl/004 sock.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,33 +104,40 @@ Uses `poll` to wait until an IO device has one or more of the evens listed in `e
Returns 0 on timeout, -1 on error or the events that are valid.
#### `FIO_SOCK_POLL_RW` (macro)
Possible valid return values also include `POLLIN | POLLOUT | POLLHUP | POLLNVAL`
#### `FIO_SOCK_WAIT_RW`
```c
#define FIO_SOCK_POLL_RW(fd_) \
(struct pollfd) { .fd = fd_, .events = (POLLIN | POLLOUT) }
#define FIO_SOCK_WAIT_RW(fd, timeout_) fio_sock_wait_io(fd, POLLIN | POLLOUT, timeout_)
```

This helper macro helps to author a `struct pollfd` member who's set to polling for both read and write events (data availability and/or space in the outgoing buffer).
A helper macro that waits on a single IO with no callbacks (0 = no event)

#### `FIO_SOCK_POLL_R` (macro)
#### `FIO_SOCK_WAIT_R`

```c
#define FIO_SOCK_POLL_R(fd_) \
(struct pollfd) { .fd = fd_, .events = POLLIN }
#define FIO_SOCK_WAIT_R(fd, timeout_) fio_sock_wait_io(fd, POLLIN, timeout_)
```
This helper macro helps to author a `struct pollfd` member who's set to polling for incoming data availability.
A helper macro that waits on a single IO with no callbacks (0 = no event)
#### `FIO_SOCK_WAIT_W`
```c
#define FIO_SOCK_WAIT_W(fd, timeout_) fio_sock_wait_io(fd, POLLOUT, timeout_)
```

A helper macro that waits on a single IO with no callbacks (0 = no event)

#### `FIO_SOCK_POLL_W` (macro)
#### `FIO_SOCK_IS_OPEN`

```c
#define FIO_SOCK_POLL_W(fd_) \
(struct pollfd) { .fd = fd_, .events = POLLOUT }
#define FIO_SOCK_IS_OPEN(fd) \
(!(fio_sock_wait_io(fd, POLLOUT, 0) & (POLLHUP | POLLNVAL)))
```

This helper macro helps to author a `struct pollfd` member who's set to polling for space in the outgoing `fd`'s buffer.
A helper macro that tests if a socket was remotely closed.

#### `fio_sock_address_new`

Expand Down

0 comments on commit 09cf377

Please sign in to comment.