diff options
author | Alan M Webb | 2009-09-21 08:42:01 -0400 |
---|---|---|
committer | dr scofield (aka dirk husemann) | 2009-09-23 14:49:34 +0200 |
commit | b7265abfaeb256ebc8421ee1d647dd68f08ff77a (patch) | |
tree | 203454dbad34c0c65bdc04b40f4a2451ba2e244b /OpenSim/Region | |
parent | * Makes SimulatorEnable messages 'reliable' and subject to redelivery. (diff) | |
download | opensim-SC_OLD-b7265abfaeb256ebc8421ee1d647dd68f08ff77a.zip opensim-SC_OLD-b7265abfaeb256ebc8421ee1d647dd68f08ff77a.tar.gz opensim-SC_OLD-b7265abfaeb256ebc8421ee1d647dd68f08ff77a.tar.bz2 opensim-SC_OLD-b7265abfaeb256ebc8421ee1d647dd68f08ff77a.tar.xz |
Added delay loop to give a newly created assembly time to appear. On
Linux (as an example), it is possible for the existence check to fail
because the file is not yet recognized by the file system. Although
the loop has a 250mS delay, in practise, the existence test in the for
loop is successful and no delay is introduced.
Next, this takes care of the two, unpredictable, situations where a
script fails to compile. The first is caused by an occasional SEGV in
the underlying mono VM while mcs is running, the second is caused by
file system latency.
Signed-off-by: dr scofield (aka dirk husemann) <drscofield@xyzzyxyzzy.net>
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | 103 |
1 files changed, 71 insertions, 32 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs index cb5664b..5a94957 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | |||
@@ -542,11 +542,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
542 | break; | 542 | break; |
543 | case enumCompileType.cs: | 543 | case enumCompileType.cs: |
544 | case enumCompileType.lsl: | 544 | case enumCompileType.lsl: |
545 | lock (CScodeProvider) | 545 | bool complete = false; |
546 | bool retried = false; | ||
547 | do | ||
546 | { | 548 | { |
547 | results = CScodeProvider.CompileAssemblyFromSource( | 549 | lock (CScodeProvider) |
548 | parameters, Script); | 550 | { |
551 | results = CScodeProvider.CompileAssemblyFromSource( | ||
552 | parameters, Script); | ||
553 | } | ||
554 | // Deal with an occasional segv in the compiler. | ||
555 | // Rarely, if ever, occurs twice in succession. | ||
556 | // Line # == 0 and no file name are indications that | ||
557 | // this is a native stack trace rather than a normal | ||
558 | // error log. | ||
559 | if (results.Errors.Count > 0) | ||
560 | { | ||
561 | if (!retried && (results.Errors[0].FileName == null || results.Errors[0].FileName == String.Empty) && | ||
562 | results.Errors[0].Line == 0) | ||
563 | { | ||
564 | // System.Console.WriteLine("retrying failed compilation"); | ||
565 | retried = true; | ||
566 | } | ||
567 | else | ||
568 | { | ||
569 | complete = true; | ||
570 | } | ||
571 | } | ||
572 | else | ||
573 | { | ||
574 | complete = true; | ||
575 | } | ||
549 | } | 576 | } |
577 | while(!complete); | ||
550 | break; | 578 | break; |
551 | case enumCompileType.js: | 579 | case enumCompileType.js: |
552 | results = JScodeProvider.CompileAssemblyFromSource( | 580 | results = JScodeProvider.CompileAssemblyFromSource( |
@@ -567,17 +595,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
567 | // | 595 | // |
568 | // WARNINGS AND ERRORS | 596 | // WARNINGS AND ERRORS |
569 | // | 597 | // |
570 | int display = 5; | 598 | bool hadErrors = false; |
599 | string errtext = String.Empty; | ||
600 | |||
571 | if (results.Errors.Count > 0) | 601 | if (results.Errors.Count > 0) |
572 | { | 602 | { |
573 | string errtext = String.Empty; | ||
574 | foreach (CompilerError CompErr in results.Errors) | 603 | foreach (CompilerError CompErr in results.Errors) |
575 | { | 604 | { |
576 | // Show 5 errors max | ||
577 | // | ||
578 | if (display <= 0) | ||
579 | break; | ||
580 | display--; | ||
581 | 605 | ||
582 | string severity = "Error"; | 606 | string severity = "Error"; |
583 | if (CompErr.IsWarning) | 607 | if (CompErr.IsWarning) |
@@ -587,36 +611,51 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
587 | 611 | ||
588 | KeyValuePair<int, int> lslPos; | 612 | KeyValuePair<int, int> lslPos; |
589 | 613 | ||
590 | lslPos = FindErrorPosition(CompErr.Line, CompErr.Column); | 614 | // Show 5 errors max, but check entire list for errors |
615 | |||
616 | if (severity == "Error") | ||
617 | { | ||
618 | lslPos = FindErrorPosition(CompErr.Line, CompErr.Column); | ||
619 | string text = CompErr.ErrorText; | ||
620 | |||
621 | // Use LSL type names | ||
622 | if (lang == enumCompileType.lsl) | ||
623 | text = ReplaceTypes(CompErr.ErrorText); | ||
624 | |||
625 | // The Second Life viewer's script editor begins | ||
626 | // countingn lines and columns at 0, so we subtract 1. | ||
627 | errtext += String.Format("Line ({0},{1}): {4} {2}: {3}\n", | ||
628 | lslPos.Key - 1, lslPos.Value - 1, | ||
629 | CompErr.ErrorNumber, text, severity); | ||
630 | hadErrors = true; | ||
631 | } | ||
632 | } | ||
633 | } | ||
591 | 634 | ||
592 | string text = CompErr.ErrorText; | 635 | if (hadErrors) |
636 | { | ||
637 | throw new Exception(errtext); | ||
638 | } | ||
593 | 639 | ||
594 | // Use LSL type names | 640 | // On today's highly asynchronous systems, the result of |
595 | if (lang == enumCompileType.lsl) | 641 | // the compile may not be immediately apparent. Wait a |
596 | text = ReplaceTypes(CompErr.ErrorText); | 642 | // reasonable amount of time before giving up on it. |
597 | 643 | ||
598 | // The Second Life viewer's script editor begins | 644 | if (!File.Exists(OutFile)) |
599 | // countingn lines and columns at 0, so we subtract 1. | 645 | { |
600 | errtext += String.Format("Line ({0},{1}): {4} {2}: {3}\n", | 646 | for (int i=0; i<20 && !File.Exists(OutFile); i++) |
601 | lslPos.Key - 1, lslPos.Value - 1, | 647 | { |
602 | CompErr.ErrorNumber, text, severity); | 648 | System.Threading.Thread.Sleep(250); |
603 | } | 649 | } |
604 | 650 | // One final chance... | |
605 | if (!File.Exists(OutFile)) | 651 | if (!File.Exists(OutFile)) |
606 | { | 652 | { |
653 | errtext = String.Empty; | ||
654 | errtext += "No compile error. But not able to locate compiled file."; | ||
607 | throw new Exception(errtext); | 655 | throw new Exception(errtext); |
608 | } | 656 | } |
609 | } | 657 | } |
610 | 658 | ||
611 | // | ||
612 | // NO ERRORS, BUT NO COMPILED FILE | ||
613 | // | ||
614 | if (!File.Exists(OutFile)) | ||
615 | { | ||
616 | string errtext = String.Empty; | ||
617 | errtext += "No compile error. But not able to locate compiled file."; | ||
618 | throw new Exception(errtext); | ||
619 | } | ||
620 | // m_log.DebugFormat("[Compiler] Compiled new assembly "+ | 659 | // m_log.DebugFormat("[Compiler] Compiled new assembly "+ |
621 | // "for {0}", asset); | 660 | // "for {0}", asset); |
622 | 661 | ||
@@ -629,7 +668,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
629 | 668 | ||
630 | if (fi == null) | 669 | if (fi == null) |
631 | { | 670 | { |
632 | string errtext = String.Empty; | 671 | errtext = String.Empty; |
633 | errtext += "No compile error. But not able to stat file."; | 672 | errtext += "No compile error. But not able to stat file."; |
634 | throw new Exception(errtext); | 673 | throw new Exception(errtext); |
635 | } | 674 | } |
@@ -644,7 +683,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
644 | } | 683 | } |
645 | catch (Exception) | 684 | catch (Exception) |
646 | { | 685 | { |
647 | string errtext = String.Empty; | 686 | errtext = String.Empty; |
648 | errtext += "No compile error. But not able to open file."; | 687 | errtext += "No compile error. But not able to open file."; |
649 | throw new Exception(errtext); | 688 | throw new Exception(errtext); |
650 | } | 689 | } |