Browse Source

MT#55283 call del_item callback even on failure

Relevant during shutdown. Make sure all late_port_release objects are
still appended to the global queue.

Change-Id: I8aa6c2a8ddabdf7296a6934e51ce420c5587ac53
(cherry picked from commit 89313ed074)
mr13.4
Richard Fuchs 4 months ago
parent
commit
8f0efbf10e
1 changed files with 10 additions and 6 deletions
  1. +10
    -6
      lib/poller.c

+ 10
- 6
lib/poller.c View File

@ -141,23 +141,24 @@ bool poller_add_item(struct poller *p, struct poller_item *i) {
bool poller_del_item_callback(struct poller *p, int fd, void (*callback)(void *), void *arg) { bool poller_del_item_callback(struct poller *p, int fd, void (*callback)(void *), void *arg) {
struct poller_item_int *it; struct poller_item_int *it;
bool ret = false;
if (!p || fd < 0) if (!p || fd < 0)
return false;
goto out;
{ {
LOCK(&p->lock); LOCK(&p->lock);
if (!p->items) // can happen during shutdown/free only if (!p->items) // can happen during shutdown/free only
return false;
goto out;
if (fd >= p->items->len) if (fd >= p->items->len)
return false;
goto out;
if (!(it = p->items->pdata[fd])) if (!(it = p->items->pdata[fd]))
return false;
goto out;
if (epoll_ctl(p->fd, EPOLL_CTL_DEL, fd, NULL)) if (epoll_ctl(p->fd, EPOLL_CTL_DEL, fd, NULL))
return false;
goto out;
p->items->pdata[fd] = NULL; /* stealing the ref */ p->items->pdata[fd] = NULL; /* stealing the ref */
@ -165,12 +166,15 @@ bool poller_del_item_callback(struct poller *p, int fd, void (*callback)(void *)
obj_put(it); obj_put(it);
ret = true;
out:
if (callback) if (callback)
callback(arg); callback(arg);
else else
close(fd); close(fd);
return true;
return ret;
} }
bool poller_del_item(struct poller *p, int fd) { bool poller_del_item(struct poller *p, int fd) {
return poller_del_item_callback(p, fd, NULL, NULL); return poller_del_item_callback(p, fd, NULL, NULL);


Loading…
Cancel
Save