Re: [9fans] Doesn't 'close' call finish pending 'read' on the same 'fd'?

2014-11-13 Thread Pavel Klinkovský
Hi cinap, hangup(cfd);/* hangup connection, fd stays valid but i/o will error */ thank you for your explanation and help. Going to use 'hangup' function. ;) Pavel

Re: [9fans] Doesn't 'close' call finish pending 'read' on the same 'fd'?

2014-11-13 Thread cinap_lenrek
another way to implement these kinds of timeouts is alarm(), see sleep(2). -- cinap

Re: [9fans] Doesn't 'close' call finish pending 'read' on the same 'fd'?

2014-11-13 Thread Pavel Klinkovský
another way to implement these kinds of timeouts is alarm(), see sleep(2). Yes, I know. But it was just a simplified example to explain my real need: - 'receiver' process - another 'sender' process, which should have a possibility to close the TCP connection, and relase 'receiver' from read()

Re: [9fans] Doesn't 'close' call finish pending 'read' on the same 'fd'?

2014-11-13 Thread cinap_lenrek
ah, ok :) -- cinap

Re: [9fans] Doesn't 'close' call finish pending 'read' on the same 'fd'?

2014-11-13 Thread Pavel Klinkovský
OTOH, 'hangup' approach does not work in UDP. It means, read() is not finished... :( Pavel 2014-11-13 14:17 GMT+01:00 cinap_len...@felloff.net: ah, ok :) -- cinap

Re: [9fans] Doesn't 'close' call finish pending 'read' on the same 'fd'?

2014-11-13 Thread cinap_lenrek
interesting, that might be worth implementing. the alternative would be to send the reading process a note to interrupt the blocking syscall. the closer proc should just send the note and not close the fd. and the reader proc should close the fd once he's out of the reading loop. -- cinap

Re: [9fans] Doesn't 'close' call finish pending 'read' on the same 'fd'?

2014-11-13 Thread Pavel Klinkovský
interesting, that might be worth implementing. Maybe. the alternative would be to send the reading process a note to interrupt the blocking syscall. Actually, it my 'plan B'... ;) the closer proc should just send the note and not close the fd. and the reader proc should close the fd

Re: [9fans] Doesn't 'close' call finish pending 'read' on the same 'fd'?

2014-11-13 Thread cinap_lenrek
the changes to implement udp hangup are trivial tho: diff -r 51564dc1adae sys/src/9/ip/udp.c --- a/sys/src/9/ip/udp.cThu Nov 13 10:23:53 2014 +0100 +++ b/sys/src/9/ip/udp.cThu Nov 13 15:42:24 2014 +0100 @@ -518,6 +518,11 @@ ucb = (Udpcb*)c-ptcl; if(n == 1){ +

Re: [9fans] Doesn't 'close' call finish pending 'read' on the same 'fd'?

2014-11-13 Thread Pavel Klinkovský
the changes to implement udp hangup are trivial tho: diff -r 51564dc1adae sys/src/9/ip/udp.c --- a/sys/src/9/ip/udp.cThu Nov 13 10:23:53 2014 +0100 +++ b/sys/src/9/ip/udp.cThu Nov 13 15:42:24 2014 +0100 @@ -518,6 +518,11 @@ ucb = (Udpcb*)c-ptcl; if(n == 1){

Re: [9fans] Doesn't 'close' call finish pending 'read' on the same 'fd'?

2014-11-13 Thread Pavel Klinkovský
+ if(strcmp(f[0], hangup) == 0){ + qhangup(c-rq, nil); + qhangup(c-wq, nil); + return nil; + } You patch works as expected. ;) Thanks. Pavel