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:
|
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:
Any Open Server thread can cancel a migration, however, the cancellation must be requested before the SRV_MIGRATE_STATE event handler informs the client thread that the client is ready to migrate.
The client thread can cancel a migration even inside the SRV_MIGRATE_STATE event handler. However, the client thread cannot cancel a migration after it exits the SRV_MIGRATE_STATE event with a SRV_MIG_READY state.
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:
|
Open Server does not trigger a new migrate state event
when a migration request is successfully cancelled.