X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttd%2Flttd.c;h=3a2fdd3f5bec004318a651d2941d3c91f490ac67;hb=db9d75c08a1d635cac6520252ce86047f815c98b;hp=02724ce5285f6d10bdedfff992510f2a6b0dd93b;hpb=86a65fdbbfe799d8a31d1fcfa6774ce9366054d4;p=lttv.git diff --git a/ltt/branches/poly/lttd/lttd.c b/ltt/branches/poly/lttd/lttd.c index 02724ce5..3a2fdd3f 100644 --- a/ltt/branches/poly/lttd/lttd.c +++ b/ltt/branches/poly/lttd/lttd.c @@ -35,7 +35,7 @@ /* Get the next sub buffer that can be read. */ #define RELAYFS_GET_SUBBUF _IOR(0xF4, 0x00,__u32) /* Release the oldest reserved (by "get") sub buffer. */ -#define RELAYFS_PUT_SUBBUF _IO(0xF4, 0x01) +#define RELAYFS_PUT_SUBBUF _IOW(0xF4, 0x01,__u32) /* returns the number of sub buffers in the per cpu channel. */ #define RELAYFS_GET_N_SUBBUFS _IOR(0xF4, 0x02,__u32) /* returns the size of the sub buffers. */ @@ -297,13 +297,13 @@ end: int read_subbuffer(struct fd_pair *pair) { - unsigned int subbuf_index; + unsigned int consumed_old; int err, ret; err = ioctl(pair->channel, RELAYFS_GET_SUBBUF, - &subbuf_index); - printf("index : %u\n", subbuf_index); + &consumed_old); + printf("cookie : %u\n", consumed_old); if(err != 0) { perror("Error in reserving sub buffer"); ret = -EPERM; @@ -311,7 +311,7 @@ int read_subbuffer(struct fd_pair *pair) } err = TEMP_FAILURE_RETRY(write(pair->trace, - pair->mmap + (subbuf_index * pair->subbuf_size), + pair->mmap + (consumed_old & (~(pair->subbuf_size-1))), pair->subbuf_size)); if(err < 0) { @@ -322,10 +322,16 @@ int read_subbuffer(struct fd_pair *pair) write_error: - err = ioctl(pair->channel, RELAYFS_PUT_SUBBUF); + err = ioctl(pair->channel, RELAYFS_PUT_SUBBUF, &consumed_old); if(err != 0) { - perror("Error in unreserving sub buffer"); - ret = -EPERM; + if(errno == -EFAULT) { + perror("Error in unreserving sub buffer"); + ret = -EFAULT; + } else if(errno == -EIO) { + perror("Reader has been pushed by the writer, last subbuffer corrupted."); + /* FIXME : we may delete the last written buffer if we wish. */ + ret = -EIO; + } goto get_error; }