Skip to content

Commit

Permalink
For #1651, fix return pnwrite of srs_write_large_iovs. 3.0.135
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Mar 21, 2020
1 parent 355f351 commit f89b4b3
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ For previous versions, please read:

## V3 changes

* v3.0, 2020-03-21, For [#1651][bug #1651], fix return pnwrite of srs_write_large_iovs. 3.0.135
* <strong>v3.0, 2020-03-18, [3.0 beta3(3.0.134)][r3.0b3] released. 122509 lines.</strong>
* v3.0, 2020-03-12, For [#1635][bug #1635], inotify watch ConfigMap for reload. 3.0.134
* v3.0, 2020-03-12, For [#1635][bug #1635], support auto reaload config by inotify. 3.0.129
Expand Down Expand Up @@ -1676,6 +1677,7 @@ Winlin
[bug #1594]: https://github.com/ossrs/srs/issues/1594
[bug #1630]: https://github.com/ossrs/srs/issues/1630
[bug #1635]: https://github.com/ossrs/srs/issues/1635
[bug #1651]: https://github.com/ossrs/srs/issues/1651
[bug #yyyyyyyyyyyyy]: https://github.com/ossrs/srs/issues/yyyyyyyyyyyyy

[exo #828]: https://github.com/google/ExoPlayer/pull/828
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/core/srs_core_version3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
#ifndef SRS_CORE_VERSION3_HPP
#define SRS_CORE_VERSION3_HPP

#define SRS_VERSION3_REVISION 134
#define SRS_VERSION3_REVISION 135

#endif
2 changes: 1 addition & 1 deletion trunk/src/protocol/srs_protocol_utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ srs_error_t srs_write_large_iovs(ISrsProtocolReadWriter* skt, iovec* iovs, int s
#endif

// send in a time.
if (size < limits) {
if (size <= limits) {
if ((err = skt->writev(iovs, size, pnwrite)) != srs_success) {
return srs_error_wrap(err, "writev");
}
Expand Down
64 changes: 62 additions & 2 deletions trunk/src/utest/srs_utest_protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,6 @@ srs_error_t MockBufferIO::writev(const iovec *iov, int iov_size, ssize_t* nwrite
total += writen;
}

sbytes += total;

if (nwrite) {
*nwrite = total;
}
Expand Down Expand Up @@ -6412,3 +6410,65 @@ VOID TEST(ProtocolKbpsTest, RAWStatistic)
}
}

VOID TEST(ProtocolKbpsTest, WriteLargeIOVs)
{
srs_error_t err;

if (true) {
iovec iovs[1];
iovs[0].iov_base = (char*)"Hello";
iovs[0].iov_len = 5;

MockBufferIO io;
ssize_t nn = 0;
HELPER_EXPECT_SUCCESS(srs_write_large_iovs(&io, iovs, 1, &nn));
EXPECT_EQ(5, nn);
EXPECT_EQ(5, io.sbytes);
}

if (true) {
iovec iovs[1024];
int nn_iovs = (int)(sizeof(iovs)/sizeof(iovec));
for (int i = 0; i < nn_iovs; i++) {
iovs[i].iov_base = (char*)"Hello";
iovs[i].iov_len = 5;
}

MockBufferIO io;
ssize_t nn = 0;
HELPER_EXPECT_SUCCESS(srs_write_large_iovs(&io, iovs, nn_iovs, &nn));
EXPECT_EQ(5 * nn_iovs, nn);
EXPECT_EQ(5 * nn_iovs, io.sbytes);
}

if (true) {
iovec iovs[1025];
int nn_iovs = (int)(sizeof(iovs)/sizeof(iovec));
for (int i = 0; i < nn_iovs; i++) {
iovs[i].iov_base = (char*)"Hello";
iovs[i].iov_len = 5;
}

MockBufferIO io;
ssize_t nn = 0;
HELPER_EXPECT_SUCCESS(srs_write_large_iovs(&io, iovs, nn_iovs, &nn));
EXPECT_EQ(5 * nn_iovs, nn);
EXPECT_EQ(5 * nn_iovs, io.sbytes);
}

if (true) {
iovec iovs[4096];
int nn_iovs = (int)(sizeof(iovs)/sizeof(iovec));
for (int i = 0; i < nn_iovs; i++) {
iovs[i].iov_base = (char*)"Hello";
iovs[i].iov_len = 5;
}

MockBufferIO io;
ssize_t nn = 0;
HELPER_EXPECT_SUCCESS(srs_write_large_iovs(&io, iovs, nn_iovs, &nn));
EXPECT_EQ(5 * nn_iovs, nn);
EXPECT_EQ(5 * nn_iovs, io.sbytes);
}
}

0 comments on commit f89b4b3

Please sign in to comment.