tftp: do not show progress bar if we get error right away. +13 bytes
authorDenys Vlasenko <vda.linux@googlemail.com>
Fri, 5 Mar 2010 22:38:54 +0000 (23:38 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 5 Mar 2010 22:38:54 +0000 (23:38 +0100)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
include/libbb.h
libbb/progress.c
networking/Config.in
networking/dnsd.c
networking/tftp.c

index 515e995d0bf6117eaef0ab50a8c46473d1192582..ead1020dde2fdc6091686474b8c790db5f21941e 100644 (file)
@@ -1490,6 +1490,7 @@ typedef struct bb_progress_t {
        off_t lastsize;
        unsigned lastupdate_sec;
        unsigned start_sec;
+       smallint inited;
 } bb_progress_t;
 
 void bb_progress_init(bb_progress_t *p) FAST_FUNC;
index 3a245ae6ca2548fee4232c3e7d7e4c958ae91d70..0e484da6c7d1d4ab1df62263128fa6c2dc4bd876 100644 (file)
@@ -57,6 +57,7 @@ void FAST_FUNC bb_progress_init(bb_progress_t *p)
        p->start_sec = monotonic_sec();
        p->lastupdate_sec = p->start_sec;
        p->lastsize = 0;
+       p->inited = 1;
 }
 
 void FAST_FUNC bb_progress_update(bb_progress_t *p,
index 90d905ee6c1aa54ef98c8792af2c3963293af191..b01c38e51d409be57ec08a6bc2634f052556be9c 100644 (file)
@@ -860,7 +860,7 @@ config TFTPD
          or from udpsvd. Example: "udpsvd -E 0 69 tftpd DIR"
 
 config FEATURE_TFTP_GET
-       bool "Enable \"get\" command"
+       bool "Enable 'tftp get' and/or tftpd upload code"
        default y
        depends on TFTP || TFTPD
        help
@@ -868,8 +868,11 @@ config FEATURE_TFTP_GET
          a client to retrieve a file from a TFTP server.
          Also enable upload support in tftpd, if tftpd is selected.
 
+         Note: this option does _not_ make tftpd capable of download
+         (the usual operation people need from it)!
+
 config FEATURE_TFTP_PUT
-       bool "Enable \"put\" command"
+       bool "Enable 'tftp put' and/or tftpd download code"
        default y
        depends on TFTP || TFTPD
        help
index e73e244b0767747bd97cde5dda4d03e6ad73397d..6771c53461b2ce2b7e285f45da59340f7af2c1e7 100644 (file)
@@ -376,11 +376,6 @@ static int process_packet(struct dns_entry *conf_data,
        /* QR = 1 "response", RCODE = 4 "Not Implemented" */
        outr_flags = htons(0x8000 | 4);
        err_msg = NULL;
-       /* OPCODE != 0 "standard query" ? */
-       if ((head->flags & htons(0x7800)) != 0) {
-               err_msg = "opcode != 0";
-               goto empty_packet;
-       }
 
        /* start of query string */
        query_string = (void *)(head + 1);
@@ -392,6 +387,11 @@ static int process_packet(struct dns_entry *conf_data,
        /* where to append answer block */
        answb = (void *)(unaligned_type_class + 1);
 
+       /* OPCODE != 0 "standard query"? */
+       if ((head->flags & htons(0x7800)) != 0) {
+               err_msg = "opcode != 0";
+               goto empty_packet;
+       }
        move_from_unaligned16(class, &unaligned_type_class->class);
        if (class != htons(1)) { /* not class INET? */
                err_msg = "class != 1";
index 0e5b48d40914acb14fb7c9746596a0c192d23ad2..d76f7ae5b9a5df628d1e7231822dee47fcc60e8a 100644 (file)
@@ -135,7 +135,8 @@ static void tftp_progress_init(void)
 }
 static void tftp_progress_done(void)
 {
-       progress_meter(0);
+       if (G.pmt.inited)
+               progress_meter(0);
 }
 #else
 # define tftp_progress_init() ((void)0)