winlin

Merge branch 'srs.master'

@@ -64,6 +64,47 @@ int sleep_test() @@ -64,6 +64,47 @@ int sleep_test()
64 return 0; 64 return 0;
65 } 65 }
66 66
  67 +void* sleep2_func0(void* arg)
  68 +{
  69 + int sleep_ms = 100;
  70 + st_utime_t start = st_utime();
  71 + st_usleep(sleep_ms * 1000);
  72 + st_utime_t end = st_utime();
  73 +
  74 + srs_trace("sleep ok, sleep=%dus, deviation=%dus",
  75 + (int)(sleep_ms * 1000), (int)(end - start - sleep_ms * 1000));
  76 +
  77 + return NULL;
  78 +}
  79 +
  80 +void* sleep2_func1(void* arg)
  81 +{
  82 + int sleep_ms = 250;
  83 + st_utime_t start = st_utime();
  84 + st_usleep(sleep_ms * 1000);
  85 + st_utime_t end = st_utime();
  86 +
  87 + srs_trace("sleep ok, sleep=%dus, deviation=%dus",
  88 + (int)(sleep_ms * 1000), (int)(end - start - sleep_ms * 1000));
  89 +
  90 + return NULL;
  91 +}
  92 +
  93 +int sleep2_test()
  94 +{
  95 + srs_trace("===================================================");
  96 + srs_trace("sleep2 test: start");
  97 +
  98 + st_thread_t trd0 = st_thread_create(sleep2_func0, NULL, 1, 0);
  99 + st_thread_t trd1 = st_thread_create(sleep2_func1, NULL, 1, 0);
  100 + st_thread_join(trd0, NULL);
  101 + st_thread_join(trd1, NULL);
  102 +
  103 + srs_trace("sleep test: end");
  104 + exit(0);
  105 + return 0;
  106 +}
  107 +
67 st_mutex_t sleep_work_cond = NULL; 108 st_mutex_t sleep_work_cond = NULL;
68 void* sleep_deviation_func(void* arg) 109 void* sleep_deviation_func(void* arg)
69 { 110 {
@@ -400,8 +441,8 @@ int main(int argc, char** argv) @@ -400,8 +441,8 @@ int main(int argc, char** argv)
400 return -1; 441 return -1;
401 } 442 }
402 443
403 - if (huge_stack_test() < 0) {  
404 - srs_trace("huge_stack_test failed"); 444 + if (sleep2_test() < 0) {
  445 + srs_trace("sleep2_test failed");
405 return -1; 446 return -1;
406 } 447 }
407 448
@@ -415,6 +456,11 @@ int main(int argc, char** argv) @@ -415,6 +456,11 @@ int main(int argc, char** argv)
415 return -1; 456 return -1;
416 } 457 }
417 458
  459 + if (huge_stack_test() < 0) {
  460 + srs_trace("huge_stack_test failed");
  461 + return -1;
  462 + }
  463 +
418 if (thread_test() < 0) { 464 if (thread_test() < 0) {
419 srs_trace("thread_test failed"); 465 srs_trace("thread_test failed");
420 return -1; 466 return -1;
@@ -534,6 +534,10 @@ int SrsRtmpConn::playing(SrsSource* source) @@ -534,6 +534,10 @@ int SrsRtmpConn::playing(SrsSource* source)
534 // it's ok, do nothing. 534 // it's ok, do nothing.
535 ret = ERROR_SUCCESS; 535 ret = ERROR_SUCCESS;
536 srs_verbose("recv timeout, ignore. ret=%d", ret); 536 srs_verbose("recv timeout, ignore. ret=%d", ret);
  537 +
  538 + // TODO: FIXME: the timeout may caused some dead loop.
  539 + // @see: https://github.com/winlinvip/simple-rtmp-server/issues/161
  540 + st_usleep(0);
537 } else if (ret != ERROR_SUCCESS) { 541 } else if (ret != ERROR_SUCCESS) {
538 if (!srs_is_client_gracefully_close(ret)) { 542 if (!srs_is_client_gracefully_close(ret)) {
539 srs_error("recv client control message failed. ret=%d", ret); 543 srs_error("recv client control message failed. ret=%d", ret);
@@ -48,6 +48,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -48,6 +48,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
48 // signal defines. 48 // signal defines.
49 #define SIGNAL_RELOAD SIGHUP 49 #define SIGNAL_RELOAD SIGHUP
50 50
  51 +// nginx also set to 512
51 #define SERVER_LISTEN_BACKLOG 512 52 #define SERVER_LISTEN_BACKLOG 512
52 53
53 // system interval in ms, 54 // system interval in ms,