/* * Perform a normal session logout */ void iSCSILibWrapper::iSCSINormalLogout(void) { // Remove us from the background thread iSCSIBackGround::GetInstance().RemoveConnection(*this); if (!mClient.connected || mClient.error) { if (mClient.error) mErrorString.Format("%s: previous error prevents logout from target %s: %s", __func__, mTarget.c_str(), iscsi_get_error(mIscsi)); else mErrorString.Format("%s: Logout from target %s not possible without a connection!", __func__, mTarget.c_str()); mError = true; throw CException(mErrorString); } mClient.finished = 0; if (iscsi_logout_async(mIscsi, discoverylogout_cb, this)) { mErrorString.Format("%s: Logout from target %s failed: %s", __func__, mTarget.c_str(), iscsi_get_error(mIscsi)); mError = true; throw CException(mErrorString); } ServiceISCSIEvents(); // Add to the background task iSCSIBackGround::GetInstance().AddConnection(*this); }
/* * Perform a logout from a discovery session */ void iSCSILibWrapper::iSCSIDiscoveryLogout(void) { // Remove us from the background thread iSCSIBackGround::GetInstance().RemoveConnection(*this); mClient.finished = 0; if (iscsi_logout_async(mIscsi, discoverylogout_cb, this)) { mErrorString.Format("%s: Logout failed for target %s: %s", __func__, mTarget.c_str(), iscsi_get_error(mIscsi)); mError = true; throw CException(mErrorString); } ServiceISCSIEvents(); // Add to the background task iSCSIBackGround::GetInstance().AddConnection(*this); }
void discovery_cb(struct iscsi_context *iscsi, int status, void *command_data, void *private_data) { struct client_state *clnt = (struct client_state *)private_data; struct iscsi_discovery_address *addr; printf("discovery callback status:%04x\n", status); for(addr=command_data; addr; addr=addr->next) { printf("Target:%s Address:%s\n", addr->target_name, addr->target_address); } addr=command_data; clnt->has_discovered_target = 1; clnt->target_name = strdup(addr->target_name); clnt->target_address = strdup(addr->target_address); printf("discovery complete, send logout command\n"); if (iscsi_logout_async(iscsi, discoverylogout_cb, private_data) != 0) { printf("iscsi_logout_async failed\n"); exit(10); } }