Handle splice errors
authorJulien Desfossez <julien.desfossez@polymtl.ca>
Tue, 24 May 2011 14:15:47 +0000 (10:15 -0400)
committerDavid Goulet <david.goulet@polymtl.ca>
Tue, 24 May 2011 14:16:20 +0000 (10:16 -0400)
Send to the session daemon the eventual error returned by splice.

Signed-off-by: David Goulet <david.goulet@polymtl.ca>
kconsumerd/kconsumerd.c
liblttsessiondcomm/liblttsessiondcomm.c
liblttsessiondcomm/liblttsessiondcomm.h

index 7e166b8f144886dc254cf997c4753721e3350efb..a00f0793211218b58252ba2cc3c967414da3c941 100644 (file)
@@ -260,16 +260,18 @@ static int on_read_subbuffer(struct ltt_kconsumerd_fd *kconsumerd_fd,
                                SPLICE_F_MOVE | SPLICE_F_MORE);
                DBG("splice chan to pipe ret %ld", ret);
                if (ret < 0) {
+                       ret = errno;
                        perror("Error in relay splice");
-                       goto write_end;
+                       goto splice_error;
                }
 
                ret = splice(thread_pipe[0], NULL, outfd, NULL, ret,
                                SPLICE_F_MOVE | SPLICE_F_MORE);
                DBG("splice pipe to file %ld", ret);
                if (ret < 0) {
+                       ret = errno;
                        perror("Error in file splice");
-                       goto write_end;
+                       goto splice_error;
                }
                if (ret >= len) {
                        len = 0;
@@ -279,7 +281,7 @@ static int on_read_subbuffer(struct ltt_kconsumerd_fd *kconsumerd_fd,
                                SYNC_FILE_RANGE_WRITE);
                kconsumerd_fd->out_fd_offset += ret;
        }
-write_end:
+
        /*
         * This does a blocking write-and-wait on any page that belongs to the
         * subbuffer prior to the one we just wrote.
@@ -307,6 +309,26 @@ write_end:
                posix_fadvise(outfd, orig_offset - kconsumerd_fd->max_sb_size,
                                kconsumerd_fd->max_sb_size, POSIX_FADV_DONTNEED);
        }
+       goto end;
+
+splice_error:
+       /* send the appropriate error description to sessiond */
+       switch(ret) {
+               case EBADF:
+                       send_error(KCONSUMERD_SPLICE_EBADF);
+                       break;
+               case EINVAL:
+                       send_error(KCONSUMERD_SPLICE_EINVAL);
+                       break;
+               case ENOMEM:
+                       send_error(KCONSUMERD_SPLICE_ENOMEM);
+                       break;
+               case ESPIPE:
+                       send_error(KCONSUMERD_SPLICE_ESPIPE);
+                       break;
+       }
+
+end:
        return ret;
 }
 
index d754f59daee86876a1fef4e783b0a75ab62545db..19bda83883df09ddd7db9700c8c946451b93c4cc 100644 (file)
@@ -60,6 +60,10 @@ static const char *lttcomm_readable_code[] = {
        [ LTTCOMM_ERR_INDEX(KCONSUMERD_EXIT_SUCCESS) ] = "Kconsumerd exiting normally",
        [ LTTCOMM_ERR_INDEX(KCONSUMERD_EXIT_FAILURE) ] = "Kconsumerd exiting on error",
        [ LTTCOMM_ERR_INDEX(KCONSUMERD_OUTFD_ERROR) ] = "Kconsumerd error opening the tracefile",
+       [ LTTCOMM_ERR_INDEX(KCONSUMERD_SPLICE_EBADF) ] = "Kconsumerd splice EBADF",
+       [ LTTCOMM_ERR_INDEX(KCONSUMERD_SPLICE_EINVAL) ] = "Kconsumerd splice EINVAL",
+       [ LTTCOMM_ERR_INDEX(KCONSUMERD_SPLICE_ENOMEM) ] = "Kconsumerd splice ENOMEM",
+       [ LTTCOMM_ERR_INDEX(KCONSUMERD_SPLICE_ESPIPE) ] = "Kconsumerd splice ESPIPE",
        [ LTTCOMM_ERR_INDEX(LTTCOMM_NO_EVENT) ] = "No event found",
 };
 
index 8e6a862efcdc6791cb100b8d8f070e9cdbe90997..580d4c2c75381fbe30220d7d2111be7d6c753057 100644 (file)
@@ -112,6 +112,10 @@ enum lttcomm_return_code {
        KCONSUMERD_EXIT_SUCCESS,                /* kconsumerd exiting normally */
        KCONSUMERD_EXIT_FAILURE,                /* kconsumerd exiting on error */
        KCONSUMERD_OUTFD_ERROR,                 /* error opening the tracefile */
+       KCONSUMERD_SPLICE_EBADF,                /* EBADF from splice(2) */
+       KCONSUMERD_SPLICE_EINVAL,               /* EINVAL from splice(2) */
+       KCONSUMERD_SPLICE_ENOMEM,               /* ENOMEM from splice(2) */
+       KCONSUMERD_SPLICE_ESPIPE,               /* ESPIPE from splice(2) */
        /* MUST be last element */
        LTTCOMM_NR,                                             /* Last element */
 };
This page took 0.027683 seconds and 4 git commands to generate.