Commit 96c1496a authored by Kristof Szabados's avatar Kristof Szabados
Browse files

Fixed 'out' and 'inout' parameters for 'map'/'unmap' in parallel mode (bug 546286) Java side.


Signed-off-by: Kristof Szabados's avatarKristof Szabados <Kristof.Szabados@ericsson.com>
parent 134c3c65
......@@ -847,12 +847,17 @@ public final class TTCN_Communication {
send_message(text_buf);
}
public static void send_mapped(final String localPort, final String systemPort, final boolean translation) {
public static void send_mapped(final String localPort, final String systemPort, final Map_Params params, final boolean translation) {
final Text_Buf text_buf = new Text_Buf();
text_buf.push_int(MSG_MAPPED);
text_buf.push_int(translation ? 1 : 0);
text_buf.push_string(localPort);
text_buf.push_string(systemPort);
final int nof_params = params.get_nof_params();
text_buf.push_int(nof_params);
for (int i = 0; i < nof_params; i++) {
text_buf.push_string(params.get_param(i).get_value().toString());
}
send_message(text_buf);
}
......@@ -873,12 +878,17 @@ public final class TTCN_Communication {
send_message(text_buf);
}
public static void send_unmapped(final String localPort, final String systemPort, final boolean translation) {
public static void send_unmapped(final String localPort, final String systemPort, final Map_Params params, final boolean translation) {
final Text_Buf text_buf = new Text_Buf();
text_buf.push_int(MSG_UNMAPPED);
text_buf.push_int(translation ? 1 : 0);
text_buf.push_string(localPort);
text_buf.push_string(systemPort);
final int nof_params = params.get_nof_params();
text_buf.push_int(nof_params);
for (int i = 0; i < nof_params; i++) {
text_buf.push_string(params.get_param(i).get_value().toString());
}
send_message(text_buf);
}
......@@ -1490,15 +1500,23 @@ public final class TTCN_Communication {
}
if (!TTCN_Runtime.is_single()) {
if (translation) {
send_mapped(system_port, local_port, translation);
send_mapped(system_port, local_port, params, translation);
} else {
send_mapped(local_port, system_port, translation);
send_mapped(local_port, system_port, params, translation);
}
}
}
private static void process_map_ack() {
incoming_buf.get().cut_message();
final Text_Buf local_incoming_buf = incoming_buf.get();
final int nof_params = local_incoming_buf.pull_int().get_int();
final Map_Params local_map_params = TitanPort.map_params_cache.get();
local_map_params.reset(nof_params);
for (int i = 0; i < nof_params; i++) {
final String par = local_incoming_buf.pull_string();
local_map_params.set_param(i, new TitanCharString(par));
}
local_incoming_buf.cut_message();
switch (TTCN_Runtime.get_state()) {
case MTC_MAP:
......@@ -1535,15 +1553,23 @@ public final class TTCN_Communication {
}
if (!TTCN_Runtime.is_single()) {
if (translation) {
send_unmapped(system_port, local_port, translation);
send_unmapped(system_port, local_port, params, translation);
} else {
send_unmapped(local_port, system_port, translation);
send_unmapped(local_port, system_port, params, translation);
}
}
}
private static void process_unmap_ack() {
incoming_buf.get().cut_message();
final Text_Buf local_incoming_buf = incoming_buf.get();
final int nof_params = local_incoming_buf.pull_int().get_int();
final Map_Params local_map_params = TitanPort.map_params_cache.get();
local_map_params.reset(nof_params);
for (int i = 0; i < nof_params; i++) {
final String par = local_incoming_buf.pull_string();
local_map_params.set_param(i, new TitanCharString(par));
}
local_incoming_buf.cut_message();
switch (TTCN_Runtime.get_state()) {
case MTC_UNMAP:
......
......@@ -2009,11 +2009,13 @@ public final class TTCN_Runtime {
TTCN_Communication.send_map_req(componentReference.componentValue, componentPort, systemPort, params, translation);
executorState.set(executorStateEnum.MTC_MAP);
wait_for_state_change();
params.operator_assign(TitanPort.map_params_cache.get());
break;
case PTC_FUNCTION:
TTCN_Communication.send_map_req(componentReference.componentValue, componentPort, systemPort, params, translation);
executorState.set(executorStateEnum.PTC_MAP);
wait_for_state_change();
params.operator_assign(TitanPort.map_params_cache.get());
break;
default:
if (in_controlPart()) {
......@@ -2086,11 +2088,13 @@ public final class TTCN_Runtime {
TTCN_Communication.send_unmap_req(componentReference.componentValue, componentPort, systemPort, params, translation);
executorState.set(executorStateEnum.MTC_UNMAP);
wait_for_state_change();
params.operator_assign(TitanPort.map_params_cache.get());
break;
case PTC_FUNCTION:
TTCN_Communication.send_unmap_req(componentReference.componentValue, componentPort, systemPort, params, translation);
executorState.set(executorStateEnum.PTC_UNMAP);
wait_for_state_change();
params.operator_assign(TitanPort.map_params_cache.get());
break;
default:
if (in_controlPart()) {
......
......@@ -139,14 +139,45 @@ public class TitanPort extends Channel_And_Timeout_Event_Handler {
}
public static final class Map_Params {
private final int nof_params;
private final ArrayList<TitanCharString> params;
private int nof_params;
private ArrayList<TitanCharString> params;
public Map_Params(final int nof_params) {
init(nof_params);
}
public Map_Params(final Map_Params other) {
copy(other);
}
private void init(final int nof_params) {
this.nof_params = nof_params;
this.params = new ArrayList<TitanCharString>(nof_params);
}
private void clear() {
nof_params = 0;
this.params = new ArrayList<TitanCharString>(nof_params);
}
private void copy(final Map_Params other) {
init(other.nof_params);
for (int i = 0; i < nof_params; i++) {
params.set(i, other.params.get(i));
}
}
public Map_Params operator_assign(final Map_Params other) {
clear();
copy(other);
return this;
}
public void reset(final int nof_params) {
//clear();
init(nof_params);
}
public void set_param(final int index, final TitanCharString param) {
if (index >= nof_params) {
throw new TtcnError("Map/unmap parameter index out of bounds");
......@@ -168,6 +199,13 @@ public class TitanPort extends Channel_And_Timeout_Event_Handler {
}
}
public static final ThreadLocal<Map_Params> map_params_cache = new ThreadLocal<Map_Params>() {
@Override
protected Map_Params initialValue() {
return new Map_Params(0);
}
};
protected String port_name;
protected int msg_head_count;
protected int msg_tail_count;
......@@ -381,15 +419,16 @@ public class TitanPort extends Channel_And_Timeout_Event_Handler {
while (!system_mappings.isEmpty()) {
final String system_port = system_mappings.get(0);
TTCN_Logger.log_port_misc(TitanLoggerApi.Port__Misc_reason.enum_type.removing__unterminated__mapping, port_name, TitanComponent.NULL_COMPREF, system_port, null, -1, 0);
final Map_Params params = new Map_Params(0);
try {
unmap(system_port, new Map_Params(0), system);
unmap(system_port, params, system);
} catch (final TtcnError e) {
//intentionally empty
}
if (is_parallel) {
try {
TTCN_Communication.send_unmapped(port_name, system_port, system);
TTCN_Communication.send_unmapped(port_name, system_port, params, system);
} catch (final TtcnError e) {
//intentionally empty
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment