Branch: Tag:

2010-11-02

2010-11-02 22:12:59 by Marcus Comstedt <marcus@mc.pp.se>

Improved performance of Process.run when threads aren't supported.

Patch taken from githelper: Instead of calling Pike.DefaultBackend() until
p->status() says that the process has terminated, loop until both stdout and
stderr have been closed. This is better because otherwise we may be stuck
inside the backend for up to one second while the process is already
terminated. This change gives a considerable speedup on Solaris.

236:    mystderr->set_read_callback( lambda( mixed i, string data) {    gotstderr += data;    } ); +  mystdout->set_close_callback( lambda () { +  mystdout->set_read_callback(0); +  mystdout = 0; +  }); +  mystderr->set_close_callback( lambda () { +  mystderr->set_read_callback(0); +  mystderr = 0; +  });       if (mystdin) {    Shuffler.Shuffle sf = Shuffler.Shuffler()->shuffle( mystdin );    sf->add_source(stdin_str); -  sf->start(); +  sf->set_done_callback (lambda () {    mystdin = 0; -  +  }); +  sf->start();    }    -  while( !p->status() || p->status() == 1 ) +  while( mystdout || mystderr || mystdin )    Pike.DefaultBackend( 1.0 );    -  mystdout->set_read_callback(0); -  mystderr->set_read_callback(0); -  -  gotstdout += mystdout->read(); -  gotstderr += mystderr->read(); -  +     exitcode = p->wait();   #endif