inc busy /dec busy code.

This commit is contained in:
Kelvin Sherlock 2012-08-26 15:51:46 -04:00
parent 7d31bafffc
commit caa54a0f3e
4 changed files with 50 additions and 8 deletions

View File

@ -26,13 +26,17 @@ int read_binary(Word ipid, FILE *file)
rrBuff rb;
Word count;
IncBusy();
rv = TCPIPReadTCP(ipid, 0, (Ref)buffer, 512, &rb);
DecBusy();
count = rb.rrBuffCount;
if (!count)
{
if (rv) break;
IncBusy();
TCPIPPoll();
DecBusy();
continue;
}
@ -59,9 +63,11 @@ int ConnectLoop(char *host, Word port, Connection *connection)
{
fprintf(stderr, "Connection timed out.\n");
IncBusy();
TCPIPAbortTCP(connection->ipid);
TCPIPLogout(connection->ipid);
DecBusy();
return 0;
}
}

View File

@ -45,8 +45,10 @@ static int gopher_text(Word ipid, FILE *file)
int rv = 0;
Word lastTerm = 0;
IncBusy();
TCPIPPoll();
DecBusy();
for(;;)
{
Word count;
@ -62,7 +64,10 @@ static int gopher_text(Word ipid, FILE *file)
if (rv < 0) break; // eof
if (rv == 0) // no data available (yet)
{
IncBusy();
TCPIPPoll();
DecBusy();
continue;
}
@ -146,11 +151,17 @@ static int gopher_dir(Word ipid, FILE *file)
if (rv < 0) break;
if (rv == 0)
{
IncBusy();
TCPIPPoll();
DecBusy();
continue;
}
if (!rb.moreFlag) TCPIPPoll();
if (!rb.moreFlag)
{
IncBusy();
TCPIPPoll();
DecBusy();
}
if (!count)
{
@ -351,6 +362,8 @@ int do_gopher(const char *url, URLComponents *components)
// path is /[type][resource]
// where [type] is 1 char and the leading / is ignored.
IncBusy();
if (path)
{
@ -370,6 +383,7 @@ int do_gopher(const char *url, URLComponents *components)
}
//
TCPIPWriteTCP(connection.ipid, "\r\n", 2, true, false);
DecBusy();

17
http.c
View File

@ -49,9 +49,9 @@ static int do_http_0_9(
char *cp;
int length;
IncBusy();
TCPIPWriteTCP(ipid, "GET ", 4, false, false);
length = components->pathAndQuery.length;
cp = url + components->pathAndQuery.location;
@ -61,9 +61,11 @@ static int do_http_0_9(
cp = "/";
}
TCPIPWriteTCP(ipid, cp, length, false, false);
TCPIPWriteTCP(ipid, "\r\n", 2, true, false);
DecBusy();
ok = read_binary(ipid, file);
return 0;
@ -90,7 +92,9 @@ static int parseHeaders(Word ipid, FILE *file, Handle dict)
line = 0;
IncBusy();
TCPIPPoll();
DecBusy();
for (;;)
{
@ -103,7 +107,9 @@ static int parseHeaders(Word ipid, FILE *file, Handle dict)
if (ok == 0)
{
IncBusy();
TCPIPPoll();
DecBusy();
continue;
}
@ -288,9 +294,10 @@ int read_response(Word ipid, FILE *file, Handle dict)
{
LongWord count = 256;
IncBusy();
TCPIPPoll();
TCPIPStatusTCP(ipid, &sr);
DecBusy();
count = sr.srRcvQueued;
if (count > contentSize) count = contentSize;
@ -300,7 +307,9 @@ int read_response(Word ipid, FILE *file, Handle dict)
continue;
}
IncBusy();
terr = TCPIPReadTCP(ipid, 2, (Ref)0, count, &rr);
DecBusy();
if (_toolErr) break;
@ -375,6 +384,7 @@ static int do_http_1_1(
// send the request.
// GET path HTTP/version\r\n
IncBusy();
if (flags._I)
TCPIPWriteTCP(ipid, "HEAD ", 5, false, false);
@ -416,6 +426,7 @@ static int do_http_1_1(
// end headers and push.
TCPIPWriteTCP(ipid, "\r\n", 2, true, false);
DecBusy();
DisposeHandle(dict);
dict = NULL;

View File

@ -3,6 +3,17 @@
#include <stdio.h>
#define IncBusy() asm { jsl 0xE10064 }
#define DecBusy() asm { jsl 0xE10068 }
#define Resched() asm { cop 0x7f }
#define BusyFlag ((byte *)0xE100FFl)
#define SEI() asm { sei }
#define CLI() asm { cli }
int read_binary(unsigned ipid, FILE *file);
int setfiletype(const char *filename);