seems to work for test 271 on Linux now!

This commit is contained in:
Daniel Stenberg 2005-09-19 22:03:16 +00:00
parent 3fe5311967
commit f5ae149338
1 changed files with 19 additions and 11 deletions

View File

@ -98,6 +98,9 @@
#include "getpart.h" #include "getpart.h"
#include "util.h" #include "util.h"
/* include memdebug.h last */
#include "memdebug.h"
struct testcase { struct testcase {
char *buffer; /* holds the file data to send to the client */ char *buffer; /* holds the file data to send to the client */
size_t bufsize; /* size of the data in buffer */ size_t bufsize; /* size of the data in buffer */
@ -509,10 +512,6 @@ int main(int argc, char **argv)
do { do {
FILE *server; FILE *server;
server = fopen(REQUEST_DUMP, "ab");
if(!server)
break;
fromlen = sizeof(from); fromlen = sizeof(from);
n = recvfrom(sock, buf, sizeof (buf), 0, n = recvfrom(sock, buf, sizeof (buf), 0,
(struct sockaddr *)&from, &fromlen); (struct sockaddr *)&from, &fromlen);
@ -533,13 +532,19 @@ int main(int argc, char **argv)
logmsg("connect: fail\n"); logmsg("connect: fail\n");
return 1; return 1;
} }
maxtimeout = 5*TIMEOUT;
tp = (struct tftphdr *)buf; tp = (struct tftphdr *)buf;
tp->th_opcode = ntohs(tp->th_opcode); tp->th_opcode = ntohs(tp->th_opcode);
if (tp->th_opcode == RRQ || tp->th_opcode == WRQ) { if (tp->th_opcode == RRQ || tp->th_opcode == WRQ) {
memset(&test, 0, sizeof(test)); memset(&test, 0, sizeof(test));
server = fopen(REQUEST_DUMP, "ab");
if(!server)
break;
test.server = server; test.server = server;
tftp(&test, tp, n); tftp(&test, tp, n);
if(test.buffer)
free(test.buffer);
} }
fclose(server); fclose(server);
sclose(peer); sclose(peer);
@ -612,6 +617,7 @@ again:
recvtftp(test, pf); recvtftp(test, pf);
else else
sendtftp(test, pf); sendtftp(test, pf);
return 0; return 0;
} }
@ -697,6 +703,8 @@ static void timer(int signum)
{ {
(void)signum; (void)signum;
logmsg("alarm!");
timeout += rexmtval; timeout += rexmtval;
if (timeout >= maxtimeout) if (timeout >= maxtimeout)
exit(1); exit(1);
@ -720,7 +728,7 @@ static void sendtftp(struct testcase *test, struct formats *pf)
size = readit(test, &dp, pf->f_convert); size = readit(test, &dp, pf->f_convert);
if (size < 0) { if (size < 0) {
nak(errno + 100); nak(errno + 100);
goto abort; return;
} }
dp->th_opcode = htons((u_short)DATA); dp->th_opcode = htons((u_short)DATA);
dp->th_block = htons((u_short)block); dp->th_block = htons((u_short)block);
@ -730,7 +738,7 @@ static void sendtftp(struct testcase *test, struct formats *pf)
send_data: send_data:
if (send(peer, dp, size + 4, 0) != size + 4) { if (send(peer, dp, size + 4, 0) != size + 4) {
logmsg("write\n"); logmsg("write\n");
goto abort; return;
} }
read_ahead(test, pf->f_convert); read_ahead(test, pf->f_convert);
for ( ; ; ) { for ( ; ; ) {
@ -739,13 +747,15 @@ static void sendtftp(struct testcase *test, struct formats *pf)
alarm(0); alarm(0);
if (n < 0) { if (n < 0) {
logmsg("read: fail\n"); logmsg("read: fail\n");
goto abort; return;
} }
ap->th_opcode = ntohs((u_short)ap->th_opcode); ap->th_opcode = ntohs((u_short)ap->th_opcode);
ap->th_block = ntohs((u_short)ap->th_block); ap->th_block = ntohs((u_short)ap->th_block);
if (ap->th_opcode == ERROR) if (ap->th_opcode == ERROR) {
goto abort; logmsg("got ERROR");
return;
}
if (ap->th_opcode == ACK) { if (ap->th_opcode == ACK) {
if (ap->th_block == block) { if (ap->th_block == block) {
@ -761,8 +771,6 @@ static void sendtftp(struct testcase *test, struct formats *pf)
} }
block++; block++;
} while (size == SEGSIZE); } while (size == SEGSIZE);
abort:
;
} }
static void justquit(int signum) static void justquit(int signum)