]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - client_common.c
Pass command exit status via sideband to client.
[paraslash.git] / client_common.c
index daead879faa7f4dff4d9016c68f95426269551f0..649a1b4fdf49579e653d7b6cd6d9c977524e6171 100644 (file)
@@ -242,14 +242,19 @@ static char **parse_features(char *buf)
 
 static int dispatch_sbb(struct client_task *ct, struct sb_buffer *sbb)
 {
 
 static int dispatch_sbb(struct client_task *ct, struct sb_buffer *sbb)
 {
-       int ret, ll;
+       int ret;
+       const char *designator[] = {SB_DESIGNATORS_ARRAY};
 
 
-       if (!sbb || !sbb->iov.iov_base || sbb->iov.iov_len == 0)
+       if (!sbb)
                return 0;
                return 0;
+       if (sbb->band < NUM_SB_DESIGNATORS)
+               PARA_DEBUG_LOG("band: %s\n", designator[sbb->band]);
 
        switch (sbb->band) {
        case SBD_OUTPUT:
 
        switch (sbb->band) {
        case SBD_OUTPUT:
-               btr_add_output(sbb->iov.iov_base, sbb->iov.iov_len, ct->btrn);
+               if (iov_valid(&sbb->iov))
+                       btr_add_output(sbb->iov.iov_base, sbb->iov.iov_len,
+                               ct->btrn);
                ret = 1;
                goto out;
        case SBD_DEBUG_LOG:
                ret = 1;
                goto out;
        case SBD_DEBUG_LOG:
@@ -259,10 +264,18 @@ static int dispatch_sbb(struct client_task *ct, struct sb_buffer *sbb)
        case SBD_ERROR_LOG:
        case SBD_CRIT_LOG:
        case SBD_EMERG_LOG:
        case SBD_ERROR_LOG:
        case SBD_CRIT_LOG:
        case SBD_EMERG_LOG:
-               ll = sbb->band - SBD_DEBUG_LOG;
-               para_log(ll, "remote: %s", (char *)sbb->iov.iov_base);
+               if (iov_valid(&sbb->iov)) {
+                       int ll = sbb->band - SBD_DEBUG_LOG;
+                       para_log(ll, "remote: %s", (char *)sbb->iov.iov_base);
+               }
                ret = 1;
                goto deallocate;
                ret = 1;
                goto deallocate;
+       case SBD_EXIT__SUCCESS:
+               ret = -E_SERVER_CMD_SUCCESS;
+               goto deallocate;
+       case SBD_EXIT__FAILURE:
+               ret = -E_SERVER_CMD_FAILURE;
+               goto deallocate;
        default:
                PARA_ERROR_LOG("invalid band %d\n", sbb->band);
                ret = -E_BAD_BAND;
        default:
                PARA_ERROR_LOG("invalid band %d\n", sbb->band);
                ret = -E_BAD_BAND;
@@ -546,7 +559,8 @@ static void client_post_select(struct sched *s, struct task *t)
 out:
        t->error = ret;
        if (ret < 0) {
 out:
        t->error = ret;
        if (ret < 0) {
-               if (ret != -E_SERVER_EOF && ret != -E_BTR_EOF && ret != -E_EOF)
+               if (!ct->use_sideband && ret != -E_SERVER_EOF &&
+                               ret != -E_BTR_EOF && ret != -E_EOF)
                        PARA_ERROR_LOG("%s\n", para_strerror(-t->error));
                btr_remove_node(btrn);
        }
                        PARA_ERROR_LOG("%s\n", para_strerror(-t->error));
                btr_remove_node(btrn);
        }