Forráskód Böngészése

klishd ignores SIGPIPE when client close the socket

Serj Kalichev 1 éve
szülő
commit
93aa5b675d
2 módosított fájl, 6 hozzáadás és 3 törlés
  1. 3 0
      bin/klishd/klishd.c
  2. 3 3
      klish/ktp/ktpd_session.c

+ 3 - 0
bin/klishd/klishd.c

@@ -209,6 +209,8 @@ err: // For listen daemon
 	faux_eloop_add_signal(eloop, SIGINT, stop_loop_ev, NULL);
 	faux_eloop_add_signal(eloop, SIGTERM, stop_loop_ev, NULL);
 	faux_eloop_add_signal(eloop, SIGQUIT, stop_loop_ev, NULL);
+	// Ignore SIGPIPE from client
+	signal(SIGPIPE, SIG_IGN);
 	// Main service loop
 	faux_eloop_loop(eloop);
 
@@ -217,6 +219,7 @@ err_client:
 
 	ktpd_session_free(ktpd_session);
 	faux_eloop_free(eloop);
+	syslog(LOG_DEBUG, "Close connection %d", client_fd);
 	close(client_fd);
 
 	// Free scheme

+ 3 - 3
klish/ktp/ktpd_session.c

@@ -1213,7 +1213,7 @@ bool_t client_ev(faux_eloop_t *eloop, faux_eloop_type_e type,
 		if (faux_async_out(async) < 0) {
 			// Someting went wrong
 			faux_eloop_del_fd(eloop, info->fd);
-			syslog(LOG_ERR, "Problem with async output");
+			syslog(LOG_ERR, "Can't send data to client");
 			return BOOL_FALSE; // Stop event loop
 		}
 	}
@@ -1223,7 +1223,7 @@ bool_t client_ev(faux_eloop_t *eloop, faux_eloop_type_e type,
 		if (faux_async_in(async) < 0) {
 			// Someting went wrong
 			faux_eloop_del_fd(eloop, info->fd);
-			syslog(LOG_ERR, "Problem with client async input");
+			syslog(LOG_ERR, "Can't get data from client");
 			return BOOL_FALSE; // Stop event loop
 		}
 	}
@@ -1231,7 +1231,7 @@ bool_t client_ev(faux_eloop_t *eloop, faux_eloop_type_e type,
 	// EOF
 	if (info->revents & POLLHUP) {
 		faux_eloop_del_fd(eloop, info->fd);
-		syslog(LOG_DEBUG, "Close connection %d", info->fd);
+		syslog(LOG_DEBUG, "Connection %d is closed by client", info->fd);
 		return BOOL_FALSE; // Stop event loop
 	}