Skip to content

Commit

Permalink
Add finish nni_list in struct nng_aio
Browse files Browse the repository at this point in the history
1. Add finish nni_list in struct nng_aio.
2. Use a_finish_node to store finished aio in function sub0_recv_cb, thus separated from sub0_ctx recv_queue.
  • Loading branch information
willwu1217 committed Oct 25, 2023
1 parent a373f85 commit 436e217
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/core/aio.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ struct nng_aio {
nni_aio_expire_q *a_expire_q;
nni_list_node a_expire_node; // Expiration node
nni_reap_node a_reap_node;
nni_list_node a_finish_node; // Finished node
};

#endif // CORE_AIO_H
4 changes: 2 additions & 2 deletions src/sp/protocol/pubsub0/sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ sub0_recv_cb(void *arg)
return;
}

nni_aio_list_init(&finish);
NNI_LIST_INIT(&finish, nng_aio, a_finish_node);

msg = nni_aio_get_msg(&p->aio_recv);
nni_aio_set_msg(&p->aio_recv, NULL);
Expand Down Expand Up @@ -388,6 +388,7 @@ sub0_recv_cb(void *arg)
nni_pollable_raise(&sock->readable);
}
}
nni_mtx_unlock(&sock->lk);

// NB: This is slightly less efficient in that we may have
// created an extra copy in the face of e.g. two subscriptions,
Expand All @@ -404,7 +405,6 @@ sub0_recv_cb(void *arg)
nni_list_remove(&finish, aio);
nni_aio_finish_sync(aio, 0, len);
}
nni_mtx_unlock(&sock->lk);

nni_pipe_recv(p->pipe, &p->aio_recv);
}
Expand Down

0 comments on commit 436e217

Please sign in to comment.