CHANGE

Property

Value

Kind

Server library, client library, or connection library

Type

Procedure (see below)

Read

Never

Write

Server libraries: only in an EXPORTLIBRARY statement in the server library program

Client libraries: only in the library declaration

Connection libraries: only in the connection library declaration

Default

Not applicable

Explanation

The CHANGE attribute specifies a procedure that notifies the library process of any changes in the status of a particular connection. The person who implements the library program is responsible for writing this procedure (hereafter referred to as the CHANGE procedure).

The system passes parameters to the CHANGE procedure that identify the new state of the connection and the reason that the state is changing. The CHANGE procedure can notify the library process of the changed status by modifying global objects in the library.

The connection does not fully transition to the state reported by the CHANGE procedure until the CHANGE procedure exits. Therefore, it is important not to include statements in the CHANGE procedure that could cause the CHANGE procedure to enter any prolonged waiting state.

If an error or fault occurs in a CHANGE procedure and the new state is LINKING or LINKED, the system prevents the change in connection state from completing. Further, the error or fault is propagated to the requesting process (the process that initiated the linkage or delinkage that is in progress). If the requesting process does not include code to handle the fault, the system discontinues the requesting process.

Library Linkages

In general, the system does not permit CHANGE procedures to execute statements that cause a new library linkage to occur; such statements result in a failed linkage attempt. However, the system does permit CHANGE procedures to link to certain system libraries such as GENERALSUPPORT and MCPSUPPORT. When a statement in a CHANGE procedure links to a system library, the system does not execute any CHANGE or APPROVAL procedure that the linking process has declared for the system library itself.

Client Libraries and Server Libraries

A CHANGE procedure can be specified inside the server library program or inside the client program.

For server libraries, the CHANGE attribute can be assigned only in an EXPORTLIBRARY statement. For example, the following ALGOL statement specifies that when the current block freezes as a library, the procedure CHG1 should be used as the CHANGE procedure for that library:

EXPORTLIBRARY (CHANGE = CHG1);

When CHANGE is specified for a server library, the CHANGE procedure is executed whenever any client process finishes linking to, or starts delinking from, the library.

For client programs, the CHANGE attribute can be assigned only in a library declaration. In this case, the CHANGE procedure is executed whenever that particular client program finishes linking to or starts delinking from the library.

For server libraries and client libraries, the system invokes the CHANGE procedure only when the connection state changes to LINKED or to DELINKING. In some cases, it is possible that the system will invoke the CHANGE procedure more than once for the DELINKING state.

Note: A server library cannot determine its current number of clients by reading the LIBRARYUSERS task attribute inside the CHANGE procedure, because the MYSELF task variable does not refer to the server library process. Refer to the discussion of the MYSELF task variable later under this heading.

Connection Libraries

The CHANGE attribute can be assigned only in a connection library declaration, and the CHANGE procedure must be declared inside the connection library block.

The CHANGE attribute can be assigned to the connection library on either side of a connection. That is, a CHANGE attribute can be specified in a connection library declaration regardless of whether that connection library is to be used in READYCL or LINKLIBRARY functions.

When a linkage attempt for a connection library fails, it does not go through the normal state progression from NOTLINKED to LINKING to LINKED to DELINKING and back to NOTLINKED. Instead, the connection library either does not undergo state transitions or traverses the states from LINKING to DELINKING and back to NOTLINKED.

MYSELF Task Variable

Currently, when the MYSELF task variable is used inside a CHANGE procedure, MYSELF refers to the process initiating the linkage or delinkage. This process is also referenced by the task-valued parameter ACTOR, which is described later under this heading.

Note: The meaning of the MYSELF task variable in CHANGE procedures is subject to change in future software releases. Therefore, it is preferable to use the ACTOR parameter instead of MYSELF in CHANGE procedures.

Parameters and Return Value

The CHANGE procedure must have the following form:

PROCEDURE CHANGE (CONN_INDEX, NEW_STATE, REASON, ACTOR, IMDSED);
   VALUE   CONN_INDEX, NEW_STATE, REASON, IMDSED;
   INTEGER CONN_INDEX, NEW_STATE, REASON;
   TASK    ACTOR;
   BOOLEAN IMDSED;

The CHANGE procedure should read, but not modify, the procedure parameters. The following are the meanings of these parameters:

Parameter

Meaning

CONN_INDEX

Server libraries: This parameter has no meaning.

Connection libraries: The index of the connection that has changed state. The index can be different on the requesting library side than on the responding library side. CONN_INDEX reflects the value from the point of view of the requesting or responding connection library to which this CHANGE procedure is assigned.

NEW_STATE

The value that the STATE attribute now returns.

The following descriptions include the STATE attribute mnemonic corresponding to each numeric value:

  • 1 (NOTLINKED)

    Server libraries: Value is never returned.

    Connection libraries: The connection specified by CONN_INDEX has completed delinkage and imported library objects cannot be used. If any connection libraries are referenced, the CHANGE procedure causes a fault and ceases processing.

  • 2 (LINKING)

    Server libraries: Value is never returned.

    Connection libraries: A linkage is initiated, but not complete, for the connection index specified by CONN_INDEX. The APPROVAL procedure, if any, is called. However, no linkages have been established between export and import objects and imported library objects cannot be used. If any connection libraries are referenced, the CHANGE procedure causes a fault and ceases processing. The linkage fails with error -23 (CHANGE procedure faulted).

  • 3 (LINKED)

    Server libraries: A client process has completed linking to the library.

    Connection libraries: The connection specified by CONN_INDEX has completed linkage.

NEW_STATE (cont.)

  • 4 (DELINKING)

    Server libraries: A client process has started delinking from the library.

    Connection libraries: Delinkage is initiated, but not complete, for the connection index specified by CONN_INDEX.

REASON

The reason for the state change.

 Field [03:03]

If the NEW_STATE value is 2 (linking) or 4 (delinking), then the following are the possible values of this field and their meanings:

  • 0

    The change resulted from a LINKLIBRARY, DELINKLIBRARY, or CANCEL function.

  • 1

    The change resulted from implicit library linkage or from delinkage due to block exit.

 

If the NEW_STATE value is 1 (not linked), then the following are the possible values of this field and their meanings:

  • 0

    Linkage removed by DELINKLIBRARY or CANCEL.

  • 1

    Linkage terminated due to block exit.

  • 2

    Linkage attempt failed because templates didn't match.

  • 3

    Linkage attempt failed because of a CHANGE procedure fault.

  • 4

    An MCP error occurred.

  Field [00:01]

The locality bit.

The following are the possible values and meanings:

  • 0

    This CHANGE procedure is the CHANGE procedure for the process initiating the linkage or delinkage.

  • 1

    This CHANGE procedure is the CHANGE procedure for the library being linked to or delinked from.

ACTOR

The task variable for the process whose action caused the state change. If the new state is 2 (linking) or 3 (linked), the ACTOR process is the one that initiated the link, either by calling LINKLIBRARY or by implicit linkage.

Statements in the CHANGE procedure can read the task attributes of the ACTOR parameter, but cannot modify any of these attributes. Attempts to modify such task attributes result in the warning message MAY NOT MODIFY THIS TASK, and the attribute values are not changed.

IMDSED

  • TRUE

    The ACTOR process is terminating abnormally, either due to a program fault or a DS (Discontinue) system command. The ACTOR process is being delinked because of this abnormal termination.

  • FALSE

    The ACTOR process is not terminating abnormally.