* Threads in 1.6.4 hanging: caused by accept?
@ 2005-09-15 15:42 Alan Grover
2005-09-16 0:25 ` Kevin Ryde
0 siblings, 1 reply; 2+ messages in thread
From: Alan Grover @ 2005-09-15 15:42 UTC (permalink / raw)
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
awgrover@mail.msen.com
+1.734.476.0969
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Threads in 1.6.4 hanging: caused by accept?
2005-09-15 15:42 Threads in 1.6.4 hanging: caused by accept? Alan Grover
@ 2005-09-16 0:25 ` Kevin Ryde
0 siblings, 0 replies; 2+ messages in thread
From: Kevin Ryde @ 2005-09-16 0:25 UTC (permalink / raw)
Alan Grover <awgrover@mail.msen.com> writes:
>
> What would be the comprehensive list of calls that block all threads?
> How do you figure that out?
`gethost' is a bad one, it disappears deep into libc so select or
whatever doesn't help. I ended up forking a subprocess to make the
call. Or I guess there's a few asynch dns libraries too, until the
posix threads in 1.8 avoid the problem.
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-09-16 0:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-15 15:42 Threads in 1.6.4 hanging: caused by accept? Alan Grover
2005-09-16 0:25 ` Kevin Ryde
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).