Skip to content

Commit

Permalink
attempt to fix emperor messaging on smartos/omnios
Browse files Browse the repository at this point in the history
  • Loading branch information
unbit committed Aug 26, 2014
1 parent 56fedbd commit 13df278
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
16 changes: 16 additions & 0 deletions core/emperor.c
Original file line number Diff line number Diff line change
Expand Up @@ -2325,7 +2325,17 @@ void uwsgi_emperor_simple_do(struct uwsgi_emperor_scanner *ues, char *name, char

void uwsgi_master_manage_emperor() {
char byte;
#ifdef UWSGI_EVENT_USE_PORT
// special cose for port event system
// place the socket in non-blocking mode
uwsgi_socket_nb(uwsgi.emperor_fd);
#endif
ssize_t rlen = read(uwsgi.emperor_fd, &byte, 1);
#ifdef UWSGI_EVENT_USE_PORT
// special cose for port event system
// and place back in blocking mode
uwsgi_socket_b(uwsgi.emperor_fd);
#endif
if (rlen > 0) {
uwsgi_log_verbose("received message %d from emperor\n", byte);
// remove me
Expand All @@ -2345,6 +2355,12 @@ void uwsgi_master_manage_emperor() {
uwsgi_unblock_signal(SIGHUP);
}
}
#ifdef UWSGI_EVENT_USE_PORT
// special cose for port event system
else if (rlen < 0 && uwsgi_is_again()) {
return;
}
#endif
else {
uwsgi_error("uwsgi_master_manage_emperor()/read()");
uwsgi_log("lost connection with my emperor !!!\n");
Expand Down
11 changes: 6 additions & 5 deletions core/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,11 @@ int event_queue_wait_multi(int eq, int timeout, void *events, int nevents) {
}

if (ret < 0) {
if (errno != ETIME) {
uwsgi_error("port_getn()");
return -1;
}
return 0;
if (errno == ETIME) return 0;
if (errno != EINTR) {
uwsgi_error("port_getn()");
}
return -1;
}

uint_t i;
Expand Down Expand Up @@ -452,6 +452,7 @@ int event_queue_wait(int eq, int timeout, int *interesting_fd) {
else {
ret = port_get(eq, &pe, NULL);
}

if (ret < 0) {
if (errno == ETIME) return 0;
if (errno != EINTR) {
Expand Down

0 comments on commit 13df278

Please sign in to comment.