winlin

refine comments for SrsMessageArray. 2.0.25

@@ -498,6 +498,7 @@ int SrsEdgeForwarder::cycle() @@ -498,6 +498,7 @@ int SrsEdgeForwarder::cycle()
498 } 498 }
499 499
500 // forward all messages. 500 // forward all messages.
  501 + // each msg in msgs.msgs must be free, for the SrsMessageArray never free them.
501 int count = 0; 502 int count = 0;
502 if ((ret = queue->dump_packets(msgs.max, msgs.msgs, count)) != ERROR_SUCCESS) { 503 if ((ret = queue->dump_packets(msgs.max, msgs.msgs, count)) != ERROR_SUCCESS) {
503 srs_error("get message to push to origin failed. ret=%d", ret); 504 srs_error("get message to push to origin failed. ret=%d", ret);
@@ -522,7 +523,7 @@ int SrsEdgeForwarder::cycle() @@ -522,7 +523,7 @@ int SrsEdgeForwarder::cycle()
522 continue; 523 continue;
523 } 524 }
524 525
525 - // all msgs to forward to origin. 526 + // sendout messages, all messages are freed by send_and_free_messages().
526 if ((ret = client->send_and_free_messages(msgs.msgs, count, stream_id)) != ERROR_SUCCESS) { 527 if ((ret = client->send_and_free_messages(msgs.msgs, count, stream_id)) != ERROR_SUCCESS) {
527 srs_error("edge publish push message to server failed. ret=%d", ret); 528 srs_error("edge publish push message to server failed. ret=%d", ret);
528 return ret; 529 return ret;
@@ -416,6 +416,7 @@ int SrsForwarder::forward() @@ -416,6 +416,7 @@ int SrsForwarder::forward()
416 } 416 }
417 417
418 // forward all messages. 418 // forward all messages.
  419 + // each msg in msgs.msgs must be free, for the SrsMessageArray never free them.
419 int count = 0; 420 int count = 0;
420 if ((ret = queue->dump_packets(msgs.max, msgs.msgs, count)) != ERROR_SUCCESS) { 421 if ((ret = queue->dump_packets(msgs.max, msgs.msgs, count)) != ERROR_SUCCESS) {
421 srs_error("get message to forward failed. ret=%d", ret); 422 srs_error("get message to forward failed. ret=%d", ret);
@@ -438,7 +439,7 @@ int SrsForwarder::forward() @@ -438,7 +439,7 @@ int SrsForwarder::forward()
438 continue; 439 continue;
439 } 440 }
440 441
441 - // all msgs to forward. 442 + // sendout messages, all messages are freed by send_and_free_messages().
442 if ((ret = client->send_and_free_messages(msgs.msgs, count, stream_id)) != ERROR_SUCCESS) { 443 if ((ret = client->send_and_free_messages(msgs.msgs, count, stream_id)) != ERROR_SUCCESS) {
443 srs_error("forwarder messages to server failed. ret=%d", ret); 444 srs_error("forwarder messages to server failed. ret=%d", ret);
444 return ret; 445 return ret;
@@ -558,6 +558,7 @@ int SrsRtmpConn::playing(SrsSource* source) @@ -558,6 +558,7 @@ int SrsRtmpConn::playing(SrsSource* source)
558 pithy_print.elapse(); 558 pithy_print.elapse();
559 559
560 // get messages from consumer. 560 // get messages from consumer.
  561 + // each msg in msgs.msgs must be free, for the SrsMessageArray never free them.
561 int count = 0; 562 int count = 0;
562 if ((ret = consumer->dump_packets(msgs.max, msgs.msgs, count)) != ERROR_SUCCESS) { 563 if ((ret = consumer->dump_packets(msgs.max, msgs.msgs, count)) != ERROR_SUCCESS) {
563 srs_error("get messages from consumer failed. ret=%d", ret); 564 srs_error("get messages from consumer failed. ret=%d", ret);
@@ -591,9 +592,7 @@ int SrsRtmpConn::playing(SrsSource* source) @@ -591,9 +592,7 @@ int SrsRtmpConn::playing(SrsSource* source)
591 } 592 }
592 } 593 }
593 594
594 - // sendout messages  
595 - // @remark, becareful, all msgs must be free explicitly,  
596 - // free by send_and_free_message or srs_freep. 595 + // sendout messages, all messages are freed by send_and_free_messages().
597 if (count > 0) { 596 if (count > 0) {
598 // no need to assert msg, for the rtmp will assert it. 597 // no need to assert msg, for the rtmp will assert it.
599 if ((ret = rtmp->send_and_free_messages(msgs.msgs, count, res->stream_id)) != ERROR_SUCCESS) { 598 if ((ret = rtmp->send_and_free_messages(msgs.msgs, count, res->stream_id)) != ERROR_SUCCESS) {
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 // current release version 31 // current release version
32 #define VERSION_MAJOR 2 32 #define VERSION_MAJOR 2
33 #define VERSION_MINOR 0 33 #define VERSION_MINOR 0
34 -#define VERSION_REVISION 24 34 +#define VERSION_REVISION 25
35 // server info. 35 // server info.
36 #define RTMP_SIG_SRS_KEY "SRS" 36 #define RTMP_SIG_SRS_KEY "SRS"
37 #define RTMP_SIG_SRS_ROLE "origin/edge server" 37 #define RTMP_SIG_SRS_ROLE "origin/edge server"
@@ -40,6 +40,9 @@ SrsMessageArray::SrsMessageArray(int max_msgs) @@ -40,6 +40,9 @@ SrsMessageArray::SrsMessageArray(int max_msgs)
40 40
41 SrsMessageArray::~SrsMessageArray() 41 SrsMessageArray::~SrsMessageArray()
42 { 42 {
  43 + // we just free the msgs itself,
  44 + // both delete and delete[] is ok,
  45 + // for each msg in msgs is already freed by send_and_free_messages.
43 srs_freep(msgs); 46 srs_freep(msgs);
44 } 47 }
45 48