Commit 257db81c authored by Yoni Fogel's avatar Yoni Fogel

Closes #1321

Remove locks around pread (pread in windows is now thread safe)

git-svn-id: file:///svn/toku/tokudb@8740 c7de825b-a66e-492c-adef-691d508d4ae1
parent 117eacc0
......@@ -362,9 +362,7 @@ int toku_deserialize_brtnode_from (int fd, BLOCKNUM blocknum, u_int32_t fullhash
u_int32_t uncompressed_size;
{
// get the compressed size
lock_for_pwrite();
r = pread(fd, uncompressed_header, sizeof(uncompressed_header), offset);
unlock_for_pwrite();
//printf("%s:%d r=%d the datasize=%d\n", __FILE__, __LINE__, r, toku_ntohl(datasize_n));
if (r!=(int)sizeof(uncompressed_header)) {
if (r==-1) r=errno;
......@@ -384,9 +382,7 @@ int toku_deserialize_brtnode_from (int fd, BLOCKNUM blocknum, u_int32_t fullhash
assert(compressed_data);
{
lock_for_pwrite();
ssize_t rlen=pread(fd, compressed_data, compressed_size, offset+uncompressed_magic_len + compression_header_len);
unlock_for_pwrite();
//printf("%s:%d pread->%d offset=%ld datasize=%d\n", __FILE__, __LINE__, r, offset, compressed_size + uncompressed_magic_len + compression_header_len);
assert((size_t)rlen==compressed_size);
//printf("Got %d %d %d %d\n", rc.buf[0], rc.buf[1], rc.buf[2], rc.buf[3]);
......@@ -750,9 +746,7 @@ deserialize_brtheader (u_int32_t size, int fd, DISKOFF off, struct brt_header **
if (rc.size<=0) { ret = EINVAL; goto died1; }
rc.ndone = 0;
{
lock_for_pwrite();
ssize_t r = pread(fd, rc.buf, size-12, off+12);
unlock_for_pwrite();
if (r!=(ssize_t)size-12) { ret = EINVAL; goto died1; }
}
h->dirty=0;
......@@ -850,9 +844,7 @@ int toku_deserialize_brtheader_from (int fd, BLOCKNUM blocknum, struct brt_heade
//printf("%s:%d malloced %p\n", __FILE__, __LINE__, h);
char magic[12];
lock_for_pwrite();
ssize_t r = pread(fd, magic, 12, offset);
unlock_for_pwrite();
if (r==0) return -1;
if (r<0) return errno;
if (r!=12) return EINVAL;
......@@ -924,9 +916,7 @@ int toku_serialize_fifo_at (int fd, toku_off_t freeoff, FIFO fifo) {
static int
read_int (int fd, toku_off_t *at, u_int32_t *result) {
int v;
lock_for_pwrite();
ssize_t r = pread(fd, &v, 4, *at);
unlock_for_pwrite();
if (r<0) return errno;
assert(r==4);
*result = toku_ntohl(v);
......@@ -936,9 +926,7 @@ read_int (int fd, toku_off_t *at, u_int32_t *result) {
static int
read_char (int fd, toku_off_t *at, char *result) {
lock_for_pwrite();
ssize_t r = pread(fd, result, 1, *at);
unlock_for_pwrite();
if (r<0) return errno;
assert(r==1);
(*at)++;
......@@ -959,9 +947,7 @@ static int
read_nbytes (int fd, toku_off_t *at, char **data, u_int32_t len) {
char *result = toku_malloc(len);
if (result==0) return errno;
lock_for_pwrite();
ssize_t r = pread(fd, result, len, *at);
unlock_for_pwrite();
//printf("%s:%d read %d bytes at %" PRId64 ", which are %s\n", __FILE__, __LINE__, len, *at, result);
if (r<0) return errno;
assert(r==(ssize_t)len);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment