mirror of
https://github.com/ksherlock/marignotti.git
synced 2025-03-03 01:29:40 +00:00
fix bugs
This commit is contained in:
parent
c58d6d456d
commit
1883b2ce7a
8
driver.c
8
driver.c
@ -2,6 +2,7 @@
|
||||
#include <gno/kerntool.h>
|
||||
#include <errno.h>
|
||||
#include "net.h"
|
||||
#include "s16debug.h"
|
||||
|
||||
#pragma noroot
|
||||
#pragma optimize 79
|
||||
@ -13,12 +14,12 @@ int block(int sem)
|
||||
return xerrno;
|
||||
}
|
||||
|
||||
int queue_command(Entry *e, word command, LongWord cookie, LongWord timeout)
|
||||
int queue_command(Entry *e, Word command, LongWord cookie, LongWord timeout)
|
||||
{
|
||||
int xerrno;
|
||||
|
||||
SEI();
|
||||
e->command = kCommandRead;
|
||||
e->command = command;
|
||||
e->cookie = cookie;
|
||||
e->timeout = timeout;
|
||||
CLI();
|
||||
@ -44,6 +45,9 @@ int driver(
|
||||
int rv;
|
||||
Entry *e;
|
||||
|
||||
s16_debug_printf("driver: %04x : %04x", socknum, req);
|
||||
|
||||
|
||||
if (req == PRU_ATTACH)
|
||||
{
|
||||
return mattach(socknum, p1, p2, p3, p4, p5);
|
||||
|
@ -63,7 +63,7 @@ typedef struct xsockaddr_in {
|
||||
#define CLI() asm { cli }
|
||||
|
||||
int block(int sem);
|
||||
int queue_command(Entry *e, word command, LongWord cookie, LongWord timeout);
|
||||
int queue_command(Entry *e, Word command, LongWord cookie, LongWord timeout);
|
||||
|
||||
void init_table(void);
|
||||
void destroy_table(void);
|
||||
|
@ -18,7 +18,7 @@ int mattach(int type, void *p1, void *p2, void *p3, void *p4, void *p5)
|
||||
int protocol = *(int *)p3;
|
||||
|
||||
if (type != SOCK_STREAM) return ESOCKTNOSUPPORT;
|
||||
if (protocol != 6) return EPROTONOSUPPORT;
|
||||
//if (protocol != 6) return EPROTONOSUPPORT;
|
||||
// TODO -- check protocol? 6 = tcp, 1 = icmp, 17 = udp.
|
||||
|
||||
IncBusy();
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <gno/kerntool.h>
|
||||
#include <errno.h>
|
||||
#include <misctool.h>
|
||||
#include "s16debug.h"
|
||||
|
||||
#pragma noroot
|
||||
#pragma optimize 79
|
||||
@ -76,6 +77,9 @@ int mconnect(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5)
|
||||
|
||||
xerrno = queue_command(e, kCommandConnect, 0, timeout);
|
||||
|
||||
s16_debug_printf("mconnect: %d - %d - %d",
|
||||
e->semaphore, xerrno, e->command);
|
||||
|
||||
// hmmm .. should these abort?
|
||||
if (xerrno == EINTR)
|
||||
{
|
||||
@ -98,7 +102,7 @@ int mconnect(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5)
|
||||
// todo -- differentiate ECONNREFUSED vs EHOSTUNREACH
|
||||
return ECONNREFUSED;
|
||||
|
||||
if (timeout && timeout > GetTick())
|
||||
if (timeout && timeout <= GetTick())
|
||||
{
|
||||
IncBusy();
|
||||
TCPIPAbortTCP(e->ipid);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "marignotti.h"
|
||||
#include <gno/kerntool.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <misctool.h>
|
||||
|
||||
#pragma noroot
|
||||
#pragma optimize 79
|
||||
@ -11,11 +11,13 @@ int mdetach(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5)
|
||||
{
|
||||
|
||||
// TODO -- SO_LINGER/SO_LINGER_SEC
|
||||
LongWord timeout;
|
||||
|
||||
timeout = GetTick() + 5 * 60;
|
||||
SEI();
|
||||
e->command = kCommandDisconnectAndLogout;
|
||||
e->cookie = 0;
|
||||
e->timeout = 0;
|
||||
e->timeout = timeout;
|
||||
CLI();
|
||||
|
||||
return 0;
|
||||
|
2
mread.c
2
mread.c
@ -104,7 +104,7 @@ int mread(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (timeout && timeout > GetTick())
|
||||
if (timeout && timeout <= GetTick())
|
||||
return EAGAIN;
|
||||
|
||||
}
|
||||
|
40
table.c
40
table.c
@ -2,6 +2,8 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <misctool.h>
|
||||
#include "s16debug.h"
|
||||
|
||||
|
||||
#pragma optimize 79
|
||||
#pragma noroot
|
||||
@ -109,7 +111,6 @@ void process_table(void)
|
||||
Entry *next;
|
||||
Entry *prev;
|
||||
|
||||
tick = GetTick();
|
||||
|
||||
for (i = 0; i < TABLE_SIZE; ++i)
|
||||
{
|
||||
@ -117,18 +118,21 @@ void process_table(void)
|
||||
e = table[i];
|
||||
while (e)
|
||||
{
|
||||
Word command;
|
||||
next = e->next;
|
||||
|
||||
if (e->command)
|
||||
command = e->command;
|
||||
if (command)
|
||||
{
|
||||
Word expired = 0;
|
||||
Word sig = 0;
|
||||
Word expired;
|
||||
Word sig;
|
||||
Word state;
|
||||
|
||||
tick = GetTick();
|
||||
IncBusy();
|
||||
|
||||
|
||||
if (e->timeout && tick > e->timeout)
|
||||
expired = 0;
|
||||
if (e->timeout != 0 && tick > e->timeout)
|
||||
expired = 1;
|
||||
|
||||
terr = TCPIPStatusTCP(e->ipid, &e->sr);
|
||||
@ -136,9 +140,15 @@ void process_table(void)
|
||||
if (t) terr = t;
|
||||
e->terr = terr;
|
||||
|
||||
state = e->sr.srState;
|
||||
s16_debug_printf("process: %04x : %04x : expired: %d",
|
||||
e->ipid, command, expired);
|
||||
|
||||
s16_debug_srbuff(&e->sr);
|
||||
|
||||
switch(e->command)
|
||||
state = e->sr.srState;
|
||||
sig = 0;
|
||||
|
||||
switch(command)
|
||||
{
|
||||
case kCommandRead:
|
||||
if (e->sr.srRcvQueued >= e->cookie
|
||||
@ -154,6 +164,10 @@ void process_table(void)
|
||||
{
|
||||
sig = 1;
|
||||
}
|
||||
if (expired)
|
||||
{
|
||||
sig = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case kCommandDisconnect:
|
||||
@ -165,7 +179,14 @@ void process_table(void)
|
||||
|
||||
case kCommandDisconnectAndLogout:
|
||||
// logout and remove entry.
|
||||
if (state == TCPSCLOSED)
|
||||
if (expired)
|
||||
{
|
||||
// sweet 16 link layer?
|
||||
TCPIPAbortTCP(e->ipid);
|
||||
state = TCPSCLOSED;
|
||||
}
|
||||
|
||||
if (state == TCPSCLOSED || state == TCPSTIMEWAIT)
|
||||
{
|
||||
TCPIPLogout(e->ipid);
|
||||
sdelete(e->semaphore);
|
||||
@ -186,6 +207,7 @@ void process_table(void)
|
||||
|
||||
if (sig)
|
||||
{
|
||||
s16_debug_printf("sending signal to %d", e->semaphore);
|
||||
e->command = kCommandNone;
|
||||
ssignal(e->semaphore);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user