]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - command.c
command_util: Avoid empty output lines.
[paraslash.git] / command.c
index 7b474ab1e9337c85dfc5db7b1a997a0c81e59da0..72f8e04e7fe949c89bba065c857a0e7d9ab0820c 100644 (file)
--- a/command.c
+++ b/command.c
@@ -1100,18 +1100,24 @@ __noreturn void handle_connect(int fd, const char *peername)
        if (ret >= 0)
                goto out;
 err_out:
-       send_strerror(cc, -ret);
+       if (send_strerror(cc, -ret) >= 0 && cc->use_sideband)
+               send_sb(&cc->scc, NULL, 0, SBD_EXIT__FAILURE, true);
 net_err:
        PARA_NOTICE_LOG("%s\n", para_strerror(-ret));
 out:
        free(buf);
        free(command);
-       sc_free(cc->scc.recv);
-       sc_free(cc->scc.send);
        mutex_lock(mmd_mutex);
        if (cc->cmd && (cc->cmd->perms & AFS_WRITE) && ret >= 0)
                mmd->events++;
        mmd->active_connections--;
        mutex_unlock(mmd_mutex);
+       if (ret >= 0 && cc->use_sideband) {
+               ret = send_sb(&cc->scc, NULL, 0, SBD_EXIT__SUCCESS, true);
+               if (ret < 0)
+                       PARA_NOTICE_LOG("%s\n", para_strerror(-ret));
+       }
+       sc_free(cc->scc.recv);
+       sc_free(cc->scc.send);
        exit(ret < 0? EXIT_FAILURE : EXIT_SUCCESS);
 }