|
|
@ -553,6 +553,8 @@ static void bs_write_packet(struct boxs *bs, const unsigned char *buf, uint16_t
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void bs_end(struct boxs *bs) {
|
|
|
|
static void bs_end(struct boxs *bs) {
|
|
|
|
|
|
|
|
if (bs->wrote_goodbye) return;
|
|
|
|
|
|
|
|
bs->wrote_goodbye = true;
|
|
|
|
if (!bs->noauth) {
|
|
|
|
if (!bs->noauth) {
|
|
|
|
bs_write_end_box(bs);
|
|
|
|
bs_write_end_box(bs);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -615,7 +617,10 @@ static enum stream_state bs_read_out_1(struct boxs *bs, int fd) {
|
|
|
|
size_t len = sizeof(buf);
|
|
|
|
size_t len = sizeof(buf);
|
|
|
|
int rc;
|
|
|
|
int rc;
|
|
|
|
rc = bs_read_packet(bs, buf, &len);
|
|
|
|
rc = bs_read_packet(bs, buf, &len);
|
|
|
|
if (rc < 0 && errno == EPIPE) return stream_state_ended_ok;
|
|
|
|
if (rc < 0 && errno == EPIPE) {
|
|
|
|
|
|
|
|
bs_end(bs);
|
|
|
|
|
|
|
|
return stream_state_ended_ok;
|
|
|
|
|
|
|
|
}
|
|
|
|
if (rc < 0) return stream_state_ended_error;
|
|
|
|
if (rc < 0) return stream_state_ended_error;
|
|
|
|
rc = write_all(fd, buf, len);
|
|
|
|
rc = write_all(fd, buf, len);
|
|
|
|
if (rc < 0) return stream_state_ended_error;
|
|
|
|
if (rc < 0) return stream_state_ended_error;
|
|
|
@ -746,7 +751,7 @@ static int bs_passthrough(struct boxs *bs, int infd, int outfd) {
|
|
|
|
if (FD_ISSET(sfd, &rd)) out = bs_read_out_1(bs, outfd);
|
|
|
|
if (FD_ISSET(sfd, &rd)) out = bs_read_out_1(bs, outfd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return in == stream_state_ended_ok && out == stream_state_ended_ok ? 0 :
|
|
|
|
return in != stream_state_ended_error && out == stream_state_ended_ok ? 0 :
|
|
|
|
in == stream_state_ended_error || out == stream_state_ended_error ? 2 : 1;
|
|
|
|
in == stream_state_ended_error || out == stream_state_ended_error ? 2 : 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|