Skip to contentSkip to conversation

mcstrans: continue on failed accept() or add_pollfd() calls

PATCH In review Stephen Smalley 1 participant 2 messages May 27 SELinux security module

lore
Share & tools
lore

Stephen Smalley

author maintainer
#0 lore raw

PATCH 1/1 mcstrans: continue on failed accept() or add_pollfd() calls

Don't exit on failed accept() or add_pollfd() calls and close the fd if we couldn't add it to the poll set.

---
 mcstrans/src/mcstransd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
mcstrans/src/mcstransd.c +3 -2
index 42262e58..bda580d4 100644
@@ -307,14 +307,15 @@ process_events(struct pollfd **ufds, int *nfds)
 				/* Probably received a connection */
 				if ((connfd = accept(sockfd, NULL, NULL)) < 0) {
 					syslog(LOG_ERR, "accept() failed: %m");
-					return -1;
+					continue;
 				}
 
 				if (add_pollfd(ufds, nfds, connfd)) {
 					syslog(LOG_ERR,
 					  "Failed to add fd (%d) to poll list\n",
 						connfd);
-					return -1;
+					close(connfd);
+					continue;
 				}
 			} else {
 				ret = service_request(connfd);
Signature · 1 line
2.54.0
author maintainer
#1 lore raw
Quoted 5 lines · Stephen Smalley

Don't exit on failed accept() or add_pollfd() calls and close the fd if we couldn't add it to the poll set.

Merged.

Quoted 29 lines
---
 mcstrans/src/mcstransd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
mcstrans/src/mcstransd.c +3 -3
index 42262e58..bda580d4 100644
@@ -307,14 +307,15 @@ process_events(struct pollfd **ufds, int *nfds)
                                /* Probably received a connection */
                                if ((connfd = accept(sockfd, NULL, NULL)) < 0) {
                                        syslog(LOG_ERR, "accept() failed: %m");
-                                       return -1;
+                                       continue;
                                }
 
                                if (add_pollfd(ufds, nfds, connfd)) {
                                        syslog(LOG_ERR,
                                          "Failed to add fd (%d) to poll list\n",
                                                connfd);
-                                       return -1;
+                                       close(connfd);
+                                       continue;
                                }
                        } else {
                                ret = service_request(connfd);
--

2.54.0