mirror of
https://github.com/strongswan/strongswan.git
synced 2025-10-04 00:00:14 -04:00
watcher: Make sure to re-activate the correct entry after a callback
Since the same FD may be added multiple times (e.g. with separate callbacks for WATCHER_READ and WATCHER_WRITE), the previous check might not have found the correct entry. As the entry can't be removed while in a callback, the pointer comparison is fine.
This commit is contained in:
parent
34e9cdbcac
commit
705a20619f
@ -153,6 +153,8 @@ static entry_t *remove_entry(private_watcher_t *this, entry_t *entry,
|
|||||||
* Data we pass on for an async notification
|
* Data we pass on for an async notification
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
/** triggering entry */
|
||||||
|
entry_t *entry;
|
||||||
/** file descriptor */
|
/** file descriptor */
|
||||||
int fd;
|
int fd;
|
||||||
/** event type */
|
/** event type */
|
||||||
@ -227,7 +229,7 @@ static void notify_end(notify_data_t *data)
|
|||||||
this->mutex->lock(this->mutex);
|
this->mutex->lock(this->mutex);
|
||||||
for (entry = this->fds; entry; prev = entry, entry = entry->next)
|
for (entry = this->fds; entry; prev = entry, entry = entry->next)
|
||||||
{
|
{
|
||||||
if (entry->fd == data->fd)
|
if (entry == data->entry)
|
||||||
{
|
{
|
||||||
if (!data->keep)
|
if (!data->keep)
|
||||||
{
|
{
|
||||||
@ -277,6 +279,7 @@ static void notify(private_watcher_t *this, entry_t *entry,
|
|||||||
|
|
||||||
/* get a copy of entry for async job, but with specific event */
|
/* get a copy of entry for async job, but with specific event */
|
||||||
INIT(data,
|
INIT(data,
|
||||||
|
.entry = entry,
|
||||||
.fd = entry->fd,
|
.fd = entry->fd,
|
||||||
.event = event,
|
.event = event,
|
||||||
.cb = entry->cb,
|
.cb = entry->cb,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user