bool SCI_Transporter::disconnectRemote() { DBUG_ENTER("SCI_Transporter::disconnectRemote"); sci_error_t err; for(Uint32 i=0; i<m_adapters; i++) { /** * Segment unmapped, disconnect from the remotely connected segment */ SCIUnmapSegment(m_TargetSegm[i].rhm[i].map,0,&err); if(err!=SCI_ERR_OK) { report_error(TE_SCI_UNABLE_TO_UNMAP_SEGMENT); DBUG_PRINT("error", ("Unable to unmap segment")); DBUG_RETURN(false); } SCIDisconnectSegment(m_TargetSegm[i].rhm[i].remoteHandle, FLAGS, &err); if(err!=SCI_ERR_OK) { report_error(TE_SCI_UNABLE_TO_DISCONNECT_SEGMENT); DBUG_PRINT("error", ("Unable to disconnect segment")); DBUG_RETURN(false); } DBUG_PRINT("info", ("Remote memory segment is unmapped and disconnected")); } DBUG_RETURN(true); } // disconnectRemote()
bool SCI_Transporter::disconnectLocal() { DBUG_ENTER("SCI_Transporter::disconnectLocal"); sci_error_t err; m_ActiveAdapterId=0; /** Free resources used by a local segment */ SCIUnmapSegment(m_SourceSegm[0].lhm[0].map,0,&err); if(err!=SCI_ERR_OK) { report_error(TE_SCI_UNABLE_TO_UNMAP_SEGMENT); DBUG_PRINT("error", ("Unable to unmap segment")); DBUG_RETURN(false); } SCIRemoveSegment((m_SourceSegm[m_ActiveAdapterId].localHandle), FLAGS, &err); if(err!=SCI_ERR_OK) { report_error(TE_SCI_UNABLE_TO_REMOVE_SEGMENT); DBUG_PRINT("error", ("Unable to remove segment")); DBUG_RETURN(false); } DBUG_PRINT("info", ("Local memory segment is unmapped and removed")); DBUG_RETURN(true); } // disconnectLocal()
int deconnexion_sci_client(client_t *cl) { int ret; sci_error_t retval; ret = SUCCESS; log_message("begining\n"); if (cl->remote_fin_io_interrupt != NULL) { SCIDisconnectInterrupt(cl->remote_fin_io_interrupt, NO_FLAGS, &retval); if (retval != SCI_ERR_OK) ret = ERROR; cl->remote_fin_io_interrupt = NULL; } log_message("SCIDisconnectInterrupt(cl->remote_fin_io_interrupt) done\n"); if (cl->remote_error_io_interrupt != NULL) { SCIDisconnectInterrupt(cl->remote_error_io_interrupt, NO_FLAGS, &retval); if (retval != SCI_ERR_OK) ret = ERROR; cl->remote_error_io_interrupt = NULL; } log_message("SCIDisconnectInterrupt(cl->remote_error_io_interrupt) done\n"); if (cl->remote_ready_interrupt != NULL) { SCIDisconnectInterrupt(cl->remote_ready_interrupt, NO_FLAGS, &retval); if (retval != SCI_ERR_OK) ret = ERROR; cl->remote_ready_interrupt = NULL; } log_message("SCIDisconnectInterrupt(cl->remote_ready_interrupt) done\n"); //SCIRemoveSequence(cl->seq_data_read_segment, NO_FLAGS, &retval); //if (retval != SCI_ERR_OK) ret = ERROR; if (cl->map_data_read_segment != NULL) { SCIUnmapSegment(cl->map_data_read_segment, NO_FLAGS, &retval); if (retval != SCI_ERR_OK) ret = ERROR; cl->map_data_read_segment = NULL; } log_message("SCIUnmapSegment(cl->map_data_read_segment) done\n"); if (cl->rs_data_read_segment != NULL) { SCIDisconnectSegment(cl->rs_data_read_segment, NO_FLAGS, &retval); if (retval != SCI_ERR_OK) ret = ERROR; cl->rs_data_read_segment = NULL; } log_message("CIDisconnectSegment(cl->rs_data_read_segment) done\n"); log_message("end: retval = %d",ret); return ret; }
unsigned int ShmemServerNode(void) { unsigned int *localMapAddr; /* Create a segmentId */ localSegmentId =1;// (localNodeId1 << 16) | remoteNodeId1; /* Create local segment */ SCICreateSegment(sdOne,&localSegmentOne,localSegmentId, segmentSize, NO_CALLBACK, NULL, NO_FLAGS,&error); if (error == SCI_ERR_OK) { printf("Local segment (id=%d, size=%d) is created. \n", localSegmentId, segmentSize); } else { fprintf(stderr,"SCICreateSegment failed - Error code 0x%x\n",error); return 0; } //localSegmentId = (localNodeId2 << 16) | remoteNodeId2; /* SCICreateSegment(sdTwo,&localSegmentTwo,localSegmentId+1, segmentSize, NO_CALLBACK, NULL, NO_FLAGS,&error); if (error == SCI_ERR_OK) { printf("Local segment (id=%d, size=%d) is created (2). \n", localSegmentId, segmentSize); } else { fprintf(stderr,"SCICreateSegment failed - Error code 0x%x\n",error); return 0; } printf("segment one %p segment 2 %p\n", localSegmentOne, localSegmentTwo); */ /* Prepare the segment */ SCIPrepareSegment(localSegmentOne,localAdapterNo,NO_FLAGS,&error); if (error == SCI_ERR_OK) { printf("Local segment (id=%d, size=%d) is prepared. \n", localSegmentId, segmentSize); } else { fprintf(stderr,"SCIPrepareSegment failed - Error code 0x%x\n",error); return 0; } /* Prepare the segment */ SCIPrepareSegment(localSegmentOne,standbyAdapterNo,NO_FLAGS,&error); if (error == SCI_ERR_OK) { printf("Local segment (id=%d, size=%d) is created. \n", localSegmentId, segmentSize); } else { fprintf(stderr,"SCIPrepareSegment failed - Error code 0x%x\n",error); return 0; } /* Map local segment to user space */ localMapAddr = (unsigned int *)SCIMapLocalSegment(localSegmentOne,&localMapOne, offset,segmentSize, NULL,NO_FLAGS,&error); if (error == SCI_ERR_OK) { printf("Local segment (id=0x%x) is mapped to user space @ 0x%x.\n", localSegmentId, localMapAddr); } else { fprintf(stderr,"SCIMapLocalSegment failed - Error code 0x%x\n",error); return 0; } /* Map local segment to user space */ /* localMapAddr = (unsigned int *)SCIMapLocalSegment(localSegmentTwo,&localMapTwo, offset,segmentSize, NULL,NO_FLAGS,&error); if (error == SCI_ERR_OK) { printf("Local segment (id=0x%x) is mapped to user space @ 0x%x.\n", localSegmentId, localMapAddr); printf("Local segment (id=%d) is mapped to user space.\n", localSegmentId); } else { fprintf(stderr,"SCIMapLocalSegment failed - Error code 0x%x\n",error); return 0; } */ /* Set the segment available */ SCISetSegmentAvailable(localSegmentOne, localAdapterNo, NO_FLAGS, &error); if (error == SCI_ERR_OK) { printf("Local segment (id=0x%x) is available for remote connections. \n", localSegmentId); } else { fprintf(stderr,"SCISetSegmentAvailable failed - Error code 0x%x\n",error); return 0; } SCISetSegmentAvailable(localSegmentOne, standbyAdapterNo, NO_FLAGS, &error); if (error == SCI_ERR_OK) { printf("Local segment (id=0x%x) is available for remote connections. \n", localSegmentId); } else { fprintf(stderr,"SCISetSegmentAvailable failed - Error code 0x%x\n",error); return 0; } int timeout=0; error = ReceiveInterrupt(sdOne,localAdapterNo,localNodeId1,DATA_TRANSFER_READY, timeout); if (error == SCI_ERR_OK) { printf("\nThe data transfer is ready\n"); } else { printf("\nInterrupt synchronization failed\n"); return 0; } again: // printf("Wait for the shared memory data transfer ....."); /* Wait for interrupt signal telling that block transfer is ready */ //printf("\nData transfer done!\n"); //PrintClientData() PrintServerData(localMapAddr); /*Uint32 micros; Uint32 micros2; NDB_TICKS secs; NdbTick_CurrentMicrosecond(&secs, µs); error = SendInterrupt(sdOne,localAdapterNo,localNodeId1,remoteNodeId1, DATA_TRANSFER_READY); NdbTick_CurrentMicrosecond(&secs, µs2); printf("TIME ELAPSED %d \n", micros2-micros); // NdbSleep_MilliSleep(100); */ goto again; /* Unmap local segment */ SCIUnmapSegment(localMapTwo,NO_FLAGS,&error); if (error == SCI_ERR_OK) { printf("The local segment is unmapped\n"); } else { fprintf(stderr,"SCIUnmapSegment failed - Error code 0x%x\n",error); return 0; } /* Unmap local segment */ SCIUnmapSegment(localMapOne,NO_FLAGS,&error); if (error == SCI_ERR_OK) { printf("The local segment is unmapped\n"); } else { fprintf(stderr,"SCIUnmapSegment failed - Error code 0x%x\n",error); return 0; } /* Remove local segment */ SCIRemoveSegment(localSegmentOne,NO_FLAGS,&error); if (error == SCI_ERR_OK) { printf("The local segment is removed\n"); } else { fprintf(stderr,"SCIRemoveSegment failed - Error code 0x%x\n",error); return 0; } /* Remove local segment */ SCIRemoveSegment(localSegmentTwo,NO_FLAGS,&error); if (error == SCI_ERR_OK) { printf("The local segment is removed\n"); } else { fprintf(stderr,"SCIRemoveSegment failed - Error code 0x%x\n",error); return 0; } return 1; }
unsigned int ShmemClientNode(void) { volatile unsigned int *remoteMapAddr1; volatile unsigned int *remoteMapAddr2; printf("here?\n"); /* Create a segmentId */ remoteSegmentId1 = 1;//(remoteNodeId1 << 16) | localNodeId1; /* Connect to remote segment */ printf("Connect to remote segment .... \n"); printf("segid = %d node %d \n",remoteSegmentId1, remoteNodeId1 ); do { SCIConnectSegment(sdOne, &remoteSegmentOne, remoteNodeId1, remoteSegmentId1, localAdapterNo, NO_CALLBACK, NULL, SCI_INFINITE_TIMEOUT, NO_FLAGS, &error); } while (error != SCI_ERR_OK); printf("connected\n"); // remoteSegmentId2 = (remoteNodeId2 << 16) | localNodeId2; // printf("segid = %d\n",remoteSegmentId2 ); printf("segid = %d node %d \n",remoteSegmentId1, remoteNodeId1 ); do { SCIConnectSegment(sdTwo, &remoteSegmentTwo, remoteNodeId2, remoteSegmentId1, standbyAdapterNo, NO_CALLBACK, NULL, SCI_INFINITE_TIMEOUT, NO_FLAGS, &error); } while (error != SCI_ERR_OK); printf("connected 3\n"); printf("Remote segment (id=0x%x) is connected.\n", remoteSegmentId2); /* Map remote segment to user space */ remoteMapAddr1 = (unsigned int*)SCIMapRemoteSegment(remoteSegmentOne,&remoteMapOne,offset,segmentSize,NULL,NO_FLAGS,&error); if (error == SCI_ERR_OK) { printf("Remote segment (id=0x%x) is mapped to user space @ 0x%x. \n", remoteSegmentId1, remoteMapAddr1); } else { fprintf(stderr,"SCIMapRemoteSegment failed - Error code 0x%x\n",error); return 0; } remoteMapAddr2 = (unsigned int *)SCIMapRemoteSegment(remoteSegmentTwo,&remoteMapTwo,offset,segmentSize,NULL,NO_FLAGS,&error); if (error == SCI_ERR_OK) { printf("Remote segment (id=0x%x) is mapped to user space @ 0x%x. \n", remoteSegmentId2, remoteMapAddr2); } else { fprintf(stderr,"SCIMapRemoteSegment failed - Error code 0x%x\n",error); return 0; } /* Start data transfer and error checking */ error = (sci_error_t)TransferData(remoteMapOne,remoteMapAddr1, remoteMapAddr2,segmentSize); if (error == SCI_ERR_OK) { printf("Data transfer done!\n\n"); } else { fprintf(stderr,"Data transfer failed - Error code 0x%x\n\n",error); return 0; } /* Send an interrupt to remote node telling that the data transfer is ready */ error = SendInterrupt(sdOne,localAdapterNo,localNodeId1,remoteNodeId1, DATA_TRANSFER_READY); if (error == SCI_ERR_OK) { printf("\nInterrupt message sent to remote node\n"); } else { printf("\nInterrupt synchronization failed\n"); return 0; } PrintClientData(); /* Unmap remote segment */ SCIUnmapSegment(remoteMapOne,NO_FLAGS,&error); if (error == SCI_ERR_OK) { printf("The remote segment is unmapped\n"); } else { fprintf(stderr,"SCIUnmapSegment failed - Error code 0x%x\n",error); return 0; } SCIUnmapSegment(remoteMapTwo,NO_FLAGS,&error); if (error == SCI_ERR_OK) { printf("The remote segment is unmapped\n"); } else { fprintf(stderr,"SCIUnmapSegment failed - Error code 0x%x\n",error); return 0; } /* Disconnect segment */ SCIDisconnectSegment(remoteSegmentOne,NO_FLAGS,&error); if (error == SCI_ERR_OK) { printf("The segment is disconnected\n"); } else { fprintf(stderr,"SCIDisconnectSegment failed - Error code 0x%x\n",error); return 0; } SCIDisconnectSegment(remoteSegmentTwo,NO_FLAGS,&error); if (error == SCI_ERR_OK) { printf("The segment is disconnected\n"); } else { fprintf(stderr,"SCIDisconnectSegment failed - Error code 0x%x\n",error); return 0; } return 1; }