poll: Rename lock to lock_cnt and make it unsigned
Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Этот коммит содержится в:
родитель
30b5a2e33b
Коммит
2ed0525f40
10
src/poll.c
10
src/poll.c
@ -68,7 +68,7 @@ struct ssh_poll_handle_struct {
|
|||||||
size_t idx;
|
size_t idx;
|
||||||
} x;
|
} x;
|
||||||
short events;
|
short events;
|
||||||
int lock;
|
uint32_t lock_cnt;
|
||||||
ssh_poll_callback cb;
|
ssh_poll_callback cb;
|
||||||
void *cb_data;
|
void *cb_data;
|
||||||
};
|
};
|
||||||
@ -422,7 +422,7 @@ void ssh_poll_set_events(ssh_poll_handle p, short events)
|
|||||||
{
|
{
|
||||||
p->events = events;
|
p->events = events;
|
||||||
if (p->ctx != NULL) {
|
if (p->ctx != NULL) {
|
||||||
if (!p->lock) {
|
if (p->lock_cnt == 0) {
|
||||||
p->ctx->pollfds[p->x.idx].events = events;
|
p->ctx->pollfds[p->x.idx].events = events;
|
||||||
} else if (!(p->ctx->pollfds[p->x.idx].events & POLLOUT)) {
|
} else if (!(p->ctx->pollfds[p->x.idx].events & POLLOUT)) {
|
||||||
/* if locked, allow only setting POLLOUT to prevent recursive
|
/* if locked, allow only setting POLLOUT to prevent recursive
|
||||||
@ -703,7 +703,7 @@ int ssh_poll_ctx_dopoll(ssh_poll_ctx ctx, int timeout)
|
|||||||
* output buffer */
|
* output buffer */
|
||||||
for (i = 0; i < ctx->polls_used; i++) {
|
for (i = 0; i < ctx->polls_used; i++) {
|
||||||
/* The lock prevents invoking POLLIN events: drop them now */
|
/* The lock prevents invoking POLLIN events: drop them now */
|
||||||
if (ctx->pollptrs[i]->lock) {
|
if (ctx->pollptrs[i]->lock_cnt > 0) {
|
||||||
ctx->pollfds[i].events &= ~POLLIN;
|
ctx->pollfds[i].events &= ~POLLIN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -732,7 +732,7 @@ int ssh_poll_ctx_dopoll(ssh_poll_ctx ctx, int timeout)
|
|||||||
revents = ctx->pollfds[i].revents;
|
revents = ctx->pollfds[i].revents;
|
||||||
/* avoid having any event caught during callback */
|
/* avoid having any event caught during callback */
|
||||||
ctx->pollfds[i].events = 0;
|
ctx->pollfds[i].events = 0;
|
||||||
p->lock++;
|
p->lock_cnt++;
|
||||||
if (p->cb && (ret = p->cb(p, fd, revents, p->cb_data)) < 0) {
|
if (p->cb && (ret = p->cb(p, fd, revents, p->cb_data)) < 0) {
|
||||||
if (ret == -2) {
|
if (ret == -2) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -743,7 +743,7 @@ int ssh_poll_ctx_dopoll(ssh_poll_ctx ctx, int timeout)
|
|||||||
} else {
|
} else {
|
||||||
ctx->pollfds[i].revents = 0;
|
ctx->pollfds[i].revents = 0;
|
||||||
ctx->pollfds[i].events = p->events;
|
ctx->pollfds[i].events = p->events;
|
||||||
p->lock--;
|
p->lock_cnt--;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user