SRV_CTL_MIGRATE

SRV_CTL_MIGRATE is a srv_send_ctlinfo() control type. You can use SRV_CTL_MIGRATE to send a migration request to the client or cancel a previous migration request, provided the client supports migration and has received a session ID when it first connected to the session.

Requesting a client migration

This sample code sends a request to the client to migrate to server “target”:

CS_RETCODE ret;
SRV_CTLITEM *srvitems;
CS_CHAR *target;
/*
** request a migration to server 'target'
*/
srvitems = (SRV_CTLITEM *) srv_alloc(sizeof
   (SRV_CTLITEM));
srvitems[0].srv_ctlitemtype = SRV_CT_SERVERNAME;
srvitems[0].srv_ctllength = strlen(target);
srvitems[0].srv_ctlptr = target;
ret = srv_send_ctlinfo(sp, SRV_CTL_MIGRATE, 1,
   srvitems);
srv_free(srvitems);

Your application can still send the SRV_CTL_MIGRATE control type even if a migration has already been requested. Open Server cancels the earlier migration request and sends a new request to the client. The return values for a new migration request are:

Return value

Description

CS_SUCCEED

The migration request was sent successfully.

CS_FAIL

The migration request failed due to one of the following reasons:

  • The Open Server thread does not support connection migration.

  • An earlier migration request was sent and the client has started migrating to the new server.

Cancelling a migration

You can also use the SRV_CTL_MIGRATE control type to cancel a previous migration request. In this case, paramcnt must be 0 and param must be a NULL pointer. For example:

ret = srv_send_ctlinfo(sp, SRV_CTL_MIGRATE, 0, NULL);
if (ret != CS_SUCCEED)
{
...
}

SRV_CTL_MIGRATE can be used by any thread in an Open Server application. However, a thread cancelling the migration of a client thread’s connection has different requirements than a client thread cancelling its own connection migration:

The return values of a migration cancellation are:

Return value

Description

CS_SUCCEED

The migration request was cancelled successfully.

CS_FAIL

The migration cancellation failed due to one of these reasons:

  • There is no migration in progress.

  • The client has started migrating to the new server.

NoteOpen Server does not trigger a new migrate state event when a migration request is successfully cancelled.