You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@whimsical.apache.org by sebb <se...@gmail.com> on 2016/07/08 17:44:58 UTC

Re: [whimsy] branch master updated: Dir.chdir is a no-no in a long running process

On 8 July 2016 at 18:42,  <ru...@apache.org> wrote:
> This is an automated email from the ASF dual-hosted git repository.
>
> rubys pushed a commit to branch master
> in repository https://git-dual.apache.org/repos/asf/whimsy.git
>
> The following commit(s) were added to refs/heads/master by this push:
>        new  6650168   Dir.chdir is a no-no in a long running process
> 6650168 is described below
>
> commit 6650168f4a00f58551dcca800eed5531c25f4269
> Author: Sam Ruby <ru...@intertwingly.net>
> AuthorDate: Fri Jul 8 13:42:01 2016 -0400
>
>     Dir.chdir is a no-no in a long running process

Why is that?
Just curious.

> ---
>  www/board/agenda/views/actions/posted-reports.json.rb | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/www/board/agenda/views/actions/posted-reports.json.rb b/www/board/agenda/views/actions/posted-reports.json.rb
> index bdd6025..5743429 100755
> --- a/www/board/agenda/views/actions/posted-reports.json.rb
> +++ b/www/board/agenda/views/actions/posted-reports.json.rb
> @@ -32,9 +32,8 @@ archive.each do |email|
>  end
>
>  # Get a list of missing board reports
> -Dir.chdir ASF::SVN['private/foundation/board']
> -agenda = Dir['board_agenda_*.txt'].sort.last.untaint
> -parsed = ASF::Board::Agenda.parse(IO.read(agenda), true)
> +agendas = Dir["#{ASF::SVN['private/foundation/board']}/board_agenda_*.txt"]
> +parsed = ASF::Board::Agenda.parse(IO.read(agendas.sort.last.untaint), true)
>  missing = parsed.select {|item| item['missing']}.
>    map {|item| item['title'].downcase}
>
>
> --
> To stop receiving notification emails like this one, please contact
> ['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].

Re: [whimsy] branch master updated: Dir.chdir is a no-no in a long running process

Posted by sebb <se...@gmail.com>.
On 8 July 2016 at 18:49, Sam Ruby <ru...@intertwingly.net> wrote:
> On Fri, Jul 8, 2016 at 1:44 PM, sebb <se...@gmail.com> wrote:
>> On 8 July 2016 at 18:42,  <ru...@apache.org> wrote:
>>> This is an automated email from the ASF dual-hosted git repository.
>>>
>>> rubys pushed a commit to branch master
>>> in repository https://git-dual.apache.org/repos/asf/whimsy.git
>>>
>>> The following commit(s) were added to refs/heads/master by this push:
>>>        new  6650168   Dir.chdir is a no-no in a long running process
>>> 6650168 is described below
>>>
>>> commit 6650168f4a00f58551dcca800eed5531c25f4269
>>> Author: Sam Ruby <ru...@intertwingly.net>
>>> AuthorDate: Fri Jul 8 13:42:01 2016 -0400
>>>
>>>     Dir.chdir is a no-no in a long running process
>>
>> Why is that?
>> Just curious.
>
> If you go to board/agenda before this change deploys you will see.  :-(
>
> Essentially, every process has a single working directory and
> potentially multiple threads.  So changing the working directory can
> break other threads.  Or subsequent requests if the directory isn't
> restored and the process is reused.

OK, so it's not thread-safe/reusable.
That I can understand.

I was confused by the reference to long-running.

> - Sam Ruby
>
>>> ---
>>>  www/board/agenda/views/actions/posted-reports.json.rb | 5 ++---
>>>  1 file changed, 2 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/www/board/agenda/views/actions/posted-reports.json.rb b/www/board/agenda/views/actions/posted-reports.json.rb
>>> index bdd6025..5743429 100755
>>> --- a/www/board/agenda/views/actions/posted-reports.json.rb
>>> +++ b/www/board/agenda/views/actions/posted-reports.json.rb
>>> @@ -32,9 +32,8 @@ archive.each do |email|
>>>  end
>>>
>>>  # Get a list of missing board reports
>>> -Dir.chdir ASF::SVN['private/foundation/board']
>>> -agenda = Dir['board_agenda_*.txt'].sort.last.untaint
>>> -parsed = ASF::Board::Agenda.parse(IO.read(agenda), true)
>>> +agendas = Dir["#{ASF::SVN['private/foundation/board']}/board_agenda_*.txt"]
>>> +parsed = ASF::Board::Agenda.parse(IO.read(agendas.sort.last.untaint), true)
>>>  missing = parsed.select {|item| item['missing']}.
>>>    map {|item| item['title'].downcase}
>>>
>>>
>>> --
>>> To stop receiving notification emails like this one, please contact
>>> ['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].

Re: [whimsy] branch master updated: Dir.chdir is a no-no in a long running process

Posted by Sam Ruby <ru...@intertwingly.net>.
On Fri, Jul 8, 2016 at 1:44 PM, sebb <se...@gmail.com> wrote:
> On 8 July 2016 at 18:42,  <ru...@apache.org> wrote:
>> This is an automated email from the ASF dual-hosted git repository.
>>
>> rubys pushed a commit to branch master
>> in repository https://git-dual.apache.org/repos/asf/whimsy.git
>>
>> The following commit(s) were added to refs/heads/master by this push:
>>        new  6650168   Dir.chdir is a no-no in a long running process
>> 6650168 is described below
>>
>> commit 6650168f4a00f58551dcca800eed5531c25f4269
>> Author: Sam Ruby <ru...@intertwingly.net>
>> AuthorDate: Fri Jul 8 13:42:01 2016 -0400
>>
>>     Dir.chdir is a no-no in a long running process
>
> Why is that?
> Just curious.

If you go to board/agenda before this change deploys you will see.  :-(

Essentially, every process has a single working directory and
potentially multiple threads.  So changing the working directory can
break other threads.  Or subsequent requests if the directory isn't
restored and the process is reused.

- Sam Ruby

>> ---
>>  www/board/agenda/views/actions/posted-reports.json.rb | 5 ++---
>>  1 file changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/www/board/agenda/views/actions/posted-reports.json.rb b/www/board/agenda/views/actions/posted-reports.json.rb
>> index bdd6025..5743429 100755
>> --- a/www/board/agenda/views/actions/posted-reports.json.rb
>> +++ b/www/board/agenda/views/actions/posted-reports.json.rb
>> @@ -32,9 +32,8 @@ archive.each do |email|
>>  end
>>
>>  # Get a list of missing board reports
>> -Dir.chdir ASF::SVN['private/foundation/board']
>> -agenda = Dir['board_agenda_*.txt'].sort.last.untaint
>> -parsed = ASF::Board::Agenda.parse(IO.read(agenda), true)
>> +agendas = Dir["#{ASF::SVN['private/foundation/board']}/board_agenda_*.txt"]
>> +parsed = ASF::Board::Agenda.parse(IO.read(agendas.sort.last.untaint), true)
>>  missing = parsed.select {|item| item['missing']}.
>>    map {|item| item['title'].downcase}
>>
>>
>> --
>> To stop receiving notification emails like this one, please contact
>> ['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].