Re: wip-threads-and-fork

2013-01-17 Thread Andy Wingo
Hi, On Wed 21 Mar 2012 22:26, l...@gnu.org (Ludovic Courtès) writes: > What about adding a big fat warning in the doc about use of > ‘primitive-fork’ in a multi-threaded program? > Andy Wingo skribis: > >> If other threads are active, I think primitive-fork should raise an >> e

Re: wip-threads-and-fork

2012-04-07 Thread Ludovic Courtès
Hey! Andy Wingo skribis: > On Tue 27 Mar 2012 08:54, l...@gnu.org (Ludovic Courtès) writes: > >> Andy Wingo skribis: >> >>> On Wed 21 Mar 2012 22:26, l...@gnu.org (Ludovic Courtès) writes: >>> What about adding a big fat warning in the doc about use of ‘primitive-fork’ in a multi-thre

Re: wip-threads-and-fork

2012-04-06 Thread Andy Wingo
Heya :) An ongoing discussion... On Tue 27 Mar 2012 08:54, l...@gnu.org (Ludovic Courtès) writes: > Andy Wingo skribis: > >> On Wed 21 Mar 2012 22:26, l...@gnu.org (Ludovic Courtès) writes: >> >>> What about adding a big fat warning in the doc about use of >>> ‘primitive-fork’ in a multi-thread

Re: wip-threads-and-fork

2012-03-27 Thread Ludovic Courtès
Hi, Andy Wingo skribis: > On Wed 21 Mar 2012 22:26, l...@gnu.org (Ludovic Courtès) writes: [...] >> Yes, things like ‘open-process’ make sense. >> >> What about adding a big fat warning in the doc about use of >> ‘primitive-fork’ in a multi-threaded program? > > Sure. WDYT about a warning at

Re: wip-threads-and-fork

2012-03-23 Thread Andy Wingo
Hi :) On Wed 21 Mar 2012 22:26, l...@gnu.org (Ludovic Courtès) writes: > Without exposing ‘pthread_atfork’, how would you suggest making user > code “fork-safe”? A use case would be reviving the futures thread pool > after ‘fork’. Humm, just tried to think about it for 10 minutes or so and I'm

Re: wip-threads-and-fork

2012-03-21 Thread Nala Ginrut
you suggest making user > code “fork-safe”? A use case would be reviving the futures thread pool > after ‘fork’. > > > Did you see that I merged the atfork bits into master? > > (wip-threads-and-fork also had some CLOEXEC bits that needed more > > baking). They worked..

Re: wip-threads-and-fork

2012-03-21 Thread Ludovic Courtès
‘fork’. > Did you see that I merged the atfork bits into master? > (wip-threads-and-fork also had some CLOEXEC bits that needed more > baking). They worked... sorta. They had a few problems: > > 1) It's impossible to work around the lack of atfork() in libraries > tha

Re: wip-threads-and-fork

2012-03-04 Thread Andy Wingo
On Sat 03 Mar 2012 22:20, l...@gnu.org (Ludovic Courtès) writes: > I’d prefer a solution where libguile-internal threads and locks are > suitably handled upon fork (basically what wip-threads-and-fork does), > and where users are provided with mechanisms to do the same at their >

Re: wip-threads-and-fork

2012-03-03 Thread Ludovic Courtès
Hey! Andy Wingo skribis: > How do you feel about raising an error if primitive-fork is called, and > there are other threads running? I think I’d prefer a solution where libguile-internal threads and locks are suitably handled upon fork (basically what wip-threads-and-fork does), and

Re: wip-threads-and-fork

2012-03-03 Thread Andy Wingo
Hello :) On Thu 01 Mar 2012 20:35, l...@gnu.org (Ludovic Courtès) writes: > I still think that saying that “a guile built with threads […] should > not call primitive-fork” is too strong, because again, it’s very, very > unlikely to fail when (= 1 (length (all-threads))), GNU/Linux or not. OK, a

Re: wip-threads-and-fork

