[MINOR] stream_sock: don't dereference a non-existing frontend
The stream_sock accept() can be used without any frontend. Check
everywhere if it exists before dereferencing it in the error path.
diff --git a/src/stream_sock.c b/src/stream_sock.c
index 9159796..93e3daf 100644
--- a/src/stream_sock.c
+++ b/src/stream_sock.c
@@ -1156,20 +1156,23 @@
case ECONNABORTED:
return 0; /* nothing more to accept */
case ENFILE:
- send_log(p, LOG_EMERG,
- "Proxy %s reached system FD limit at %d. Please check system tunables.\n",
- p->id, maxfd);
+ if (p)
+ send_log(p, LOG_EMERG,
+ "Proxy %s reached system FD limit at %d. Please check system tunables.\n",
+ p->id, maxfd);
return 0;
case EMFILE:
- send_log(p, LOG_EMERG,
- "Proxy %s reached process FD limit at %d. Please check 'ulimit-n' and restart.\n",
- p->id, maxfd);
+ if (p)
+ send_log(p, LOG_EMERG,
+ "Proxy %s reached process FD limit at %d. Please check 'ulimit-n' and restart.\n",
+ p->id, maxfd);
return 0;
case ENOBUFS:
case ENOMEM:
- send_log(p, LOG_EMERG,
- "Proxy %s reached system memory limit at %d sockets. Please check system tunables.\n",
- p->id, maxfd);
+ if (p)
+ send_log(p, LOG_EMERG,
+ "Proxy %s reached system memory limit at %d sockets. Please check system tunables.\n",
+ p->id, maxfd);
return 0;
default:
return 0;
@@ -1184,8 +1187,10 @@
ret = l->accept(l, cfd, &addr);
if (unlikely(ret < 0)) {
/* critical error encountered, generally a resource shortage */
- EV_FD_CLR(fd, DIR_RD);
- p->state = PR_STIDLE;
+ if (p) {
+ EV_FD_CLR(fd, DIR_RD);
+ p->state = PR_STIDLE;
+ }
goto out_close;
}
else if (unlikely(ret == 0)) {