From 4e856a1324ff63e911cc1fdec4eae6f511baf480 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 1 Jul 2024 13:06:07 +0300 Subject: [PATCH] fixed --- plainbin.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/plainbin.c b/plainbin.c index 1adaac9..62d3180 100644 --- a/plainbin.c +++ b/plainbin.c @@ -15,7 +15,7 @@ #define SEND_TIMEOUT 1 #define RECV_TIMEOUT 2 #define MSG1 "Server is very busy.\n" -#define MSG2 "The file is very large.\n" +#define MSG2 "File is very large.\n" #define MSG3 "No such file.\n" #define MSG4 "No namespace available.\n" @@ -288,11 +288,15 @@ LD_ERROR: } void sig_handler(int sig) { - if (sig == SIGUSR1) - ifd_clients--; + if (sig == SIGUSR1) { + if (ifd_clients) + ifd_clients--; + } - else if (sig == SIGUSR2) - ofd_clients--; + else if (sig == SIGUSR2) { + if (ofd_clients) + ofd_clients--; + } else { close(ifd); @@ -393,7 +397,7 @@ int main(int argc, char **argv) { return 0; default: - printf("%s [iomdsnbtV] - Simple file sharing server\n\t-i NUM Input port\tdefault: %d\n\t-o NUM Output port\tdefault: %d\n\t-m NUM Max clients\tdefault: %zu\n\t-d DIR Word directory\tdefault: %s\n\t-s NUM Max file size\tdefault: %zuMB\n\t-n NUM Filename length\tdefault: %zu\n\t-b NUM Buffer size\tdefault: %zuB\n\t-t STR Set MOTD\n\t-V Print version and license\n", prog_name, iport, oport, max_clients, dir, max_size, name_len, buf_size); + printf("%s [iomdsnbtV] - Simple file sharing server\n\t-i NUM Input port\tdefault: %d\n\t-o NUM Output port\tdefault: %d\n\t-m NUM Max clients\tdefault: %zu\n\t-d STR Working dir\tdefault: %s\n\t-s NUM Max file size\tdefault: %zuMB\n\t-n NUM Filename length\tdefault: %zu\n\t-b NUM Buffer size\tdefault: %zuB\n\t-t STR Set MOTD\n\t-V Print version and license\n", prog_name, iport, oport, max_clients, dir, max_size, name_len, buf_size); return 0; } }