mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-06-08 18:14:53 +00:00
dm: enhence the mevent API
There is one race issue between mevent callback (which is called in mevent_dispatch thread) and mevent_delete (which could be called in dev thread). And the callback is called after mevent_delete. libevent have the exactly same issue. The issue is decripted here: https://github.com/libevent/libevent/blob/master/whatsnew-2.1.txt The fixing is: We introduce a teardown callback to mevent and make sure there is no race issue between callback and teardown call. This patch updates the mevent API and the caller as well. Tracked-On: #1877 Signed-off-by: Yin Fengwei <fengwei.yin@intel.com> Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
@@ -1017,7 +1017,7 @@ vmei_host_client_native_connect(struct vmei_host_client *hclient)
|
||||
|
||||
/* add READ event into mevent */
|
||||
hclient->rx_mevp = mevent_add(hclient->client_fd, EVF_READ,
|
||||
vmei_rx_callback, hclient);
|
||||
vmei_rx_callback, hclient, NULL, NULL);
|
||||
if (!hclient->rx_mevp)
|
||||
return MEI_HBM_REJECTED;
|
||||
|
||||
@@ -1951,7 +1951,7 @@ vmei_start(struct virtio_mei *vmei, bool do_rescan)
|
||||
|
||||
hclient->client_fd = pipefd[0];
|
||||
hclient->rx_mevp = mevent_add(hclient->client_fd, EVF_READ,
|
||||
vmei_rx_callback, hclient);
|
||||
vmei_rx_callback, hclient, NULL, NULL);
|
||||
vmei->hbm_fd = pipefd[1];
|
||||
|
||||
if (do_rescan) {
|
||||
@@ -2051,7 +2051,7 @@ static int vmei_add_reset_event(struct virtio_mei *vmei)
|
||||
|
||||
vmei->dev_state_first = true;
|
||||
vmei->reset_mevp = mevent_add(dev_state_fd, EVF_READ_ET,
|
||||
vmei_reset_callback, vmei);
|
||||
vmei_reset_callback, vmei, NULL, NULL);
|
||||
if (!vmei->reset_mevp) {
|
||||
close(dev_state_fd);
|
||||
return -ENOMEM;
|
||||
|
||||
Reference in New Issue
Block a user