From 4bea91fc677359f3dcedb05a431258b6cd5d98f3 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 22 Aug 2013 22:40:38 +0200 Subject: TFTP: make the CURLOPT_LOW_SPEED* options work ... this also makes sure that the progess callback gets called more often during TFTP transfers. Added test 1238 to verify. Bug: http://curl.haxx.se/bug/view.cgi?id=1269 Reported-by: Jo3 --- lib/tftp.c | 10 ++++++++++ tests/data/Makefile.am | 2 +- tests/data/test1238 | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 tests/data/test1238 diff --git a/lib/tftp.c b/lib/tftp.c index b582ab319..f1ffd2a3a 100644 --- a/lib/tftp.c +++ b/lib/tftp.c @@ -56,6 +56,7 @@ #include "multiif.h" #include "url.h" #include "rawstr.h" +#include "speedcheck.h" #define _MPRINTF_REPLACE /* use our functions only */ #include @@ -1255,6 +1256,15 @@ static CURLcode tftp_doing(struct connectdata *conn, bool *dophase_done) if(*dophase_done) { DEBUGF(infof(conn->data, "DO phase is complete\n")); } + else { + /* The multi code doesn't have this logic for the DOING state so we + provide it for TFTP since it may do the entire transfer in this + state. */ + if(Curl_pgrsUpdate(conn)) + result = CURLE_ABORTED_BY_CALLBACK; + else + result = Curl_speedcheck(conn->data, Curl_tvnow()); + } return result; } diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index d9957f030..e0007f406 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -94,7 +94,7 @@ test1208 test1209 test1210 test1211 test1212 test1213 test1214 test1215 \ test1216 test1217 test1218 test1219 \ test1220 test1221 test1222 test1223 test1224 test1225 test1226 test1227 \ test1228 test1229 test1230 test1231 test1232 test1233 test1234 test1235 \ -test1236 test1237 \ +test1236 test1237 test1238 \ \ test1300 test1301 test1302 test1303 test1304 test1305 test1306 test1307 \ test1308 test1309 test1310 test1311 test1312 test1313 test1314 test1315 \ diff --git a/tests/data/test1238 b/tests/data/test1238 new file mode 100644 index 000000000..18593398a --- /dev/null +++ b/tests/data/test1238 @@ -0,0 +1,49 @@ + + + +TFTP +TFTP RRQ + + + +# +# Server-side + + +writedelay: 1 + +# ~1200 bytes (so that they don't fit in two 512 byte chunks) + +012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 + + + +# +# Client-side + + +tftp + + +slow TFTP retrieve cancel due to -Y and -y + +# if less than 1000 bytes/sec within 2 seconds, abort! + +tftp://%HOSTIP:%TFTPPORT//1238 -Y1000 -y2 + + + +# +# Verify pseudo protocol after the test has been "shot" + + +opcode: 1 +filename: /1238 +mode: octet + +# 28 = CURLE_OPERATION_TIMEDOUT + +28 + + + -- cgit v1.2.3