Browse Source

Handle epoll hangups in userproxy_recv even if epollin is set, but after reading any data available, and do not skip processing if proxy is not marked alive yet.

master
Con Kolivas 8 years ago
parent
commit
510e130490
  1. 43
      src/generator.c

43
src/generator.c

@ -2187,13 +2187,6 @@ static void *userproxy_recv(void *arg)
if (unlikely(!proxy->authorised)) if (unlikely(!proxy->authorised))
continue; continue;
if ((event.events & (EPOLLHUP | EPOLLERR | EPOLLRDHUP)) &&
!(event.events & EPOLLIN)) {
LOGNOTICE("Proxy %d:%d %s hung up in epoll_wait", proxy->id,
proxy->subid, proxy->url);
disable_subproxy(gdata, proxy->parent, proxy);
continue;
}
now = time(NULL); now = time(NULL);
mutex_lock(&gdata->notify_lock); mutex_lock(&gdata->notify_lock);
@ -2219,23 +2212,35 @@ static void *userproxy_recv(void *arg)
timeout = 0; timeout = 0;
cs = &proxy->cs; cs = &proxy->cs;
#if 0
/* Is this needed at all? */
if (!proxy->alive) if (!proxy->alive)
continue; continue;
#endif
cksem_wait(&cs->sem); if (likely(event.events & EPOLLIN)) {
while ((ret = read_socket_line(cs, &timeout)) > 0) { cksem_wait(&cs->sem);
/* proxy may have been recycled here if it is not a while ((ret = read_socket_line(cs, &timeout)) > 0) {
* parent and reconnect was issued */ timeout = 0;
if (parse_method(ckp, proxy, cs->buf)) /* proxy may have been recycled here if it is not a
continue; * parent and reconnect was issued */
/* If it's not a method it should be a share result */ if (parse_method(ckp, proxy, cs->buf))
if (!parse_share(gdata, proxy, cs->buf)) { continue;
LOGNOTICE("Proxy %d:%d unhandled stratum message: %s", /* If it's not a method it should be a share result */
proxy->id, proxy->subid, cs->buf); if (!parse_share(gdata, proxy, cs->buf)) {
LOGNOTICE("Proxy %d:%d unhandled stratum message: %s",
proxy->id, proxy->subid, cs->buf);
}
} }
timeout = 0; cksem_post(&cs->sem);
}
if ((event.events & (EPOLLHUP | EPOLLERR | EPOLLRDHUP))) {
LOGNOTICE("Proxy %d:%d %s hung up in epoll_wait", proxy->id,
proxy->subid, proxy->url);
disable_subproxy(gdata, proxy->parent, proxy);
continue;
} }
cksem_post(&cs->sem);
} }
return NULL; return NULL;
} }

Loading…
Cancel
Save