1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- S Y S T E M . R P C --
11 -- Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc. --
13 -- GNAT is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNAT; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
24 -- As a special exception, if other files instantiate generics from this --
25 -- unit, or you link this unit with other files to produce an executable, --
26 -- this unit does not by itself cause the resulting executable to be --
27 -- covered by the GNU General Public License. This exception does not --
28 -- however invalidate any other reasons why the executable file might be --
29 -- covered by the GNU Public License. --
31 -- GNAT was originally developed by the GNAT team at New York University. --
32 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
34 ------------------------------------------------------------------------------
36 with Unchecked_Deallocation
;
39 with System
.RPC
.Net_Trace
;
40 with System
.RPC
.Garlic
;
41 with System
.RPC
.Streams
;
42 pragma Elaborate
(System
.RPC
.Garlic
);
44 package body System
.RPC
is
46 use type Ada
.Streams
.Stream_Element_Count
;
47 use type Ada
.Streams
.Stream_Element_Offset
;
49 use type Garlic
.Protocol_Access
;
50 use type Garlic
.Lock_Method
;
52 Max_Of_Message_Id
: constant := 127;
54 subtype Message_Id_Type
is
55 Integer range -Max_Of_Message_Id
.. Max_Of_Message_Id
;
56 -- A message id is either a request id or reply id. A message id is
57 -- provided with a message to a receiving stub which uses the opposite
58 -- as a reply id. A message id helps to retrieve to which task is
59 -- addressed a reply. When the environment task receives a message, the
60 -- message id is extracted : a positive message id stands for a call, a
61 -- negative message id stands for a reply. A null message id stands for
62 -- an asynchronous request.
64 subtype Request_Id_Type
is Message_Id_Type
range 1 .. Max_Of_Message_Id
;
65 -- When a message id is positive, it is a request
67 type Message_Length_Per_Request
is array (Request_Id_Type
)
68 of Ada
.Streams
.Stream_Element_Count
;
70 Header_Size
: Ada
.Streams
.Stream_Element_Count
71 := Streams
.Get_Integer_Initial_Size
+
72 Streams
.Get_SEC_Initial_Size
;
73 -- Initial size needed for frequently used header streams
75 Stream_Error
: exception;
76 -- Occurs when a read procedure is executed on an empty stream
77 -- or when a write procedure is executed on a full stream
79 Partition_RPC_Receiver
: RPC_Receiver
;
80 -- Cache the RPC_Recevier passed by Establish_RPC_Receiver
82 type Anonymous_Task_Node
;
84 type Anonymous_Task_Node_Access
is access Anonymous_Task_Node
;
85 -- Types we need to construct a singly linked list of anonymous tasks
86 -- This pool is maintained to avoid a task creation each time a RPC
87 -- occurs - to be cont'd
89 task type Anonymous_Task_Type
(Self
: Anonymous_Task_Node_Access
) is
92 (Message_Id
: in Message_Id_Type
;
93 Partition
: in Partition_ID
;
94 Params_Size
: in Ada
.Streams
.Stream_Element_Count
;
95 Result_Size
: in Ada
.Streams
.Stream_Element_Count
;
96 Protocol
: in Garlic
.Protocol_Access
);
97 -- This entry provides an anonymous task a remote call to perform
98 -- This task calls for a
99 -- Request id is provided to construct the reply id by using
100 -- -Request. Partition is used to send the reply message. Params_Size
101 -- is the size of the calling stub Params stream. Then, Protocol
102 -- (used by the environment task previously) allows to extract the
103 -- message following the header (The header is extracted by the
106 end Anonymous_Task_Type
;
108 type Anonymous_Task_Access
is access Anonymous_Task_Type
;
110 type Anonymous_Task_List
is
112 Head
: Anonymous_Task_Node_Access
;
113 Tail
: Anonymous_Task_Node_Access
;
116 type Anonymous_Task_Node
is
118 Element
: Anonymous_Task_Access
;
119 Next
: Anonymous_Task_Node_Access
;
121 -- Types we need to construct a singly linked list of anonymous tasks
122 -- This pool is maintained to avoid a task creation each time a RPC
125 protected Garbage_Collector
is
128 (Item
: out Anonymous_Task_Node_Access
);
129 -- Anonymous task pool management : if there is an anonymous task
130 -- left, use it. Otherwise, allocate a new one
133 (Item
: in out Anonymous_Task_Node_Access
);
134 -- Anonymous task pool management : queue this task in the pool
135 -- of inactive anonymous tasks.
138 Anonymous_List
: Anonymous_Task_Node_Access
;
139 -- The list root of inactive anonymous tasks
141 end Garbage_Collector
;
145 entry New_Request
(Request
: out Request_Id_Type
);
146 -- To get a new request
148 entry Wait_On
(Request_Id_Type
)
149 (Length
: out Ada
.Streams
.Stream_Element_Count
);
150 -- To block the calling stub when it waits for a reply
151 -- When it is resumed, we provide the size of the reply
154 (Request
: in Request_Id_Type
;
155 Length
: in Ada
.Streams
.Stream_Element_Count
);
156 -- To wake up the calling stub when the environnement task has
157 -- received a reply for this request
161 task Environnement
is
164 -- Receive no message until Partition_Receiver is set
165 -- Establish_RPC_Receiver decides when the environment task
166 -- is allowed to start
170 protected Partition_Receiver
is
173 -- Blocks if the Partition_RPC_Receiver has not been set
176 -- Done by Establish_RPC_Receiver when Partition_RPC_Receiver
181 Was_Set
: Boolean := False;
182 -- True when Partition_RPC_Receiver has been set
184 end Partition_Receiver
;
185 -- Anonymous tasks have to wait for the Partition_RPC_Receiver
189 (D_Elaborate
, -- About the elaboration of this package
190 D_Communication
, -- About calls to Send and Receive
192 D_Exception
); -- Exception handler
195 package Debugging
is new System
.RPC
.Net_Trace
(Debug_Level
, "RPC : ");
199 (Flag
: in Debug_Level
; Info
: in String) renames Debugging
.Debug
;
202 ------------------------
203 -- Partition_Receiver --
204 ------------------------
206 protected body Partition_Receiver
is
208 -------------------------------
209 -- Partition_Receiver.Is_Set --
210 -------------------------------
212 entry Is_Set
when Was_Set
is
217 ----------------------------
218 -- Partition_Receiver.Set --
219 ----------------------------
226 end Partition_Receiver
;
233 (Index
: out Packet_Node_Access
;
234 Stream
: in Params_Stream_Type
) is
236 Index
:= Stream
.Extra
.Head
;
237 exception when others =>
238 D
(D_Exception
, "exception in Head_Node");
247 (Index
: out Packet_Node_Access
;
248 Stream
: in Params_Stream_Type
) is
250 Index
:= Stream
.Extra
.Tail
;
251 exception when others =>
252 D
(D_Exception
, "exception in Tail_Node");
261 (Index
: in Packet_Node_Access
) return Boolean is
264 exception when others =>
265 D
(D_Exception
, "exception in Null_Node");
269 ----------------------
270 -- Delete_Head_Node --
271 ----------------------
273 procedure Delete_Head_Node
274 (Stream
: in out Params_Stream_Type
) is
277 new Unchecked_Deallocation
278 (Packet_Node
, Packet_Node_Access
);
280 Next_Node
: Packet_Node_Access
:= Stream
.Extra
.Head
.Next
;
284 -- Delete head node and free memory usage
286 Free
(Stream
.Extra
.Head
);
287 Stream
.Extra
.Head
:= Next_Node
;
289 -- If the extra storage is empty, update tail as well
291 if Stream
.Extra
.Head
= null then
292 Stream
.Extra
.Tail
:= null;
295 exception when others =>
296 D
(D_Exception
, "exception in Delete_Head_Node");
298 end Delete_Head_Node
;
305 (Node
: in out Packet_Node_Access
) is
308 -- Node is set to the next node
309 -- If not possible, Stream_Error is raised
317 exception when others =>
318 D
(D_Exception
, "exception in Next_Node");
322 ---------------------
323 -- Append_New_Node --
324 ---------------------
326 procedure Append_New_Node
327 (Stream
: in out Params_Stream_Type
) is
328 Index
: Packet_Node_Access
;
331 -- Set Index to the end of the linked list
333 Tail_Node
(Index
, Stream
);
335 if Null_Node
(Index
) then
337 -- The list is empty : set head as well
339 Stream
.Extra
.Head
:= new Packet_Node
;
340 Stream
.Extra
.Tail
:= Stream
.Extra
.Head
;
344 -- The list is not empty : link new node with tail
346 Stream
.Extra
.Tail
.Next
:= new Packet_Node
;
347 Stream
.Extra
.Tail
:= Stream
.Extra
.Tail
.Next
;
351 exception when others =>
352 D
(D_Exception
, "exception in Append_New_Node");
361 (Stream
: in out Params_Stream_Type
;
362 Item
: out Ada
.Streams
.Stream_Element_Array
;
363 Last
: out Ada
.Streams
.Stream_Element_Offset
) renames
364 System
.RPC
.Streams
.Read
;
371 (Stream
: in out Params_Stream_Type
;
372 Item
: in Ada
.Streams
.Stream_Element_Array
) renames
373 System
.RPC
.Streams
.Write
;
375 -----------------------
376 -- Garbage_Collector --
377 -----------------------
379 protected body Garbage_Collector
is
381 --------------------------------
382 -- Garbage_Collector.Allocate --
383 --------------------------------
386 (Item
: out Anonymous_Task_Node_Access
) is
387 New_Anonymous_Task_Node
: Anonymous_Task_Node_Access
;
388 Anonymous_Task
: Anonymous_Task_Access
;
391 -- If the list is empty, allocate a new anonymous task
392 -- Otherwise, reuse the first queued anonymous task
394 if Anonymous_List
= null then
396 -- Create a new anonymous task
397 -- Provide this new task with its id to allow it
398 -- to enqueue itself into the free anonymous task list
399 -- with the function Deallocate
401 New_Anonymous_Task_Node
:= new Anonymous_Task_Node
;
403 new Anonymous_Task_Type
(New_Anonymous_Task_Node
);
404 New_Anonymous_Task_Node
.all := (Anonymous_Task
, null);
408 -- Extract one task from the list
409 -- Set the Next field to null to avoid possible bugs
411 New_Anonymous_Task_Node
:= Anonymous_List
;
412 Anonymous_List
:= Anonymous_List
.Next
;
413 New_Anonymous_Task_Node
.Next
:= null;
417 -- Item is an out parameter
419 Item
:= New_Anonymous_Task_Node
;
421 exception when others =>
422 D
(D_Exception
, "exception in Allocate (Anonymous Task)");
426 ----------------------------------
427 -- Garbage_Collector.Deallocate --
428 ----------------------------------
431 (Item
: in out Anonymous_Task_Node_Access
) is
434 -- Enqueue the task in the free list
436 Item
.Next
:= Anonymous_List
;
437 Anonymous_List
:= Item
;
439 exception when others =>
440 D
(D_Exception
, "exception in Deallocate (Anonymous Task)");
444 end Garbage_Collector
;
451 (Partition
: in Partition_ID
;
452 Params
: access Params_Stream_Type
;
453 Result
: access Params_Stream_Type
) is
454 Protocol
: Protocol_Access
;
455 Request
: Request_Id_Type
;
456 Header
: aliased Params_Stream_Type
(Header_Size
);
457 R_Length
: Ada
.Streams
.Stream_Element_Count
;
460 -- Parameters order :
461 -- Opcode (provided and used by garlic)
462 -- (1) Size (provided by s-rpc and used by garlic)
463 -- (size of (2)+(3)+(4)+(5))
464 -- (2) Request (provided by calling stub (resp receiving stub) and
465 -- used by anonymous task (resp Do_RPC))
466 -- *** ZERO IF APC ***
467 -- (3) Res.len. (provided by calling stubs and used by anonymous task)
468 -- *** ZERO IF APC ***
469 -- (4) Receiver (provided by calling stubs and used by anonymous task)
470 -- (5) Params (provided by calling stubs and used by anonymous task)
472 -- The call is a remote call or a local call. A local call occurs
473 -- when the pragma All_Calls_Remote has been specified. Do_RPC is
474 -- called and the execution has to be performed in the PCS
476 if Partition
/= Garlic
.Get_My_Partition_ID
then
478 -- Get a request id to be resumed when the reply arrives
480 Dispatcher
.New_Request
(Request
);
482 -- Build header = request (2) + result.initial_size (3)
484 D
(D_Debug
, "Do_RPC - Build header");
485 Streams
.Allocate
(Header
);
486 Streams
.Integer_Write_Attribute
-- (2)
487 (Header
'Access, Request
);
488 System
.RPC
.Streams
.SEC_Write_Attribute
-- (3)
489 (Header
'Access, Result
.Initial_Size
);
491 -- Get a protocol method to communicate with the remote partition
492 -- and give the message size
495 "Do_RPC - Lookup for protocol to talk to partition" &
496 Partition_ID
'Image (Partition
));
499 Streams
.Get_Stream_Size
(Header
'Access) +
500 Streams
.Get_Stream_Size
(Params
), -- (1)
504 -- Send the header by using the protocol method
506 D
(D_Communication
, "Do_RPC - Send Header to partition" &
507 Partition_ID
'Image (Partition
));
511 Header
'Access); -- (2) + (3)
513 -- The header is deallocated
515 Streams
.Deallocate
(Header
);
517 -- Send Params from Do_RPC
519 D
(D_Communication
, "Do_RPC - Send Params to partition" &
520 Partition_ID
'Image (Partition
));
524 Params
); -- (4) + (5)
526 -- Let Garlic know we have nothing else to send
531 D
(D_Debug
, "Do_RPC - Suspend");
533 -- Wait for a reply and get the reply message length
535 Dispatcher
.Wait_On
(Request
) (R_Length
);
536 D
(D_Debug
, "Do_RPC - Resume");
539 New_Result
: aliased Params_Stream_Type
(R_Length
);
542 -- Adjust the Result stream size right now to be able to load
543 -- the stream in one receive call. Create a temporary resutl
544 -- that will be substituted to Do_RPC one
546 Streams
.Allocate
(New_Result
);
548 -- Receive the reply message from receiving stub
550 D
(D_Communication
, "Do_RPC - Receive Result from partition" &
551 Partition_ID
'Image (Partition
));
557 -- Let Garlic know we have nothing else to receive
559 Garlic
.Complete_Receive
563 -- Update calling stub Result stream
565 D
(D_Debug
, "Do_RPC - Reconstruct Result");
566 Streams
.Deallocate
(Result
.all);
567 Result
.Initial
:= New_Result
.Initial
;
568 Streams
.Dump
("|||", Result
.all);
574 -- Do RPC locally and first wait for Partition_RPC_Receiver to be
577 Partition_Receiver
.Is_Set
;
578 D
(D_Debug
, "Do_RPC - Locally");
579 Partition_RPC_Receiver
.all (Params
, Result
);
583 exception when others =>
584 D
(D_Exception
, "exception in Do_RPC");
593 (Partition
: in Partition_ID
;
594 Params
: access Params_Stream_Type
) is
595 Message_Id
: Message_Id_Type
:= 0;
596 Protocol
: Protocol_Access
;
597 Header
: aliased Params_Stream_Type
(Header_Size
);
600 -- For more informations, see above
601 -- Request = 0 as we are not waiting for a reply message
602 -- Result length = 0 as we don't expect a result at all
604 if Partition
/= Garlic
.Get_My_Partition_ID
then
606 -- Build header = request (2) + result.initial_size (3)
607 -- As we have an APC, the request id is null to indicate
608 -- to the receiving stub that we do not expect a reply
609 -- This comes from 0 = -0
611 D
(D_Debug
, "Do_APC - Build Header");
612 Streams
.Allocate
(Header
);
613 Streams
.Integer_Write_Attribute
614 (Header
'Access, Integer (Message_Id
));
615 Streams
.SEC_Write_Attribute
618 -- Get a protocol method to communicate with the remote partition
619 -- and give the message size
622 "Do_APC - Lookup for protocol to talk to partition" &
623 Partition_ID
'Image (Partition
));
626 Streams
.Get_Stream_Size
(Header
'Access) +
627 Streams
.Get_Stream_Size
(Params
),
631 -- Send the header by using the protocol method
633 D
(D_Communication
, "Do_APC - Send Header to partition" &
634 Partition_ID
'Image (Partition
));
640 -- The header is deallocated
642 Streams
.Deallocate
(Header
);
644 -- Send Params from Do_APC
646 D
(D_Communication
, "Do_APC - Send Params to partition" &
647 Partition_ID
'Image (Partition
));
653 -- Let Garlic know we have nothing else to send
661 Result
: aliased Params_Stream_Type
(0);
664 -- Result is here a dummy parameter
665 -- No reason to deallocate as it is not allocated at all
667 Partition_Receiver
.Is_Set
;
668 D
(D_Debug
, "Do_APC - Locally");
669 Partition_RPC_Receiver
.all (Params
, Result
'Access);
675 exception when others =>
676 D
(D_Exception
, "exception in Do_APC");
680 ----------------------------
681 -- Establish_RPC_Receiver --
682 ----------------------------
684 procedure Establish_RPC_Receiver
(
685 Partition
: in Partition_ID
;
686 Receiver
: in RPC_Receiver
) is
689 -- Set Partition_RPC_Receiver and allow RPC mechanism
691 Partition_RPC_Receiver
:= Receiver
;
692 Partition_Receiver
.Set
;
693 D
(D_Elaborate
, "Partition_Receiver is set");
695 exception when others =>
696 D
(D_Exception
, "exception in Establish_RPC_Receiver");
698 end Establish_RPC_Receiver
;
704 task body Dispatcher
is
705 Last_Request
: Request_Id_Type
:= Request_Id_Type
'First;
706 Current_Rqst
: Request_Id_Type
:= Request_Id_Type
'First;
707 Current_Size
: Ada
.Streams
.Stream_Element_Count
;
713 -- New_Request to get an entry in Dispatcher table
714 -- Wait_On for Do_RPC calls
715 -- Wake_Up called by environment task when a Do_RPC receives
716 -- the result of its remote call
721 (Request
: out Request_Id_Type
) do
722 Request
:= Last_Request
;
727 if Last_Request
= Request_Id_Type
'Last then
728 Last_Request
:= Request_Id_Type
'First;
730 Last_Request
:= Last_Request
+ 1;
738 (Request
: in Request_Id_Type
;
739 Length
: in Ada
.Streams
.Stream_Element_Count
) do
741 -- The environment reads the header and has been notified
742 -- of the reply id and the size of the result message
744 Current_Rqst
:= Request
;
745 Current_Size
:= Length
;
750 -- Must be select with delay for aborted tasks
754 accept Wait_On
(Current_Rqst
)
755 (Length
: out Ada
.Streams
.Stream_Element_Count
) do
756 Length
:= Current_Size
;
761 -- To free the Dispatcher when a task is aborted
775 exception when others =>
776 D
(D_Exception
, "exception in Dispatcher body");
780 -------------------------
781 -- Anonymous_Task_Type --
782 -------------------------
784 task body Anonymous_Task_Type
is
785 Whoami
: Anonymous_Task_Node_Access
:= Self
;
786 C_Message_Id
: Message_Id_Type
; -- Current Message Id
787 C_Partition
: Partition_ID
; -- Current Partition
788 Params_S
: Ada
.Streams
.Stream_Element_Count
; -- Params message size
789 Result_S
: Ada
.Streams
.Stream_Element_Count
; -- Result message size
790 C_Protocol
: Protocol_Access
; -- Current Protocol
795 -- Get a new RPC to execute
799 (Message_Id
: in Message_Id_Type
;
800 Partition
: in Partition_ID
;
801 Params_Size
: in Ada
.Streams
.Stream_Element_Count
;
802 Result_Size
: in Ada
.Streams
.Stream_Element_Count
;
803 Protocol
: in Protocol_Access
) do
804 C_Message_Id
:= Message_Id
;
805 C_Partition
:= Partition
;
806 Params_S
:= Params_Size
;
807 Result_S
:= Result_Size
;
808 C_Protocol
:= Protocol
;
815 Params
: aliased Params_Stream_Type
(Params_S
);
816 Result
: aliased Params_Stream_Type
(Result_S
);
817 Header
: aliased Params_Stream_Type
(Header_Size
);
820 -- We reconstruct all the client context : Params and Result
821 -- with the SAME size, then we receive Params from calling stub
824 "Anonymous Task - Receive Params from partition" &
825 Partition_ID
'Image (C_Partition
));
831 -- Let Garlic know we don't receive anymore
833 Garlic
.Complete_Receive
837 -- Check that Partition_RPC_Receiver has been set
839 Partition_Receiver
.Is_Set
;
844 "Anonymous Task - Perform Partition_RPC_Receiver for request" &
845 Message_Id_Type
'Image (C_Message_Id
));
846 Partition_RPC_Receiver
(Params
'Access, Result
'Access);
848 -- If this was a RPC we send the result back
849 -- Otherwise, do nothing else than deallocation
851 if C_Message_Id
/= 0 then
853 -- Build Header = -C_Message_Id + Result Size
854 -- Provide the request id to the env task of the calling
855 -- stub partition We get the real result stream size : the
856 -- calling stub (in Do_RPC) updates its size to this one
858 D
(D_Debug
, "Anonymous Task - Build Header");
859 Streams
.Allocate
(Header
);
860 Streams
.Integer_Write_Attribute
861 (Header
'Access, Integer (-C_Message_Id
));
862 Streams
.SEC_Write_Attribute
864 Streams
.Get_Stream_Size
(Result
'Access));
867 -- Get a protocol method to comunicate with the remote
868 -- partition and give the message size
871 "Anonymous Task - Lookup for protocol talk to partition" &
872 Partition_ID
'Image (C_Partition
));
875 Streams
.Get_Stream_Size
(Header
'Access) +
876 Streams
.Get_Stream_Size
(Result
'Access),
880 -- Send the header by using the protocol method
883 "Anonymous Task - Send Header to partition" &
884 Partition_ID
'Image (C_Partition
));
890 -- Send Result toDo_RPC
893 "Anonymous Task - Send Result to partition" &
894 Partition_ID
'Image (C_Partition
));
900 -- Let Garlic know we don't send anymore
905 Streams
.Deallocate
(Header
);
909 Streams
.Deallocate
(Params
);
910 Streams
.Deallocate
(Result
);
914 -- Enqueue into the anonymous task free list : become inactive
916 Garbage_Collector
.Deallocate
(Whoami
);
920 exception when others =>
921 D
(D_Exception
, "exception in Anonymous_Task_Type body");
923 end Anonymous_Task_Type
;
929 task body Environnement
is
930 Partition
: Partition_ID
;
931 Message_Size
: Ada
.Streams
.Stream_Element_Count
;
932 Result_Size
: Ada
.Streams
.Stream_Element_Count
;
933 Message_Id
: Message_Id_Type
;
934 Header
: aliased Params_Stream_Type
(Header_Size
);
935 Protocol
: Protocol_Access
;
936 Anonymous
: Anonymous_Task_Node_Access
;
939 -- Wait the Partition_RPC_Receiver to be set
942 D
(D_Elaborate
, "Environment task elaborated");
946 -- We receive first a fixed size message : the header
947 -- Header = Message Id + Message Size
949 Streams
.Allocate
(Header
);
951 -- Garlic provides the size of the received message and the
952 -- protocol to use to communicate with the calling partition
954 Garlic
.Initiate_Receive
960 "Environment task - Receive protocol to talk to active partition" &
961 Partition_ID
'Image (Partition
));
963 -- Extract the header to route the message either to
964 -- an anonymous task (Message Id > 0 <=> Request Id)
965 -- or to a waiting task (Message Id < 0 <=> Reply Id)
968 "Environment task - Receive Header from partition" &
969 Partition_ID
'Image (Partition
));
975 -- Evaluate the remaining size of the message
977 Message_Size
:= Message_Size
-
978 Streams
.Get_Stream_Size
(Header
'Access);
980 -- Extract from header : message id and message size
982 Streams
.Integer_Read_Attribute
(Header
'Access, Message_Id
);
983 Streams
.SEC_Read_Attribute
(Header
'Access, Result_Size
);
985 if Streams
.Get_Stream_Size
(Header
'Access) /= 0 then
987 -- If there are stream elements left in the header ???
989 D
(D_Exception
, "Header is not empty");
994 if Message_Id
< 0 then
996 -- The message was sent by a receiving stub : wake up the
997 -- calling task - We have a reply there
999 D
(D_Debug
, "Environment Task - Receive Reply from partition" &
1000 Partition_ID
'Image (Partition
));
1001 Dispatcher
.Wake_Up
(-Message_Id
, Result_Size
);
1005 -- The message was send by a calling stub : get an anonymous
1006 -- task to perform the job
1008 D
(D_Debug
, "Environment Task - Receive Request from partition" &
1009 Partition_ID
'Image (Partition
));
1010 Garbage_Collector
.Allocate
(Anonymous
);
1012 -- We substracted the size of the header from the size of the
1013 -- global message in order to provide immediatly Params size
1015 Anonymous
.Element
.Start
1024 -- Deallocate header : unnecessary - WARNING
1026 Streams
.Deallocate
(Header
);
1030 exception when others =>
1031 D
(D_Exception
, "exception in Environment");
1037 -- Set debugging information
1039 Debugging
.Set_Environment_Variable
("RPC");
1040 Debugging
.Set_Debugging_Name
("D", D_Debug
);
1041 Debugging
.Set_Debugging_Name
("E", D_Exception
);
1042 Debugging
.Set_Debugging_Name
("C", D_Communication
);
1043 Debugging
.Set_Debugging_Name
("Z", D_Elaborate
);
1044 D
(D_Elaborate
, "To be elaborated");
1046 -- When this body is elaborated we should ensure that RCI name server
1047 -- has been already elaborated : this means that Establish_RPC_Receiver
1048 -- has already been called and that Partition_RPC_Receiver is set
1050 Environnement
.Start
;
1051 D
(D_Elaborate
, "ELABORATED");