diff --git a/compiler2/ttcn3/port.c b/compiler2/ttcn3/port.c index 2e2e27087639953af35db9713d2fd1ed9774786e..48676dcc4a3a5e19d103a422297e86bbbef2f2d8 100644 --- a/compiler2/ttcn3/port.c +++ b/compiler2/ttcn3/port.c @@ -2774,8 +2774,17 @@ void defPortClass(const port_def* pdef, output_struct* output) } src = mputstr(src, ")\n" "{\n" - "if (!is_started) TTCN_error(\"Port %s is not started but a " - "message has arrived on it.\", port_name);\n"); + "if (!is_started) {\n" + "if (is_halted) {\n" + "TTCN_warning(\"A message that arrived on port %s has been discarded, " + "because the port is not started.\", port_name);\n" + "return;\n" + "}\n" + "else {\n" + "TTCN_error(\"Port %s is not started but a " + "message has arrived on it.\", port_name);\n" + "}\n" + "}\n"); if (pdef->has_sliding) src = mputstr(src, "(void)slider;\n"); if (is_simple) src = mputstr(src, "msg_tail_count++;\n"); src = mputprintf(src, "if (TTCN_Logger::log_this_event(" @@ -2913,8 +2922,17 @@ void defPortClass(const port_def* pdef, output_struct* output) pdef->realtime ? "timestamp" : "FLOAT()"); } src = mputstr(src, - "if (!is_started) TTCN_error(\"Port %s is not started but a " + "if (!is_started) {\n" + "if (is_halted) {\n" + "TTCN_warning(\"A message that arrived on port %s has been discarded, " + "because the port is not started.\", port_name);\n" + "return;\n" + "}\n" + "else {\n" + "TTCN_error(\"Port %s is not started but a " "message has arrived on it.\", port_name);\n" + "}\n" + "}\n" "msg_tail_count++;\n" "if (TTCN_Logger::log_this_event(TTCN_Logger::PORTEVENT_MQUEUE)) " "{\n" @@ -2988,8 +3006,17 @@ void defPortClass(const port_def* pdef, output_struct* output) } src = mputstr(src, ")\n" "{\n" - "if (!is_started) TTCN_error(\"Port %s is not started but a call " + "if (!is_started) {\n" + "if (is_halted) {\n" + "TTCN_warning(\"A call that arrived on port %s has been discarded, " + "because the port is not started.\", port_name);\n" + "return;\n" + "}\n" + "else {\n" + "TTCN_error(\"Port %s is not started but a call " "has arrived on it.\", port_name);\n" + "}\n" + "}\n" "proc_tail_count++;\n" "if (TTCN_Logger::log_this_event(TTCN_Logger::PORTEVENT_PQUEUE)) " "{\n" @@ -3057,8 +3084,17 @@ void defPortClass(const port_def* pdef, output_struct* output) } src = mputstr(src, ")\n" "{\n" - "if (!is_started) TTCN_error(\"Port %s is not started but a reply " + "if (!is_started) {\n" + "if (is_halted) {\n" + "TTCN_warning(\"A reply that arrived on port %s has been discarded, " + "because the port is not started.\", port_name);\n" + "return;\n" + "}\n" + "else {\n" + "TTCN_error(\"Port %s is not started but a reply " "has arrived on it.\", port_name);\n" + "}\n" + "}\n" "proc_tail_count++;\n" "if (TTCN_Logger::log_this_event(TTCN_Logger::PORTEVENT_PQUEUE)) " "{\n" @@ -3123,8 +3159,17 @@ void defPortClass(const port_def* pdef, output_struct* output) } src = mputstr(src, ")\n" "{\n" - "if (!is_started) TTCN_error(\"Port %s is not started but an " + "if (!is_started) {\n" + "if (is_halted) {\n" + "TTCN_warning(\"An exception that arrived on port %s has been discarded, " + "because the port is not started.\", port_name);\n" + "return;\n" + "}\n" + "else {\n" + "TTCN_error(\"Port %s is not started but an " "exception has arrived on it.\", port_name);\n" + "}\n" + "}\n" "proc_tail_count++;\n" "if (TTCN_Logger::log_this_event(TTCN_Logger::PORTEVENT_PQUEUE)) " "{\n" diff --git a/regression_test/commMessage/TcommMessage.ttcn b/regression_test/commMessage/TcommMessage.ttcn index bf5ad20209ff5265c52b04b20213975a18492555..bfcd1126a5f66b23efaa4958b0f902c80c906eba 100644 --- a/regression_test/commMessage/TcommMessage.ttcn +++ b/regression_test/commMessage/TcommMessage.ttcn @@ -1586,6 +1586,32 @@ testcase tc_bug_532060() runs on C { setverdict(pass); } + +function commMessageHaltPort_behavior() runs on commMessage_comp1 { + Port1.send(1); +} + +testcase commMessageHaltPort() runs on commMessage_comp1 { + var commMessage_comp1 comp := commMessage_comp1.create alive; + connect(self:Port1, comp:Port1); + comp.start(commMessageHaltPort_behavior()); + comp.done; + Port1.halt; + comp.start(commMessageHaltPort_behavior()); + comp.done; + timer t; + t.start(0.5); + alt { + [] Port1.receive(integer: ?) { t.stop; } + [] t.timeout { setverdict(fail, "Message 1 not received."); } + } + t.start(0.5); + alt { + [] Port1.receive(integer: ?) { setverdict(fail, "Message 2 not discarded."); } + [] t.timeout { setverdict(pass); } + } +} + control { execute(commMessageIntegerEncode()); execute(commMessageValue()); @@ -1628,5 +1654,6 @@ control { execute(commMessageReceiveAnyOrOmit()); execute(commMessageBehaviorFunctionParams()); execute(tc_bug_532060()); + execute(commMessageHaltPort()); } }