Skip to content
This repository has been archived by the owner on Oct 16, 2021. It is now read-only.

Commit

Permalink
Merge pull request #109 from ifakhrutdinov/high-cpu-usage-fix
Browse files Browse the repository at this point in the history
Explicitly mark message queue events on os390
  • Loading branch information
joransiu authored Oct 1, 2018
2 parents 80e37f7 + 99a42b8 commit cafb2ba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion deps/uv/src/unix/os390-syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ int epoll_ctl(uv__os390_epoll* lst,
uv_mutex_lock(&global_epoll_lock);

if (op == EPOLL_CTL_DEL) {
if (fd == lst->msg_queue) {
if (event->is_msg) {
/* The user has deleted the System V message queue. Highly likely
* because the process is being shut down. So stop listening to it.
*/
Expand Down Expand Up @@ -316,6 +316,11 @@ int epoll_wait(uv__os390_epoll* lst, struct epoll_event* events,

ev.fd = pfd->fd;
ev.events = pfd->revents;
if (i == lst->size - 1)
ev.is_msg = 1;
else
ev.is_msg = 0;

if (pfd->revents & POLLIN && pfd->revents & POLLOUT)
reventcount += 2;
else if (pfd->revents & (POLLIN | POLLOUT))
Expand Down
1 change: 1 addition & 0 deletions deps/uv/src/unix/os390-syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
struct epoll_event {
int events;
int fd;
int is_msg;
};

typedef struct {
Expand Down
6 changes: 5 additions & 1 deletion deps/uv/src/unix/os390.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,9 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
events[i].fd = -1;

/* Remove the file descriptor from the epoll. */
dummy.events = 0;
dummy.fd = fd;
dummy.is_msg = 0;
if (loop->ep != NULL)
epoll_ctl(loop->ep, UV__EPOLL_CTL_DEL, fd, &dummy);
}
Expand Down Expand Up @@ -846,6 +849,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {

e.events = w->pevents;
e.fd = w->fd;
e.is_msg = 0;

if (w->events == 0)
op = UV__EPOLL_CTL_ADD;
Expand Down Expand Up @@ -928,7 +932,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
continue;

ep = loop->ep;
if (fd == ep->msg_queue) {
if (pe->is_msg) {
if (os390_message_queue_handler(ep) == -1) {
/* The user has deleted the System V message queue. Highly likely
* because the process is being shut down. So stop listening to it.
Expand Down

0 comments on commit cafb2ba

Please sign in to comment.