[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] tcp-abandon-port abandoned (current CVS)
From: |
Felix Winkelmann |
Subject: |
Re: [Chicken-users] tcp-abandon-port abandoned (current CVS) |
Date: |
Wed, 05 Mar 2003 10:15:20 +0100 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.0) Gecko/20020530 |
Sven Hartrumpf wrote:
Hi all.
I run into a problem when a client closes a (socket-)port (with
close-output-port)
faster than the server can read from this (socker-)port using tcp.scm-sockets.
(If I delay the client before close-output-port everything works fine; but
delaying is not a real option for me.)
If I understand the PLT documentation correctly, tcp-abandon-port is
intended for such cases (instead of close-output-port).
But tcp.scm is missing tcp-abandon-port ... :-(
What could I do?
From peeking at the PLT sources, `tcp-abandon-port' simply
marks the port so that a subsequent closing will not
call `shutdown()'. Find attached a diff that implements
tcp-abandon-port.
Wether this is really the root of your problem I can't say.
cheers,
felix
cvs diff tcp.scm
Index: tcp.scm
===================================================================
RCS file: /cvsroot/chicken/chicken/tcp.scm,v
retrieving revision 1.1
diff -r1.1 tcp.scm
42c42,43
< (export tcp-close tcp-listen tcp-connect tcp-accept tcp-accept-ready?
##sys#tcp-port->fileno tcp-listener? tcp-addresses)
---
> (export tcp-close tcp-listen tcp-connect tcp-accept tcp-accept-ready?
> ##sys#tcp-port->fileno tcp-listener? tcp-addresses
> tcp-abandon-port)
255a257
> [data (vector fd #f #f)]
287c289
< (##net#shutdown fd _sd_receive)
---
> (unless (##sys#slot data 1) (##net#shutdown fd _sd_receive))
307c309
< (##net#shutdown fd _sd_send)
---
> (unless (##sys#slot data 2) (##net#shutdown fd _sd_send))
311,312c313,314
< (##sys#setislot (##sys#port-data in) 0 fd)
< (##sys#setislot (##sys#port-data out) 0 fd)
---
> (##sys#setslot (##sys#port-data in) 0 data)
> (##sys#setslot (##sys#port-data out) 0 data)
358,362c360
< (##sys#check-port p)
< (let ([d (##sys#port-data p)])
< (if d
< (##sys#slot d 0)
< (##sys#signal-hook #:type-error "bad argument type - not a TCP port" p)
) ) )
---
> (##sys#slot (##sys#tcp-port-data p) 0) )
370a369,381
>
> (define (##sys#tcp-port-data p)
> (##sys#check-port p)
> (let ([d (##sys#port-data p)])
> (if d
> (##sys#slot d 0)
> (##sys#signal-hook #:type-error "bad argument type - not a TCP port" p)
> ) ) )
>
> (define (tcp-abandon-port p)
> (##sys#setislot
> (##sys#tcp-port-data p)
> (if (##sys#slot p 1) 2 1)
> #t) )