guile-user
[Top][All Lists]
Advanced

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

Threads in 1.6.4 hanging: caused by accept?


From: Alan Grover
Subject: Threads in 1.6.4 hanging: caused by accept?
Date: Thu, 15 Sep 2005 11:42:32 -0400
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050317)

My attempts at using sockets and threads ends with the threads hanging.
Apparently "accept" blocks all threads (other calls are alleged to do
the same: connect, recv! etc.)

I'm using guile 1.6.4, SuSE 9.2, Linux xxxxxx 2.6.8-24.17-default #1 Tue
Jul 19 08:56:33 UTC 2005 i686 i686 i386 GNU/Linux.

Why would "select" block all threads? I don't see an implication of that
in the man-page.

At the bottom of this message, there is some code to avoid the blocking
by using "select" (suggested by Christopher Cramer). It appears to work
for me. Does it only block the one thread?

What would be the comprehensive list of calls that block all threads?
How do you figure that out?


In my guile version 1.6.4 the *features* has 'threads in it.

This thread example (from Marius Vollmer works):

(use-modules (ice-9 threads))
(use-modules (ice-9 format))

(let ((ts (map (lambda (sym)
        (make-thread
            (lambda ()
                (sleep (random 4))
                (display sym ) (newline))))
        (list 'bob 'sam 'huey 'luey 'duey))))
    (for-each join-thread ts))

I take that as some kind of evidence that threads are in my version of
guile.

After extensive searching, I found bug 1004 (3 years old):
http://savannah.gnu.org/cgi-bin/viewcvs/guile/guile/workbook/bugs/1004-socket-accept-blocks-all-threads?rev=HEAD&content-type=text/vnd.viewcvs-markup

"if you _want_ the accept to block all threads, just call `accept'; if
you don't, call `select' first."

And some sample code from Christopher Cramer to avoid the block:
(define (accept/no-block s)
    "use me in place of accept"
     (let ((fd (list (port->fdes s))))
        (if (null? (car (select fd '() '())))
            (accept/no-block s)
            (accept s))))


-- 
Alan Grover
address@hidden
+1.734.476.0969





reply via email to

[Prev in Thread] Current Thread [Next in Thread]