version 1.9, 2019/02/16 16:58:39 |
version 1.10, 2019/02/16 16:59:34 |
|
|
/* Validate the index. */ |
/* Validate the index. */ |
|
|
if (idx < 0 || (uint32_t)idx >= flsz) { |
if (idx < 0 || (uint32_t)idx >= flsz) { |
ERRX(sess, "file index out of bounds: invalid %" |
ERRX(sess, "file index out of bounds: invalid %" |
PRId32 " out of %zu", idx, flsz); |
PRId32 " out of %zu", idx, flsz); |
return 0; |
return 0; |
} else if (S_ISDIR(fl[idx].st.mode)) { |
} else if (S_ISDIR(fl[idx].st.mode)) { |
|
|
s->blks = NULL; |
s->blks = NULL; |
TAILQ_INSERT_TAIL(q, s, entries); |
TAILQ_INSERT_TAIL(q, s, entries); |
|
|
/* |
/* |
* This blocks til the full blockset has been read. |
* This blocks til the full blockset has been read. |
* That's ok, because the most important thing is getting data |
* That's ok, because the most important thing is getting data |
* off the wire. |
* off the wire. |
|
|
} |
} |
} |
} |
|
|
/* |
/* |
* Set up our poll events. |
* Set up our poll events. |
* We start by polling only in receiver requests, enabling other |
* We start by polling only in receiver requests, enabling other |
* poll events on demand. |
* poll events on demand. |
|
|
if (!io_read_int(sess, fdin, &idx)) { |
if (!io_read_int(sess, fdin, &idx)) { |
ERRX1(sess, "io_read_int"); |
ERRX1(sess, "io_read_int"); |
goto out; |
goto out; |
} |
} |
if (!send_dl_enqueue(sess, |
if (!send_dl_enqueue(sess, |
&sdlq, idx, fl, flsz, fdin)) { |
&sdlq, idx, fl, flsz, fdin)) { |
ERRX1(sess, "send_dl_enqueue"); |
ERRX1(sess, "send_dl_enqueue"); |
|
|
* put is in the token phase. |
* put is in the token phase. |
*/ |
*/ |
|
|
sz = MIN(MAX_CHUNK, |
sz = MIN(MAX_CHUNK, |
up.stat.curlen - up.stat.curpos); |
up.stat.curlen - up.stat.curpos); |
if (!io_lowbuffer_alloc(sess, &wbuf, |
if (!io_lowbuffer_alloc(sess, &wbuf, |
&wbufsz, &wbufmax, sizeof(int32_t))) { |
&wbufsz, &wbufmax, sizeof(int32_t))) { |
ERRX1(sess, "io_lowbuffer_alloc"); |
ERRX1(sess, "io_lowbuffer_alloc"); |
goto out; |
goto out; |
} |
} |
io_lowbuffer_int(sess, |
io_lowbuffer_int(sess, |
wbuf, &pos, wbufsz, sz); |
wbuf, &pos, wbufsz, sz); |
if (!io_lowbuffer_alloc(sess, &wbuf, |
if (!io_lowbuffer_alloc(sess, &wbuf, |
&wbufsz, &wbufmax, sz)) { |
&wbufsz, &wbufmax, sz)) { |
ERRX1(sess, "io_lowbuffer_alloc"); |
ERRX1(sess, "io_lowbuffer_alloc"); |
goto out; |
goto out; |
} |
} |
io_lowbuffer_buf(sess, wbuf, &pos, wbufsz, |
io_lowbuffer_buf(sess, wbuf, &pos, wbufsz, |
up.stat.map + up.stat.curpos, sz); |
up.stat.map + up.stat.curpos, sz); |
up.stat.curpos += sz; |
up.stat.curpos += sz; |
if (up.stat.curpos == up.stat.curlen) |
if (up.stat.curpos == up.stat.curlen) |
|
|
|
|
hash_file(up.stat.map, |
hash_file(up.stat.map, |
up.stat.mapsz, filemd, sess); |
up.stat.mapsz, filemd, sess); |
if (!io_lowbuffer_alloc(sess, &wbuf, |
if (!io_lowbuffer_alloc(sess, &wbuf, |
&wbufsz, &wbufmax, MD4_DIGEST_LENGTH)) { |
&wbufsz, &wbufmax, MD4_DIGEST_LENGTH)) { |
ERRX1(sess, "io_lowbuffer_alloc"); |
ERRX1(sess, "io_lowbuffer_alloc"); |
goto out; |
goto out; |
|
|
LOG3(sess, "%s: flushed %jd KB total, " |
LOG3(sess, "%s: flushed %jd KB total, " |
"%.2f%% uploaded", |
"%.2f%% uploaded", |
fl[up.cur->idx].path, |
fl[up.cur->idx].path, |
(intmax_t)up.stat.total / 1024, |
(intmax_t)up.stat.total / 1024, |
100.0 * up.stat.dirty / up.stat.total); |
100.0 * up.stat.dirty / up.stat.total); |
send_up_reset(&up); |
send_up_reset(&up); |
} else if (NULL != up.cur && up.cur->idx < 0) { |
} else if (NULL != up.cur && up.cur->idx < 0) { |
|
|
} |
} |
send_up_reset(&up); |
send_up_reset(&up); |
|
|
/* |
/* |
* This is where we actually stop the |
* This is where we actually stop the |
* algorithm: we're already at the |
* algorithm: we're already at the |
* second phase. |
* second phase. |
|
|
up.cur->blks, up.cur->idx)) { |
up.cur->blks, up.cur->idx)) { |
ERRX1(sess, "blk_recv_ack"); |
ERRX1(sess, "blk_recv_ack"); |
goto out; |
goto out; |
} |
} |
LOG3(sess, "%s: primed for %jd B total", |
LOG3(sess, "%s: primed for %jd B total", |
fl[up.cur->idx].path, |
fl[up.cur->idx].path, |
(intmax_t)up.cur->blks->size); |
(intmax_t)up.cur->blks->size); |
|
|
|
|
TAILQ_REMOVE(&sdlq, up.cur, entries); |
TAILQ_REMOVE(&sdlq, up.cur, entries); |
|
|
/* |
/* |
* End of phase: enable channel to receiver. |
* End of phase: enable channel to receiver. |
* We'll need our output buffer enabled in order |
* We'll need our output buffer enabled in order |
* to process this event. |
* to process this event. |
|
|
continue; |
continue; |
} |
} |
|
|
/* |
/* |
* Non-blocking open of file. |
* Non-blocking open of file. |
* This will be picked up in the state machine |
* This will be picked up in the state machine |
* block of not being primed. |
* block of not being primed. |