standalone-enc: move fd_drain() to a separate file#414
Conversation
|
It's useful to share At the moment it's only used in |
perftests/standalone-enc/fd_drain.h
Outdated
| * Drain bytes from the file descriptor ${*fd_p} -- passed as an (int *) -- as | ||
| * quickly as possible. | ||
| */ | ||
| int fd_drain(void *); |
There was a problem hiding this comment.
My original intent was only to expose fd_drain_fork(), but standalone_transfer_noencrypt.c uses threads rather than processes, so it needs to call fd_drain() directly.
There was a problem hiding this comment.
I'm not a fan of the "pass a pointer to the file descriptor, cast to void *" API here. How about int fd_drain(int) and static int fd_drain_internal(void *) which gets called by both of the externally-visible functions?
|
This has no impact on the perftest timings. When I first glanced at it with N=5 it looked like it did, but repeating the test with N=11 and then N=31 showed it was a fluke. |
2133364 to
d79c58e
Compare
perftests/standalone-enc/fd_drain.c
Outdated
| /* Loop until we hit EOF. */ | ||
| do { | ||
| /* | ||
| * This will almost always read 1060 bytes (size of an |
There was a problem hiding this comment.
This comment seems like it made sense in the original context of where this code was used, but doesn't belong any more once fd_drain is in a separate file since it could end up being used by completely different callers.
perftests/standalone-enc/fd_drain.h
Outdated
|
|
||
| #include <sys/types.h> | ||
|
|
||
| /* The smallest this can be is PCRYPT_ESZ (which is 1060). */ |
There was a problem hiding this comment.
Not sure if this comment is necessary or even correct any more?
There was a problem hiding this comment.
Hmm, I guess that if it's something tiny like 10 bytes, that would just mean read gets called more often.
... yeah, I'll delete it.
|
Flagged one more comment. Aside from that, looks good; please tidy up the history. |
- rename pipe_output() to fd_drain_internal() - simplify loop in fd_drain_internal() - rename MAXOUTSIZE to FD_DRAIN_MAX_SIZE - use (int *) instead of (struct pipeinfo) - add fd_drain_fork_start() - remove sanity check for FD_DRAIN_MAX_SIZE
d8a1d36 to
63936be
Compare
|
Rebased, ready for merge. |
No description provided.