2012-03-01 Thread Ludovic Courtès
Hi, Andy Wingo skribis: > On Sun 26 Feb 2012 23:03, l...@gnu.org (Ludovic Courtès) writes: > >> Andy Wingo skribis: >> >>> + if (scm_ilength (scm_all_threads ()) != 1) >>> +/* Other threads may be holding on to resources that Guile needs -- >>> + it is not safe to permit

Re: wip-threads-and-fork

2012-03-01 Thread Ludovic Courtès
y unlikely to fail when (= 1 (length (all-threads))), GNU/Linux or not. Let’s not scare our users more than necessary. ;-) And perhaps it can be fixed in 2.0 based on what ‘wip-threads-and-fork’ provides, as discussed in another message. Thanks, Ludo’.

Re: wip-threads-and-fork

2012-03-01 Thread Ludovic Courtès
Hi! Andy Wingo skribis: > The solution is, besides just avoiding fork() and threads, to take locks > on all interesting data structures when you fork(). Fortunately there > are not too many, and most locks are not nested, so it seems to be a > doable thing. In wip-threads-and-for

Re: wip-threads-and-fork

2012-02-27 Thread Andy Wingo
On Sun 26 Feb 2012 23:03, l...@gnu.org (Ludovic Courtès) writes: > Andy Wingo skribis: > >> + if (scm_ilength (scm_all_threads ()) != 1) >> +/* Other threads may be holding on to resources that Guile needs -- >> + it is not safe to permit one thread to fork while others are

Re: wip-threads-and-fork

2012-02-27 Thread Andy Wingo
Hi, On Sun 26 Feb 2012 23:00, l...@gnu.org (Ludovic Courtès) writes: >> A guile built without >> threads may fork to its heart's content. However a guile built with >> threads -- the default, recommended configuration -- should not call >> primitive-fork. > > That’s a strong statement. Don't sh

Re: wip-threads-and-fork

2012-02-26 Thread Ludovic Courtès
Hi, Andy Wingo skribis: > + if (scm_ilength (scm_all_threads ()) != 1) > +/* Other threads may be holding on to resources that Guile needs -- > + it is not safe to permit one thread to fork while others are > + running. > + > + In addition, POSIX cl

Re: wip-threads-and-fork

2012-02-26 Thread Ludovic Courtès
Hi, Andy Wingo skribis: > A guile built without > threads may fork to its heart's content. However a guile built with > threads -- the default, recommended configuration -- should not call > primitive-fork. That’s a strong statement. When the only threads are the main thread and the signal th

Re: wip-threads-and-fork

2012-02-25 Thread Nala Ginrut
On Sun, Feb 26, 2012 at 2:01 AM, Andy Wingo wrote: > Hi! > > On Sat 25 Feb 2012 03:30, Nala Ginrut writes: > > > 'primitive-fork' shouldn't be removed directly according to > > previous discussion, unless the user chosen ptheads. If they do not > > use threads, then primitive-fork would be usefu

Re: wip-threads-and-fork

2012-02-25 Thread Andy Wingo
Hi! On Sat 25 Feb 2012 03:30, Nala Ginrut writes: > 'primitive-fork' shouldn't be removed directly according to > previous discussion, unless the user chosen ptheads. If they do not > use threads, then primitive-fork would be useful, is that right?   Indeed. In Guile master, primitive-fork is

Re: wip-threads-and-fork

2012-02-24 Thread Nala Ginrut
On Sat, Feb 25, 2012 at 10:21 AM, Nala Ginrut wrote: > > > On Sat, Feb 25, 2012 at 2:57 AM, Andy Wingo wrote: > >> Hello :) >> >> On Fri 24 Feb 2012 04:00, Nala Ginrut writes: >> >> > I think I could use pipes to handle some sub-process rather than do it >> > with fork manually. But I must crea

Re: wip-threads-and-fork

2012-02-24 Thread Nala Ginrut
On Sat, Feb 25, 2012 at 2:57 AM, Andy Wingo wrote: > Hello :) > > On Fri 24 Feb 2012 04:00, Nala Ginrut writes: > > > I think I could use pipes to handle some sub-process rather than do it > > with fork manually. But I must create a daemon, it can't avoid to use > > fork, will this circumstance

Re: wip-threads-and-fork

2012-02-24 Thread Andy Wingo
Hello :) On Fri 24 Feb 2012 04:00, Nala Ginrut writes: > I think I could use pipes to handle some sub-process rather than do it > with fork manually. But I must create a daemon, it can't avoid to use > fork, will this circumstance cause problems if I use threads after it? Hummm. Very good ques

Re: wip-threads-and-fork

2012-02-24 Thread Nala Ginrut
On Fri, Feb 24, 2012 at 10:47 PM, Andy Wingo wrote: > Hi, > > Thanks for the feedback :) > > On Fri 24 Feb 2012 15:08, Nala Ginrut writes: > > > Considering the new 'open-process' hasn't been done, the issues left > > suspending. > > Maybe I have not expressed myself well. To be clear, the new

Re: wip-threads-and-fork

2012-02-24 Thread Andy Wingo
Hi, Thanks for the feedback :) On Fri 24 Feb 2012 15:08, Nala Ginrut writes: > Considering the new 'open-process' hasn't been done, the issues left > suspending. Maybe I have not expressed myself well. To be clear, the new open-process implementation is now in both master and 2.0, though not

Re: wip-threads-and-fork

2012-02-24 Thread Nala Ginrut
On Fri, Feb 24, 2012 at 6:21 PM, Andy Wingo wrote: > On Fri 24 Feb 2012 04:00, Nala Ginrut writes: > > > I think I could use pipes to handle some sub-process rather than do it > > with fork manually. But I must create a daemon, it can't avoid to use > > fork, will this circumstance cause problem

Re: wip-threads-and-fork

2012-02-24 Thread Andy Wingo
On Fri 24 Feb 2012 04:00, Nala Ginrut writes: > I think I could use pipes to handle some sub-process rather than do it > with fork manually. But I must create a daemon, it can't avoid to use > fork, will this circumstance cause problems if I use threads after it? I just pushed a patch like this:

Re: wip-threads-and-fork

2012-02-23 Thread Nala Ginrut
On Fri, Feb 24, 2012 at 12:13 AM, Andy Wingo wrote: > On Thu 23 Feb 2012 16:49, Nala Ginrut writes: > > > I just want to do my negative vote when I saw "choose thead then fork > > die", but I see "open-process" soon. ;-) So, what's the difference > > between "primitive-fork" and "open-process"?

Re: wip-threads-and-fork

2012-02-23 Thread Andy Wingo
On Thu 23 Feb 2012 16:49, Nala Ginrut writes: > I just want to do my negative vote when I saw "choose thead then fork > die", but I see "open-process" soon. ;-)  So, what's the difference > between "primitive-fork" and "open-process"? If they're different, I > think much code to be modified for m

Re: wip-threads-and-fork

2012-02-23 Thread Nala Ginrut
On Thu, Feb 23, 2012 at 11:05 PM, Andy Wingo wrote: > On Wed 22 Feb 2012 22:40, Andy Wingo writes: > > > Obviously we can treat the limited case of (ice-9 popen) in a more > > portable fashion. > > I have now rewritten open-process from ice-9 popen in C, so as to be > sure that only async-signal

Re: wip-threads-and-fork

2012-02-23 Thread Andy Wingo
On Wed 22 Feb 2012 22:40, Andy Wingo writes: > Obviously we can treat the limited case of (ice-9 popen) in a more > portable fashion. I have now rewritten open-process from ice-9 popen in C, so as to be sure that only async-signal-safe routines get called. This should make ice-9 popen work reli

Re: wip-threads-and-fork

2012-02-22 Thread Andy Wingo
Hi all, An update on this issue. For context: On Wed 08 Feb 2012 23:10, Andy Wingo writes: > I was testing out the threaded web server and it was working well. Then > I tried it out with tekuti, a blog engine that uses git as the backend. > It uses (ice-9 popen) to talk to the git binaries.

wip-threads-and-fork

2012-02-08 Thread Andy Wingo
fork() and threads, to take locks on all interesting data structures when you fork(). Fortunately there are not too many, and most locks are not nested, so it seems to be a doable thing. In wip-threads-and-fork, I added a scm_c_atfork interface to define functions to call before and after a fork