Преглед на файлове

Fix SIGPIPE in client and ktpd when scheme is empty

Serj Kalichev преди 1 година
родител
ревизия
84531cf59c
променени са 3 файла, в които са добавени 7 реда и са изтрити 2 реда
  1. 3 0
      bin/klish/klish.c
  2. 0 1
      bin/klishd/klishd.c
  3. 4 1
      klish/ktp/ktpd_session.c

+ 3 - 0
bin/klish/klish.c

@@ -99,6 +99,9 @@ int main(int argc, char **argv)
 	ktp_session_set_cb(ktp, KTP_SESSION_CB_STDOUT, stdout_cb, NULL);
 	ktp_session_set_cb(ktp, KTP_SESSION_CB_STDERR, stderr_cb, NULL);
 
+	// Ignore SIGPIPE from server
+	signal(SIGPIPE, SIG_IGN);
+
 	// Commands from cmdline
 	if (faux_list_len(opts->commands) > 0) {
 		const char *line = NULL;

+ 0 - 1
bin/klishd/klishd.c

@@ -197,7 +197,6 @@ err: // For listen daemon
 	// Create KTP session
 	// Function ktpd_session_new() will add new events to eloop itself.
 	ktpd_session = ktpd_session_new(client_fd, scheme, NULL, eloop);
-	assert(ktpd_session);
 	if (!ktpd_session) {
 		syslog(LOG_ERR, "Can't create KTPd session\n");
 		goto err_client;

+ 4 - 1
klish/ktp/ktpd_session.c

@@ -82,7 +82,10 @@ ktpd_session_t *ktpd_session_new(int sock, kscheme_t *scheme,
 	ktpd->state = KTPD_SESSION_STATE_IDLE;
 	ktpd->eloop = eloop;
 	ktpd->session = ksession_new(scheme, start_entry);
-	assert(ktpd->session);
+	if (!ktpd->session) {
+		faux_free(ktpd);
+		return NULL;
+	}
 	ktpd->exec = NULL;
 	// Exit flag. It differs from ksession done flag because KTPD session
 	// can't exit immediately. It must finish current command processing