Skip to content
This repository

Workaround for morbo (MSWin + threads related) #384

Closed
wants to merge 1 commit into from

3 participants

kmx Sebastian Riedel Marcus Ramberg
kmx

Hi,

I was investigating why morbo's autoreloading feature is crashing on MS Windows.

It turns out that there are 2 pieces used by Mojo that do not play well with threads (you probably know that fork() which is used by morbo is emulated via threads on MS Windows).

1/ Mojo::Reactor::EV seems to have troubles when used with perl's threads

2/ IO::Socket::SSL is basically thread safe providing that it is loaded in the main thread - I have created an RT for this issue https://rt.cpan.org/Public/Bug/Display.html?id=79685

The patch in this pull request tries to deal with those 2 issues.

I know that it is a hack and that proper fix should be made in other modules outside Mojo. On the other hand providing that morbo is "only" development server I hope you will not reject it.

kmx

Sebastian Riedel
Owner

-1 from me, historically all Windows specific behavior has always turned out to be a total nightmare to maintain for us. This should really be fixed in EV and IO::Socket::SSL. Windows users who have those modules installed can already use the MOJO_NO_TLS=1 and MOJO_REACTOR=Mojo::Reactor::Poll environment variables as a workaround.

Marcus Ramberg
Collaborator
Sebastian Riedel kraih closed this
Sebastian Riedel
Owner

For future reference, we've discussed this a bit further on IRC, and it turns out that only EV is currently not thread-safe. So Windows users who have EV installed and want to use Morbo, only need to set the MOJO_REACTOR=Mojo::Reactor::Poll environment variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Sep 17, 2012
workaround for avoiding morbo crashes on MS Windows 1aa37fc
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 7 additions and 0 deletions. Show diff stats Hide diff stats

  1. 7  script/morbo
7  script/morbo
@@ -37,6 +37,13 @@ These options are available:
37 37
                                  working directory.
38 38
 EOF
39 39
 
  40
+if ($^O eq 'MSWin32') {
  41
+  # morbo uses fork() which is on MS Windows emulated via threads
  42
+  # however some pieces used by Mojo are not completely thread-safe
  43
+  $ENV{MOJO_REACTOR} = 'Mojo::Reactor::Poll'; # avoid using Mojo::Reactor::EV
  44
+  $ENV{MOJO_NO_TLS} or require IO::Socket::SSL; # workaround for RT #79685
  45
+}
  46
+
40 47
 $ENV{MOJO_LISTEN} = join(',', @listen) if @listen;
41 48
 require Mojo::Server::Morbo;
42 49
 my $morbo = Mojo::Server::Morbo->new;
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.