delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/2003/02/20/12:47:37

Mailing-List: contact cygwin-developers-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-developers-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin-developers/>
List-Post: <mailto:cygwin-developers AT cygwin DOT com>
List-Help: <mailto:cygwin-developers-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-developers-owner AT cygwin DOT com
Delivered-To: mailing list cygwin-developers AT cygwin DOT com
Date: Thu, 20 Feb 2003 12:55:17 -0500
From: Jason Tishler <jason AT tishler DOT net>
Subject: Re: Threaded socket hang in 1.3.20
In-reply-to: <20030220141539.GE2467@cygbert.vinschen.de>
To: Cygwin-Developers <cygwin-developers AT cygwin DOT com>
Mail-followup-to: Cygwin-Developers <cygwin-developers AT cygwin DOT com>
Message-id: <20030220175517.GA2768@tishler.net>
MIME-version: 1.0
User-Agent: Mutt/1.4i
References: <20030218222746 DOT GD2404 AT tishler DOT net>
<20030220141539 DOT GE2467 AT cygbert DOT vinschen DOT de>

--Boundary_(ID_p84Aqhs0zhYmlcDwDHa5cQ)
Content-type: text/plain; charset=us-ascii
Content-transfer-encoding: 7BIT
Content-disposition: inline

Corinna,

On Thu, Feb 20, 2003 at 03:15:39PM +0100, Corinna Vinschen wrote:
> I looked into this problem

Thanks for your help -- it is much appreciated.

> and it turns out to be a non-socket specific problem but instead a
> deadlock problem in cygheap:
> 
> [snip]
> 
>   cygheap_fdnew (int seed_fd = -1, bool lockit = true)
>     {
>       if (lockit)
> 	SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "cygheap_fdnew");

I came to the above conclusion yesterday, but did not have a chance to
report back to the list.

> [snip]
> I've cleaned that up a bit and commited the changes.

Thanks!  The two Python regression tests no longer hang with the latest
CVS.

> Now back to the test case.  With these changes the socket() call doesn't
> hang but now connect() is in trouble.  It hangs for a while until it
> returns with error 116, Connection timeout.

I just tried the test case again and it still fails with 111.  FWIW, I
happened to notice that the test case fails with 116 on 1.3.17 (on my
home PC).

YA FWIW, see attached.  I know that you do read Python, but this code
shows that connect() works with threads in at least one situation.
Maybe there is a bug in my test case?  Note that I'm only lightly versed
in sockets -- just enough to be dangerous.

> I must admit, that I didn't find the cause so far.  Help in debugging
> this is appreciated.

I will try to poke around some more.

Thanks,
Jason

-- 
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6

--Boundary_(ID_p84Aqhs0zhYmlcDwDHa5cQ)
Content-type: text/plain; charset=us-ascii; NAME=test_asynchat.py
Content-transfer-encoding: 7BIT
Content-disposition: attachment; filename=test_asynchat.py

# test asynchat -- requires threading

import thread # If this fails, we can't test this module
import asyncore, asynchat, socket, threading, time

HOST = "127.0.0.1"
PORT = 54321

class echo_server(threading.Thread):

    def run(self):
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        sock.bind((HOST, PORT))
        sock.listen(1)
        conn, client = sock.accept()
        buffer = ""
        while "\n" not in buffer:
            data = conn.recv(10)
            if not data:
                break
            buffer = buffer + data
        while buffer:
            n = conn.send(buffer)
            buffer = buffer[n:]
        conn.close()
        sock.close()

class echo_client(asynchat.async_chat):

    def __init__(self):
        asynchat.async_chat.__init__(self)
        self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
        self.connect((HOST, PORT))
        self.set_terminator("\n")
        self.buffer = ""

    def handle_connect(self):
        print "Connected"

    def collect_incoming_data(self, data):
        self.buffer = self.buffer + data

    def found_terminator(self):
        print "Received:", `self.buffer`
        self.buffer = ""
        self.close()

def main():
    s = echo_server()
    s.start()
    time.sleep(1) # Give server time to initialize
    c = echo_client()
    c.push("hello ")
    c.push("world\n")
    asyncore.loop()

main()

--Boundary_(ID_p84Aqhs0zhYmlcDwDHa5cQ)--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019