From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Robert Marlow Newsgroups: gmane.lisp.guile.user Subject: Re: Problems with Select + threads + pipes Date: 05 Aug 2003 21:51:28 +0800 Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Message-ID: <1060091490.555.6.camel@zuul> References: <1060056938.25787.29.camel@helicon> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-g/qWkDLG/rchvo+ffN5v" X-Trace: main.gmane.org 1060093337 15525 80.91.224.253 (5 Aug 2003 14:22:17 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 5 Aug 2003 14:22:17 +0000 (UTC) Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Aug 05 16:22:35 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19k2hu-0001YO-00 for ; Tue, 05 Aug 2003 16:22:34 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19k2aa-0003al-P5 for guile-user@m.gmane.org; Tue, 05 Aug 2003 10:15:00 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19k2a1-0003YC-FE for guile-user@gnu.org; Tue, 05 Aug 2003 10:14:25 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19k2ZS-0003Lv-0M for guile-user@gnu.org; Tue, 05 Aug 2003 10:14:22 -0400 Original-Received: from [202.89.173.175] (helo=keymaster.bobturf.com.au) by monty-python.gnu.org with esmtp (Exim 4.20) id 19k2Du-00046V-B4 for guile-user@gnu.org; Tue, 05 Aug 2003 09:51:34 -0400 Original-Received: from localhost.localdomain (bobstopper@zuul.bobturf.com.au [192.168.153.69]) by keymaster.bobturf.com.au (8.12.3/8.12.3/Debian-6.3) with ESMTP id h75DpTWG000931 for ; Tue, 5 Aug 2003 21:51:31 +0800 Original-To: guile-user@gnu.org In-Reply-To: <1060056938.25787.29.camel@helicon> X-Mailer: Ximian Evolution 1.0.5 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.user:2149 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:2149 --=-g/qWkDLG/rchvo+ffN5v Content-Type: text/plain Content-Transfer-Encoding: 7bit Ok, this time it gives the error. I just needed to start more threads. If anyone can point out the cause of this bug I'd be very appreciative. Just chuck the buggy.scm and buggy-companion.scm in the same directory, run the former and start dumping stuff on port 6008. Multiple connection attempts may be needed to see it happen. Error message should look something like: ERROR: In procedure select: ERROR: Bad file descriptor Thanks! -- Regards, Robert Marlow --=-g/qWkDLG/rchvo+ffN5v Content-Disposition: attachment; filename=buggy.scm Content-Transfer-Encoding: quoted-printable Content-Type: text/x-scheme; name=buggy.scm; charset=ANSI_X3.4-1968 #!/usr/bin/guile \ -e main -s !# (use-modules (ice-9 threads) (ice-9 popen)) (define mutex (make-mutex)) (define message-ready (make-condition-variable)) (define message "") (define (main args) (begin-thread (thread)) (begin-thread (thread)) (begin-thread (thread)) (begin-thread (thread)) (begin-thread (thread)) (let ((sock #f) (fileno #f)) (lock-mutex mutex) (set! sock (socket AF_INET SOCK_STREAM 0)) (unlock-mutex mutex) (bind sock AF_INET INADDR_ANY 6008) (listen sock 5) (while #t (let* ((client-connection (accept/no-block sock)) (client-details (cdr client-connection)) (client (car client-connection))) (lock-mutex mutex) (do ((line (read-line client) (read-line client))) ((eof-object? line) (shutdown client 2)) (set! message (string-append message line "\n"))) (signal-condition-variable message-ready) (unlock-mutex mutex))))) (define (thread) (while #t =20 (lock-mutex mutex) (if (not (> (string-length message) 0)) (wait-condition-variable message-ready mutex) (let ((outgoing message)) (set! message "") (unlock-mutex mutex) (piper outgoing))) (unlock-mutex mutex))) (define (piper message) (lock-mutex mutex) (let ((pipe (open-output-pipe "./buggy-companion.scm"))) (display message pipe) (close-port pipe)) (unlock-mutex mutex)) =20 (define (accept/no-block s) (if (null? (car (select (vector s) '() '()))) ; This select complains (accept/no-block s) (let ((client #f)) (lock-mutex mutex) (set! client (accept s)) (unlock-mutex mutex) client))) --=-g/qWkDLG/rchvo+ffN5v Content-Disposition: attachment; filename=buggy-companion.scm Content-Transfer-Encoding: quoted-printable Content-Type: text/x-scheme; name=buggy-companion.scm; charset=ANSI_X3.4-1968 #!/usr/bin/guile \ -e main -s !# (define (main args) (let ((str "")) (do ((line (read-line) (read-line))) ((eof-object? line)) (set! str (string-append str line "\n"))) (sleep 10) (display str))) --=-g/qWkDLG/rchvo+ffN5v Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user --=-g/qWkDLG/rchvo+ffN5v--