winlin

fix memory leak of source.

@@ -1030,7 +1030,18 @@ int SrsSource::cycle() @@ -1030,7 +1030,18 @@ int SrsSource::cycle()
1030 1030
1031 bool SrsSource::expired() 1031 bool SrsSource::expired()
1032 { 1032 {
1033 - if (!consumers.empty() || die_at == -1) { 1033 + // unknown state?
  1034 + if (die_at == -1) {
  1035 + return false;
  1036 + }
  1037 +
  1038 + // still publishing?
  1039 + if (!_can_publish) {
  1040 + return false;
  1041 + }
  1042 +
  1043 + // has any consumers?
  1044 + if (!consumers.empty()) {
1034 return false; 1045 return false;
1035 } 1046 }
1036 1047
@@ -2210,7 +2221,6 @@ int SrsSource::create_consumer(SrsConnection* conn, SrsConsumer*& consumer, bool @@ -2210,7 +2221,6 @@ int SrsSource::create_consumer(SrsConnection* conn, SrsConsumer*& consumer, bool
2210 { 2221 {
2211 int ret = ERROR_SUCCESS; 2222 int ret = ERROR_SUCCESS;
2212 2223
2213 - die_at = -1;  
2214 consumer = new SrsConsumer(this, conn); 2224 consumer = new SrsConsumer(this, conn);
2215 consumers.push_back(consumer); 2225 consumers.push_back(consumer);
2216 2226