iscsi initiator: remove the deleted variable.
I do not think that this variable is needed. The rpc system will be always executed in the first call, so there is no sync issue, add a deleted variable and put the free in the loop sounds not very clear. For the ASAN issue (use req after free), I think that the correct solution is that: we should store the context first instead of defer the free of req. Change-Id: I49ca2708ddc2c5533bb3a0aee4622ae23bfe47c6 Signed-off-by: Ziye Yang <optimistyzy@gmail.com> Reviewed-on: https://review.gerrithub.io/414726 Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
parent
7efc7b8302
commit
4f47c066c9
@ -100,7 +100,6 @@ struct bdev_iscsi_conn_req {
|
||||
spdk_bdev_iscsi_create_cb create_cb;
|
||||
spdk_bdev_iscsi_create_cb create_cb_arg;
|
||||
TAILQ_ENTRY(bdev_iscsi_conn_req) link;
|
||||
bool deleted;
|
||||
};
|
||||
|
||||
static int
|
||||
@ -537,7 +536,7 @@ complete_conn_req(struct bdev_iscsi_conn_req *req, struct spdk_bdev *bdev,
|
||||
{
|
||||
TAILQ_REMOVE(&g_iscsi_conn_req, req, link);
|
||||
req->create_cb(req->create_cb_arg, bdev, status);
|
||||
req->deleted = true;
|
||||
free(req);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -646,10 +645,12 @@ iscsi_bdev_conn_poll(void *arg)
|
||||
{
|
||||
struct bdev_iscsi_conn_req *req, *tmp;
|
||||
struct pollfd pfd;
|
||||
struct iscsi_context *context;
|
||||
|
||||
TAILQ_FOREACH_SAFE(req, &g_iscsi_conn_req, link, tmp) {
|
||||
pfd.fd = iscsi_get_fd(req->context);
|
||||
pfd.events = iscsi_which_events(req->context);
|
||||
context = req->context;
|
||||
pfd.fd = iscsi_get_fd(context);
|
||||
pfd.events = iscsi_which_events(context);
|
||||
pfd.revents = 0;
|
||||
if (poll(&pfd, 1, 0) < 0) {
|
||||
SPDK_ERRLOG("poll failed\n");
|
||||
@ -657,14 +658,10 @@ iscsi_bdev_conn_poll(void *arg)
|
||||
}
|
||||
|
||||
if (pfd.revents != 0) {
|
||||
if (iscsi_service(req->context, pfd.revents) < 0) {
|
||||
SPDK_ERRLOG("iscsi_service failed: %s\n", iscsi_get_error(req->context));
|
||||
if (iscsi_service(context, pfd.revents) < 0) {
|
||||
SPDK_ERRLOG("iscsi_service failed: %s\n", iscsi_get_error(context));
|
||||
}
|
||||
}
|
||||
|
||||
if (req->deleted) {
|
||||
free(req);
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user