[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] tcp_select ( was: Re: inet4: errno is not set correct )



Hello,

> Resolving host: google.com ...
> 173.194.37.104
> connect(): Operation now in progress
> C0nnecting...Connect timeout!
> Connect timeout!
> Connect timeout!
> Connect timeout!
> Connect timeout!
> Connect timeout!
> Connect OK!
> recv() failed: Resource temporarily unavailable
> Errno: 11
> 
> Is that what you are expecting ?

Well, thats the same result that I get with my Linux. The error 11 is
also with my system and because it is with the linux OS we houldn't care
about it to much ;) Did you try with MiNT? Here the socket_ready never
returns timeout... it always returns Success. So socket_ready works much
better with linux than with MiNT... but it should take care of the Errno
11 also, but that's another story. You can avoid the error by
usleep(shortvalue).

I'm attaching 2 patches, the tcp patch solves the problem within
inet4.xdd, which is probably not what we want, because the problem is
within sys_f_select, if I understand it correct.

The other patch solves the problem within sys_f_select, which requires
users to get an kernel update to get rid of the error...
But it seems sys_f_select was intended to look like after the patch...
I'm not sure, maybe col_ stands for collision, but it could also stand
for collected ;) 
I did not encounter errors after applying the patch to sys_f_select,
but maybe that doesn't mean anything :)
 
Greets,
m
--- sys/sockets/inet4/tcp.c.orig	Sun Oct 10 22:20:14 2010
+++ sys/sockets/inet4/tcp.c	Mon Oct 11 00:29:54 2010
@@ -29,6 +29,11 @@
 # define SEQ1ST(b)	(TH(b)->seq)
 # define SEQNXT(b)	(SEQ1ST(b) + SEGLEN(b))
 
+# define CONNECTING(tcb) \
+	((tcb)->state == TCBS_SYNSENT || (tcb)->state == TCBS_SYNRCVD)
+# define CONNECTED(tcb) \
+	((tcb)->state == TCBS_ESTABLISHED || (tcb)->state == TCBS_CLOSEWAIT)
+
 
 static long	tcp_attach	(struct in_data *);
 static long	tcp_abort	(struct in_data *, short);
@@ -350,10 +355,16 @@
 			return 0;
 
 		case FIONWRITE:
-			if (data->err || so->flags & SO_CANTSNDMORE)
+			if (data->err || (so->flags & SO_CANTSNDMORE && !CONNECTING(tcb)))
 				space = UNLIMITED;
 			else switch (tcb->state)
 			{
+
+				case TCBS_SYNSENT:
+				case TCBS_SYNRCVD:
+					space = 0;
+					break;
+
 				case TCBS_LISTEN:
 					*(long *)buf = 0;
 					return EINVAL;
@@ -441,11 +452,6 @@
 	DEBUG (("tcp_select: select called with invalid mode"));
 	return 0;
 }
-
-# define CONNECTING(tcb) \
-	((tcb)->state == TCBS_SYNSENT || (tcb)->state == TCBS_SYNRCVD)
-# define CONNECTED(tcb) \
-	((tcb)->state == TCBS_ESTABLISHED || (tcb)->state == TCBS_CLOSEWAIT)
 
 static long
 tcp_send (struct in_data *data, const struct iovec *iov, short niov, short nonblock,
--- sys/dosfile.c.orig	Mon Oct 11 00:22:10 2010
+++ sys/dosfile.c	Mon Oct 11 00:25:34 2010
@@ -900,7 +900,7 @@
 		mask = 1L;
 		for (i = 0; i < p->p_fd->nfiles; i++)
 		{
-			if (rfd & mask)
+			if (col_rfd & mask)
 			{
 				f = p->p_fd->ofiles[i];
 				if (f)
@@ -917,7 +917,7 @@
 				    }
 				}
 			}
-			if (wfd & mask)
+			if (col_wfd & mask)
 			{
 				f = p->p_fd->ofiles[i];
 				if (f)
@@ -934,7 +934,7 @@
 				    }
 				}
 			}
-			if (xfd & mask)
+			if (col_xfd & mask)
 			{
 				f = p->p_fd->ofiles[i];
 				if (f)