Skip to content

Commit f89b4b3

Browse files
committed
For ossrs#1651, fix return pnwrite of srs_write_large_iovs. 3.0.135
1 parent 355f351 commit f89b4b3

File tree

4 files changed

+66
-4
lines changed

4 files changed

+66
-4
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ For previous versions, please read:
146146

147147
## V3 changes
148148

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

16811683
[exo #828]: https://github.com/google/ExoPlayer/pull/828

trunk/src/core/srs_core_version3.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
#ifndef SRS_CORE_VERSION3_HPP
2525
#define SRS_CORE_VERSION3_HPP
2626

27-
#define SRS_VERSION3_REVISION 134
27+
#define SRS_VERSION3_REVISION 135
2828

2929
#endif

trunk/src/protocol/srs_protocol_utility.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ srs_error_t srs_write_large_iovs(ISrsProtocolReadWriter* skt, iovec* iovs, int s
336336
#endif
337337

338338
// send in a time.
339-
if (size < limits) {
339+
if (size <= limits) {
340340
if ((err = skt->writev(iovs, size, pnwrite)) != srs_success) {
341341
return srs_error_wrap(err, "writev");
342342
}

trunk/src/utest/srs_utest_protocol.cpp

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,6 @@ srs_error_t MockBufferIO::writev(const iovec *iov, int iov_size, ssize_t* nwrite
230230
total += writen;
231231
}
232232

233-
sbytes += total;
234-
235233
if (nwrite) {
236234
*nwrite = total;
237235
}
@@ -6412,3 +6410,65 @@ VOID TEST(ProtocolKbpsTest, RAWStatistic)
64126410
}
64136411
}
64146412

6413+
VOID TEST(ProtocolKbpsTest, WriteLargeIOVs)
6414+
{
6415+
srs_error_t err;
6416+
6417+
if (true) {
6418+
iovec iovs[1];
6419+
iovs[0].iov_base = (char*)"Hello";
6420+
iovs[0].iov_len = 5;
6421+
6422+
MockBufferIO io;
6423+
ssize_t nn = 0;
6424+
HELPER_EXPECT_SUCCESS(srs_write_large_iovs(&io, iovs, 1, &nn));
6425+
EXPECT_EQ(5, nn);
6426+
EXPECT_EQ(5, io.sbytes);
6427+
}
6428+
6429+
if (true) {
6430+
iovec iovs[1024];
6431+
int nn_iovs = (int)(sizeof(iovs)/sizeof(iovec));
6432+
for (int i = 0; i < nn_iovs; i++) {
6433+
iovs[i].iov_base = (char*)"Hello";
6434+
iovs[i].iov_len = 5;
6435+
}
6436+
6437+
MockBufferIO io;
6438+
ssize_t nn = 0;
6439+
HELPER_EXPECT_SUCCESS(srs_write_large_iovs(&io, iovs, nn_iovs, &nn));
6440+
EXPECT_EQ(5 * nn_iovs, nn);
6441+
EXPECT_EQ(5 * nn_iovs, io.sbytes);
6442+
}
6443+
6444+
if (true) {
6445+
iovec iovs[1025];
6446+
int nn_iovs = (int)(sizeof(iovs)/sizeof(iovec));
6447+
for (int i = 0; i < nn_iovs; i++) {
6448+
iovs[i].iov_base = (char*)"Hello";
6449+
iovs[i].iov_len = 5;
6450+
}
6451+
6452+
MockBufferIO io;
6453+
ssize_t nn = 0;
6454+
HELPER_EXPECT_SUCCESS(srs_write_large_iovs(&io, iovs, nn_iovs, &nn));
6455+
EXPECT_EQ(5 * nn_iovs, nn);
6456+
EXPECT_EQ(5 * nn_iovs, io.sbytes);
6457+
}
6458+
6459+
if (true) {
6460+
iovec iovs[4096];
6461+
int nn_iovs = (int)(sizeof(iovs)/sizeof(iovec));
6462+
for (int i = 0; i < nn_iovs; i++) {
6463+
iovs[i].iov_base = (char*)"Hello";
6464+
iovs[i].iov_len = 5;
6465+
}
6466+
6467+
MockBufferIO io;
6468+
ssize_t nn = 0;
6469+
HELPER_EXPECT_SUCCESS(srs_write_large_iovs(&io, iovs, nn_iovs, &nn));
6470+
EXPECT_EQ(5 * nn_iovs, nn);
6471+
EXPECT_EQ(5 * nn_iovs, io.sbytes);
6472+
}
6473+
}
6474+

0 commit comments

Comments
 (0)