Compare commits

..

No commits in common. "7ee54bddf291c153b6a22d5331aa520d97f4be06" and "3dfc258fa414d62a8c201bdaad29fbe6128280e2" have entirely different histories.

2 changed files with 1 additions and 18 deletions

View file

@ -2,12 +2,6 @@
## Upcoming Changes ## Upcoming Changes
## Version 1.3
Prevent `simplearchiver` from busy-waiting during non-blocking IO by sleeping
in "EWOULDBLOCK" conditions. This results in less consumed cpu time by the
process, especially during compression.
## Version 1.2 ## Version 1.2
Proper handling of Ctrl+C (SIGINT). This prevents temporary files from Proper handling of Ctrl+C (SIGINT). This prevents temporary files from

View file

@ -64,8 +64,6 @@ void handle_sig_int(int sig) {
is_sig_int_occurred = 1; is_sig_int_occurred = 1;
} }
} }
const struct timespec nonblock_sleep = {.tv_sec = 0, .tv_nsec = 1000000};
#endif #endif
typedef struct SDArchiverInternalToWrite { typedef struct SDArchiverInternalToWrite {
@ -299,7 +297,6 @@ int write_files_fn(void *data, void *ud) {
ret = write(pipe_into_cmd[1], write_buf, write_count); ret = write(pipe_into_cmd[1], write_buf, write_count);
if (ret == -1) { if (ret == -1) {
if (errno == EAGAIN || errno == EWOULDBLOCK) { if (errno == EAGAIN || errno == EWOULDBLOCK) {
nanosleep(&nonblock_sleep, NULL);
write_again = 1; write_again = 1;
} else { } else {
// Error during write. // Error during write.
@ -357,7 +354,7 @@ int write_files_fn(void *data, void *ud) {
// fprintf(stderr, "read_done\n"); // fprintf(stderr, "read_done\n");
} else if (ret == -1) { } else if (ret == -1) {
if (errno == EAGAIN || errno == EWOULDBLOCK) { if (errno == EAGAIN || errno == EWOULDBLOCK) {
nanosleep(&nonblock_sleep, NULL); // Nop.
} else { } else {
// Read error. // Read error.
fprintf(stderr, fprintf(stderr,
@ -1174,7 +1171,6 @@ int read_decomp_to_out_file(const char *out_filename, int in_pipe,
} else { } else {
if (errno == EAGAIN || errno == EWOULDBLOCK) { if (errno == EAGAIN || errno == EWOULDBLOCK) {
// Non-blocking read from pipe. // Non-blocking read from pipe.
nanosleep(&nonblock_sleep, NULL);
continue; continue;
} else { } else {
// Error. // Error.
@ -1214,7 +1210,6 @@ int read_decomp_to_out_file(const char *out_filename, int in_pipe,
} else { } else {
if (errno == EAGAIN || errno == EWOULDBLOCK) { if (errno == EAGAIN || errno == EWOULDBLOCK) {
// Non-blocking read from pipe. // Non-blocking read from pipe.
nanosleep(&nonblock_sleep, NULL);
continue; continue;
} else { } else {
// Error. // Error.
@ -2441,7 +2436,6 @@ int simple_archiver_write_v1(FILE *out_f, SDArchiverState *state,
// Non-blocking write. // Non-blocking write.
has_hold = (int)fread_ret; has_hold = (int)fread_ret;
memcpy(hold_buf, buf, fread_ret); memcpy(hold_buf, buf, fread_ret);
nanosleep(&nonblock_sleep, NULL);
} else { } else {
fprintf( fprintf(
stderr, stderr,
@ -2468,7 +2462,6 @@ int simple_archiver_write_v1(FILE *out_f, SDArchiverState *state,
if (write_ret < 0) { if (write_ret < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK) { if (errno == EAGAIN || errno == EWOULDBLOCK) {
// Non-blocking write. // Non-blocking write.
nanosleep(&nonblock_sleep, NULL);
} else { } else {
return SDAS_INTERNAL_ERROR; return SDAS_INTERNAL_ERROR;
} }
@ -2491,7 +2484,6 @@ int simple_archiver_write_v1(FILE *out_f, SDArchiverState *state,
if (read_ret < 0) { if (read_ret < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK) { if (errno == EAGAIN || errno == EWOULDBLOCK) {
// Non-blocking read. // Non-blocking read.
nanosleep(&nonblock_sleep, NULL);
} else { } else {
fprintf(stderr, fprintf(stderr,
"ERROR: Reading from compressor, pipe read error!\n"); "ERROR: Reading from compressor, pipe read error!\n");
@ -2526,7 +2518,6 @@ int simple_archiver_write_v1(FILE *out_f, SDArchiverState *state,
if (read_ret < 0) { if (read_ret < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK) { if (errno == EAGAIN || errno == EWOULDBLOCK) {
// Non-blocking read. // Non-blocking read.
nanosleep(&nonblock_sleep, NULL);
} else { } else {
fprintf(stderr, fprintf(stderr,
"ERROR: Reading from compressor, pipe read error!\n"); "ERROR: Reading from compressor, pipe read error!\n");
@ -3163,7 +3154,6 @@ int simple_archiver_parse_archive_version_0(FILE *in_f, int_fast8_t do_extract,
} }
} else if (write_ret == -1) { } else if (write_ret == -1) {
if (errno == EAGAIN || errno == EWOULDBLOCK) { if (errno == EAGAIN || errno == EWOULDBLOCK) {
nanosleep(&nonblock_sleep, NULL);
write_again = 1; write_again = 1;
} else { } else {
// Error. // Error.
@ -3207,7 +3197,6 @@ int simple_archiver_parse_archive_version_0(FILE *in_f, int_fast8_t do_extract,
} else if (read_ret == -1) { } else if (read_ret == -1) {
if (errno == EAGAIN || errno == EWOULDBLOCK) { if (errno == EAGAIN || errno == EWOULDBLOCK) {
// No bytes to read yet. // No bytes to read yet.
nanosleep(&nonblock_sleep, NULL);
} else { } else {
// Error. // Error.
fprintf(stderr, fprintf(stderr,