1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Compare commits

..

1594 commits

Author SHA1 Message Date
winlin
e801174ab2 Fix #2606: Memory leak for RTMP client, pick from 4.0. v3.0.170 2021-10-08 07:19:25 +08:00
winlin
b4220ee7c1 Refine Dockerfile 2021-09-05 15:03:03 +08:00
winlin
21be9daba4 Update README 2021-08-15 21:49:24 +08:00
winlin
9eadebdde7 Fix version query bug. 2021-08-15 21:43:16 +08:00
winlin
2431e0b140 Acitons: Support pullrequest CI 2021-08-15 17:49:03 +08:00
winlin
b3516b88dc Acitons: Support pullrequest CI 2021-08-15 17:45:43 +08:00
winlin
1d79ef87a5 Acitons: Support pullrequest CI 2021-08-15 17:41:15 +08:00
winlin
8d44b982ee Actions: Add CI for utest and coverage 2021-08-15 17:22:07 +08:00
winlin
b02c814251 Expose live streaming ports for SRS 3.0 2021-08-14 21:09:44 +08:00
winlin
c2b133bd07 Support Github Actions 2021-08-14 20:56:00 +08:00
winlin
b8177ff2fb Release v3.0-r8, 3.0.168 2021-08-14 09:26:04 +08:00
winlin
34117027fd Update README 2021-08-13 14:53:54 +08:00
winlin
d21dadb285 Update README 2021-08-13 14:52:10 +08:00
winlin
6543aa8635 Update README 2021-08-13 14:44:22 +08:00
winlin
d81cba4d16 Update README 2021-08-13 14:43:17 +08:00
winlin
5c97da28c6 API: For #2508, query feature docker and packager. v3.0.166 2021-08-07 16:24:02 +08:00
winlin
5c6bb63bf2 API: Use libuuid to generate uuid. v3.0.165 2021-08-06 21:37:12 +08:00
winlin
ea064166b7 Add role(srs) to query versions 2021-07-06 11:20:52 +08:00
winlin
d4c1bdf9d0 Update README for v3.0-r7 2021-07-04 14:27:22 +08:00
winlin
d72d05294d For #2424, use srandom/random to generate. 3.0.164 2021-07-04 14:21:32 +08:00
winlin
e7435a6237 Fix bug for v3.0-r6 2021-06-27 10:00:38 +08:00
winlin
2be8589a8a For #2424, query the latest available version. 3.0.163 2021-06-26 09:51:15 +08:00
winlin
cf34ebc32f Fix link in README.md 2021-05-31 13:13:02 +08:00
winlin
e7e05c434e Refine README.md 2021-05-24 10:15:54 +08:00
winlin
9f9bc6a17f For SRS3.0, correct the protocols it supports 2021-05-24 08:58:28 +08:00
Xiaoniu
a1f5382240
fix bug: memory leak in SrsStatisticClient (#2352) 2021-05-13 21:07:37 +08:00
winlin
e076300cd8 For #2311, Refine the update to update_auth 2021-05-12 21:26:04 +08:00
winlin
71dda68f62 Fix #2311, Copy the request for stat client. 3.0.162 2021-05-12 21:17:57 +08:00
winlin
b7af726ffc Doc: Link source flv 2021-04-30 16:42:47 +08:00
winlin
61a5e22af8 Update gitee repository url 2021-04-28 16:58:36 +08:00
winlin
a3fddbe8b0 Update README 2021-04-28 16:45:36 +08:00
winlin
c95c53cfe3 Update script 2021-04-28 15:30:06 +08:00
winlin
9d9d81ef17 Upgrade players. 3.0.161 2021-04-28 15:18:10 +08:00
winlin
cf6fa98e36 Update README 2021-04-28 08:19:22 +08:00
winlin
42e910bb32 Update README 2021-04-28 08:13:48 +08:00
winlin
0c5b5106d0 Update README 2021-04-28 08:12:21 +08:00
winlin
8547118622 Update README 2021-04-28 08:10:50 +08:00
winlin
f847b0d1c0 Add crossdomain.xml for install script 2021-04-26 13:47:15 +08:00
winlin
7367780605 For #2304: Deprecate pull RTSP 2021-04-25 08:53:14 +08:00
winlin
c7d45c20b5 Update README 2021-04-24 22:35:57 +08:00
winlin
e6897a9959 Update README 2021-04-24 22:27:42 +08:00
winlin
e80245c66b Update README 2021-04-24 22:22:36 +08:00
winlin
077c45cea0 Update README 2021-04-24 22:21:46 +08:00
winlin
bee9d181e7 Update README 2021-04-24 22:20:44 +08:00
winlin
cea3f43cba Update README 2021-04-24 22:18:03 +08:00
winlin
75059531c2 Release v3.0-r4 2021-04-24 18:30:00 +08:00
winlin
4cdaa15a76 Remove make install-api 2021-04-24 18:28:46 +08:00
winlin
08500fe162 Package players and console to zip and docker. 3.0.160 2021-04-24 18:28:31 +08:00
winlin
44965da9af Add srs-console to research/console. 3.0.159 2021-04-24 18:07:49 +08:00
winlin
90b2e08c4b Package srs-console to zip and docker. 3.0.159 2021-04-24 14:44:06 +08:00
winlin
f8e3be644d Update description 2021-04-16 11:11:40 +08:00
winlin
0702c27d88 Update description 2021-04-16 11:05:55 +08:00
stone
bf58f915ef
Update srs_app_config.cpp (#2275)
bugfix: misleading error log information for transcode engine config param.
2021-04-09 07:16:00 +08:00
winlin
47a7a5f825 Update README for docker 2021-03-05 09:46:17 +08:00
winlin
5eaf3b7cdb Update README for docker 2021-03-05 09:44:09 +08:00
winlin
7a134f5352 Refine usage to docker by default. 3.0.158 2021-03-05 09:04:59 +08:00
winlin
f5ff646c0c Add docker for FFmpeg publish 2021-03-05 09:04:10 +08:00
winlin
33a94de13d Add docker for FFmpeg publish 2021-03-05 09:02:04 +08:00
winlin
ba5b2f6a60 Add docker for FFmpeg publish 2021-03-05 08:58:29 +08:00
winlin
a44833a3b9 Add docker for FFmpeg publish 2021-03-05 08:57:15 +08:00
winlin
aa0520e07e Update README for docker 2021-03-05 00:11:29 +08:00
winlin
10746d25c1 Refine README for docker 2021-03-05 00:05:31 +08:00
winlin
407bad5c9d Refine README for docker 2021-03-05 00:03:46 +08:00
winlin
4465cf3df1 Refine README for docker 2021-03-05 00:03:21 +08:00
winlin
da7251f628 Refine README for docker 2021-03-04 23:56:37 +08:00
winlin
0a6ad8b821 Refine README for docker 2021-03-04 23:55:09 +08:00
winlin
48a9498a20 Refine README for docker 2021-03-04 23:51:59 +08:00
winlin
a3c9f57f8a Refine README for docker 2021-03-04 23:48:41 +08:00
winlin
3c602269bb Update usage, docker first. 2021-03-04 23:29:09 +08:00
winlin
ccbc8b25c6 Update usage, docker first. 2021-03-04 23:28:16 +08:00
winlin
48ac0a01c2 Update usage, docker first. 2021-03-04 23:27:18 +08:00
winlin
a4f9447380 Update usage, docker first. 2021-03-04 23:24:51 +08:00
winlin
de5b86aab9 Docker: Change log from file to console, add conf/docker.conf 2021-03-04 21:57:00 +08:00
winlin
eeebcda87d Update readme 2021-02-19 15:24:35 +08:00
winlin
4f013404e3 Refine stat id 2021-01-07 17:09:33 +08:00
winlin
fb7c051833 Change id from int to string for the statistics. 3.0.157 2021-01-07 16:47:49 +08:00
winlin
010878889c Release 3.0r3 2021-01-02 19:16:30 +08:00
winlin
831c78062b Remove vhost in query if not present it 2020-12-27 12:55:27 +08:00
winlin
6e43ef6866 For RTMP edge/forward, pass vhost in tcUrl, not in stream. 3.0.156 2020-12-26 22:11:23 +08:00
winlin
4d18835f3c Fix build fail 2020-12-21 10:37:33 +08:00
winlin
25c76c1e8a Fix #1694, Support DVR 2GB+ MP4 file. 3.0.155 2020-12-17 18:43:45 +08:00
winlin
ab5ddd24e2 Fix #1548, Add edts in MP4 for Windows10. 3.0.154 2020-12-17 12:07:34 +08:00
winlin
721173e6af MP4: Fix warnings 2020-12-17 11:25:51 +08:00
winlin
6e922b9589 Refine README for SRS3 2020-11-10 10:19:43 +08:00
winlin
d98a85b368 Release 3.0-r2, 3.0.153 2020-10-31 22:16:46 +08:00
winlin
9a963c6fd2 Fix #509, Always malloc stack on heap. 3.0.153 2020-10-31 21:27:09 +08:00
winlin
86f8cbb5eb Remove some global elements for debugging. 3.0.152 2020-10-31 18:01:16 +08:00
winlin
b348539687 Remove some global elements for debugging. 3.0.152 2020-10-31 17:53:00 +08:00
winlin
9f9e3a5d42 Use global _srs_server for debugging. 3.0.151 2020-10-31 17:47:27 +08:00
winlin
bf5e2add83 Refine source cid, track previous one. 3.0.150 2020-10-31 17:42:20 +08:00
winlin
f08a1a1b10 Refine etc script to collect stderr logs 2020-10-27 18:00:18 +08:00
winlin
7b68330651 Add hls.realtime.conf for low-latency HLS. 3.0.149 2020-10-25 11:44:02 +08:00
winlin
8445d5543b Refine script and startup logs. 3.0.148 2020-10-24 18:28:53 +08:00
winlin
aac170b75e Refine build script 2020-10-23 21:45:32 +08:00
winlin
0a09b53fc1 Refine build script 2020-10-23 21:35:46 +08:00
winlin
6dc3d85ded Allow FFmpeg if exists at /usr/local/bin/ffmpeg. 3.0.147 2020-10-23 21:32:57 +08:00
winlin
1d92ff73fb Fix build script 2020-10-23 21:24:29 +08:00
winlin
e1ff69f292 Refine build script, use libssl in docker. 3.0.146 2020-10-23 21:14:40 +08:00
winlin
f036460164 Update default srs.conf, enable HLS and HTTP-FLV 2020-10-23 21:00:29 +08:00
winlin
cc6b71e1ae Update conf to follow wiki 2020-10-23 20:50:56 +08:00
winlin
3f3a23f978 Fix #1987, Fix Kbps resample bug. 3.0.145 2020-10-14 11:38:54 +08:00
winlin
9c11e5077f Fix Kbps resample bug 2020-10-14 11:36:48 +08:00
winlin
3809d43ee5 Release 3.0r1, 3.0.144 2020-10-10 16:50:19 +08:00
winlin
5342596fc0 Update README for #1780 2020-10-10 16:47:25 +08:00
winlin
726ac03e22 Change stable release to 3.0 2020-10-10 16:38:59 +08:00
winlin
13af54171f For #1780, build fail on ubuntu:focal. 3.0.144 2020-10-10 16:20:05 +08:00
winlin
905444a1c7 For #1684, Prevent stop ingest for multiple times. 3.0.143 2020-09-14 20:48:44 +08:00
chenchengbin
0aecc063e0 防止ingester多次调用stop导致崩溃 2020-09-14 20:44:47 +08:00
winlin
63b5c51748 RTC: Change SO_REUSEPORT fail to warning. 3.0.142 2020-09-10 19:35:04 +08:00
winlin
18192f7efb Update SRS to Simple-Realtime-Server 2020-08-24 13:08:21 +08:00
winlin
e3f1aee6c1 Release 3.0 r0, 3.0.141 2020-06-27 11:47:36 +08:00
winlin
024df5bdbf Refine README 2020-06-24 11:38:48 +08:00
winlin
5d286776a5 Fix README link 2020-06-24 11:37:25 +08:00
winlin
ac69889b3a Link FFmpeg if exists 2020-06-20 21:48:04 +08:00
winlin
7ad947ae3b Remove dead files 2020-06-05 08:46:01 +08:00
winlin
c2657bf672 Use isolate cache for different SRS version. 2020-04-07 20:11:56 +08:00
winlin
f3d708c2b5 Fix utest build warnings 2020-03-30 12:46:53 +08:00
winlin
57604a9c65 For #1672, fix dvr close file failed bug. 3.0.140 2020-03-30 10:44:11 +08:00
xfalcon
cd1513d6a3
fix fs not close,when dvr error (#1672) 2020-03-30 10:37:16 +08:00
winlin
80f315f1ae Support utest on mac osx 2020-03-29 17:29:09 +08:00
winlin
1c65987472 Refine links use relative path 2020-03-29 16:51:56 +08:00
winlin
2ba8104b37 Update coverage script 2020-03-29 16:36:49 +08:00
winlin
b9a3df5c55 Update utest script 2020-03-29 16:18:20 +08:00
winlin
f8b0bc122b Update build script 2020-03-29 15:48:57 +08:00
winlin
0081525380 Update package script 2020-03-29 15:29:07 +08:00
winlin
c0a8193537 Update build script 2020-03-29 15:23:40 +08:00
winlin
d5339acc57 Update package script 2020-03-29 14:12:37 +08:00
winlin
f674cab84f Release 3.0-b4, 3.0.139 2020-03-29 14:00:37 +08:00
winlin
98a71954da Support multiple OS/Platform build cache. 3.0.139 2020-03-29 00:09:17 +08:00
winlin
218fe332aa For #1250, support osx build 2020-03-28 18:04:34 +08:00
winlin
0a030a4ade Update 2020-03-28 17:42:26 +08:00
winlin
2d287e3723 Merge branch 'feature/macos' into 3.0release 2020-03-28 17:24:11 +08:00
winlin
3556da40ce Fix #1250, Support macOS, OSX, MacbookPro, Apple Darwin. 3.0.138 2020-03-28 17:23:11 +08:00
winlin
c339542ce0 Support macOS OSX 2020-03-28 17:20:40 +08:00
winlin
b3b76b0ca6 Update readme 2020-03-24 13:17:05 +08:00
winlin
b12f0e8c8b Update readme 2020-03-24 13:12:00 +08:00
winlin
0dd6c31487 Fix #1629, fix kickoff FLV client bug. 3.0.137 2020-03-21 22:41:25 +08:00
winlin
850a4bbf20 Fix #1619, configure without utest by default. 3.0.136 2020-03-21 20:41:37 +08:00
winlin
f89b4b3b26 For #1651, fix return pnwrite of srs_write_large_iovs. 3.0.135 2020-03-21 20:20:40 +08:00
winlin
355f351435
Merge pull request #1651 from lam2003/3.0release
修复srs_write_large_iovs中nwrite未累加的错误
2020-03-21 19:44:37 +08:00
winlin
75f62dc653 Update mirror 2020-03-21 16:34:18 +08:00
winlin
5a55cff7ba Update mirror 2020-03-21 16:30:29 +08:00
winlin
737e4bc32d Update 2020-03-19 17:57:23 +08:00
winlin
83f743645b Release multiple processes for SRS by reuseport 2020-03-19 17:49:37 +08:00
l
bbfb03f98a
修复srs_write_large_iovs中nwrite未累加的错误 2020-03-19 14:36:56 +08:00
l
f9114770af
Merge pull request #2 from ossrs/3.0release
update to latest
2020-03-19 14:32:35 +08:00
winlin
aead1a5b74 Release 3.0.134, 3.0-b3 2020-03-18 16:33:08 +08:00
winlin
9ba861f42f 3.0release is beta now 2020-03-16 15:11:34 +08:00
winlin
a8ddd5afe7 For #1635, refine inotify watch for relative path 2020-03-16 11:52:31 +08:00
winlin
8db2c3d821 For #1635, refine inotify watch for relative path 2020-03-16 11:39:20 +08:00
winlin
88336b1f5e Remove KAFKA config, because it's removed from code 2020-03-14 14:38:26 +08:00
winlin
446e5f9a0c Update README 2020-03-14 14:34:20 +08:00
winlin
fc3704e54e Update README 2020-03-14 14:32:49 +08:00
winlin
08bffc60fb Update install 2020-03-13 16:29:54 +08:00
winlin
856ed5a971 For #1635, inotify watch ConfigMap for reload. 3.0.134 2020-03-12 22:26:34 +08:00
winlin
bb509d23e2 For #1635, inotify watch ConfigMap for reload. 3.0.133 2020-03-12 22:08:23 +08:00
winlin
88368ed18d For #1635, inotify watch ConfigMap for reload. 3.0.132 2020-03-12 21:58:29 +08:00
winlin
940798a9c7 For #1635, inotify watch ConfigMap for reload. 3.0.131 2020-03-12 21:45:10 +08:00
winlin
5e60c8f9cc For #1635, inotify watch ConfigMap for reload. 3.0.130 2020-03-12 19:37:31 +08:00
winlin
9b663c070a Fix #1635, support auto reaload config by inotify. 3.0.129 2020-03-12 18:14:23 +08:00
winlin
4b395f6e16 Fix #1630, disable cache for stream changing, and drop dup header. 3.0.128 2020-03-12 11:55:37 +08:00
winlin
ed41ca867b For #1594, detect and disable daemon for docker. 3.0.127 2020-03-12 10:11:41 +08:00
winlin
c1e07d6a96 For #1634, always check status in thread loop. 3.0.126 2020-03-12 08:59:13 +08:00
winlin
6c55fd3e4b For #1634, refactor output with datetime for ingest/encoder/exec. 3.0.125 2020-03-11 19:42:42 +08:00
winlin
c61c2a939f For #1634, refactor output with datetime for ingest/encoder/exec. 3.0.125 2020-03-11 19:33:55 +08:00
winlin
0290009b4e Refine readme 2020-03-11 19:27:26 +08:00
winlin
c78595c1fa For #1634, refactor encoder output, support timestamp variables. 2020-03-11 19:19:17 +08:00
winlin
66b194cd63 For #1634, refactor encoder process management. 2020-03-11 19:08:36 +08:00
winlin
927c0c8e39 For #1634, fix quit by accident SIGTERM while killing FFMPEG. 3.0.124 2020-03-11 19:04:52 +08:00
winlin
d5bbf84439 Release 3.0b2, 3.0.123 2020-03-05 11:34:16 +08:00
winlin
ea305790df For #1579, refactor log for gracefully quit. 2020-02-26 16:38:06 +08:00
winlin
20b9d6ab02 For #1598, support SLB health checking by TCP. 3.0.123 2020-02-21 23:51:40 +08:00
winlin
4a69499f2c Fix bug for librtmp client ipv4/ipv6 socket. 3.0.122 2020-02-21 23:11:09 +08:00
winlin
dc0f804452 For #1579, support start/final wait for gracefully quit. 3.0.121 2020-02-18 23:37:11 +08:00
winlin
58b40478b6 For #1579, support force gracefully quit. 3.0.120 2020-02-18 22:15:12 +08:00
winlin
3c597545b1 For #1579, support gracefully quit. 3.0.119 2020-02-18 19:59:47 +08:00
winlin
e6c329293c Refine log 2020-02-18 15:07:15 +08:00
winlin
f4c7b882c5 For #1579, define signals for fast/grace quit and upgrade 2020-02-18 09:53:40 +08:00
winlin
5be69d290f For #1601, flush async on_dvr/on_hls events before stop. 3.0.118 2020-02-17 11:53:04 +08:00
winlin
304b92cc36 Update maintainers 2020-02-16 13:41:47 +08:00
winlin
8079564077 Update maintainers 2020-02-16 13:39:25 +08:00
winlin
1604fcf35a Update authors 2020-02-16 13:31:03 +08:00
winlin
16173194b9 Release 3.0-beta1, r3.0b1, 3.0.117 2020-02-14 23:05:54 +08:00
winlin
131acf5bb0 For #1595, migrating streaming from ossrs.net to r.ossrs.net. 3.0.117 2020-02-14 23:04:01 +08:00
winlin
4276bea463 Migrating streaming service from ossrs.net to r.ossrs.net 2020-02-14 22:00:58 +08:00
winlin
23324cde31 Migrating streaming service from ossrs.net to r.ossrs.net 2020-02-14 21:57:02 +08:00
winlin
21c2cb6512 Update issue template 2020-02-14 11:17:19 +08:00
winlin
d2a071f041 Add TODO for incompatible APIs of librtmp 2020-02-11 19:32:46 +08:00
winlin
fc769550db Fix #665, fix HTTP-FLV reloading bug. 3.0.116 2020-02-05 14:17:30 +08:00
winlin
f6fa889393 For #1592, default ff_log_level to info 2020-02-05 13:20:37 +08:00
winlin
c6d914bc13 Fix #1592, fix terminal echo off by redirect process stdin. 3.0.115 2020-02-05 13:04:00 +08:00
winlin
c50c51889a For #1592, support ff_log_level and default to warning 2020-02-05 12:32:15 +08:00
winlin
2fa151726b For #1592, rename ff_log_dir. 2020-02-05 12:15:44 +08:00
winlin
a99cee2819 For #1186, refactor security check. 3.0.114 2020-02-04 19:33:11 +08:00
winlin
b9d45ba7d9 For #1186, refactor security check. 3.0.114 2020-02-04 19:21:15 +08:00
winlin
c51c378869 For #1186, refactor security check. 3.0.114 2020-02-04 19:07:54 +08:00
winlin
c01806d5c4 Refine version3 2020-02-04 17:04:03 +08:00
winlin
4f39303f37 Fix #939, response right A/V flag in FLV header. 3.0.113 2020-02-04 17:02:02 +08:00
winlin
68efca4fa9 For #939, always enable fast FLV streaming. 2020-02-04 16:39:01 +08:00
winlin
a2a6ca8258 For #939, always enable fast FLV streaming. 2020-02-04 16:13:48 +08:00
winlin
d57c85827c Release 3.0-b0, 3.0.112 2020-02-02 11:15:08 +08:00
winlin
c9a2e19b2f Support isolate version file. 3.0.112 2020-01-29 20:30:58 +08:00
winlin
41f3925abc Add version file for srs3 2020-01-29 20:28:37 +08:00
winlin
23ece94064 Fix #1206, dispose ingester while server quiting. 3.0.111 2020-01-29 20:22:28 +08:00
winlin
a6f88805f3 Remove test code 2020-01-29 14:42:18 +08:00
winlin
31db28b70d Update version 2020-01-28 21:48:53 +08:00
winlin
c90f441655 Update version 2020-01-28 21:47:04 +08:00
winlin
7c3b3608c0 Update version 2020-01-28 21:46:19 +08:00
winlin
ec69b0786c Update version 2020-01-28 21:45:37 +08:00
winlin
afc0faf738 Use multiple revisions. 3.0.111 2020-01-28 21:42:48 +08:00
winlin
0fc026ef6b Update version 2020-01-28 21:38:28 +08:00
winlin
adf7ef4511 Fix #1230, racing condition in source fetch or create. 3.0.110 2020-01-28 21:35:06 +08:00
winlin
5d365bade8 Fix #1303, do not dispatch previous meta when not publishing. 3.0.109 2020-01-27 19:46:08 +08:00
winlin
01870cce56 Allow use libst.so for ST is MPL license. 2020-01-26 17:33:10 +08:00
winlin
7460729c0e Update readme 2020-01-26 14:16:50 +08:00
winlin
4b1108c821 How to speedup clone 2020-01-26 14:14:29 +08:00
winlin
fe78c75b0f Fix #607, set RTMP identifying recursive depth to 3. 2020-01-26 09:25:44 +08:00
winlin
2775a391e0 Fix #878, remove deprecated #EXT-X-ALLOW-CACHE for HLS. 3.0.108 2020-01-25 20:03:22 +08:00
winlin
74154cdfd9 Fix #703, drop video data util sps/pps. 3.0.107 2020-01-25 18:05:18 +08:00
winlin
978d5e993b Fix #1108, reap DVR tmp file when unpublish. 3.0.106 2020-01-25 15:04:34 +08:00
winlin
a1ca3774a4 Merge SRS2 2020-01-25 13:08:53 +08:00
winlin
235c889e14 Update config 2020-01-24 15:35:14 +08:00
winlin
6107db91f5 Release 3.0 alpha9, 3.0a9, 3.0.105 2020-01-21 16:14:15 +08:00
winlin
c3bf0cbe1b For #1547, check options for crossbuild. 2020-01-21 15:47:19 +08:00
winlin
ba61fe8bc5 Fix #1221, remove complex configure options. 3.0.104 2020-01-21 15:22:55 +08:00
winlin
0df108740a Fix #1547, support crossbuild for ARM/MIPS. 2020-01-21 13:59:43 +08:00
winlin
6af8e38017 For #1547, support setting cc/cxx/ar tools. 3.0.103 2020-01-21 10:28:25 +08:00
winlin
a6fe4e80d3 For #1547, remove the SRS_OSX macro in code 2020-01-20 11:25:39 +08:00
winlin
024433f327 For #1547, refine configure, remove some macros 2020-01-20 10:44:46 +08:00
winlin
84d69a51a4 Add new author lam2003<linmin3@yy.com> 2020-01-19 18:27:27 +08:00
winlin
1bf90a6e21 Ignore noreply user. 2020-01-19 18:25:29 +08:00
l
86d04a70ed Fix #1580, fix cid range problem. 3.0.102 2020-01-19 18:21:28 +08:00
winlin
9ac8585cf9 Fix codec check 2020-01-19 13:16:49 +08:00
winlin
3900179685 For #307, #1070, define FLV CodecID for AV1 and Opus. 3.0.101 2020-01-19 11:22:35 +08:00
winlin
bdd0b1f7a2 SRS is a live streaming cluster, high efficiency, stable and simple. SRS是一个流媒体直播集群,高效、稳定、易用,简单而快乐。 2020-01-18 19:54:26 +08:00
winlin
9dbd049e79 For #1568, extract SrsSourceManager from SrsSource. 2020-01-16 17:56:55 +08:00
winlin
fea293d0b1 Fix #1042, improve test coverage for core/kernel/protocol/service. 2020-01-16 14:37:30 +08:00
winlin
11c2ca3b0a word the cr comment 2020-01-16 14:33:48 +08:00
winlin
0e750ab3eb For #1575, use RTMP redirect as tcUrl and redirect2 as RTMP URL. 3.0.100 2020-01-16 14:28:05 +08:00
winlin
7240fe3040 For #1509, decrease the fast vector init size from 64KB to 64B. 3.0.99 2020-01-15 21:26:02 +08:00
winlin
857c783efc For #1509, release coroutine when source is idle. 3.0.98 2020-01-15 19:51:33 +08:00
winlin
816aa91a7f Fix utest bug, init fd 2020-01-13 14:48:49 +08:00
winlin
1f493cc037 Release 3.0 alpha8, 3.0.97 2020-01-10 18:20:37 +08:00
winlin
98df29c6fb For #1042, improve test coverage for service. 3.0.97 2020-01-10 11:36:38 +08:00
winlin
6c1067d56a Merge from 2.0 2020-01-09 10:20:49 +08:00
winlin
59bc00e038 Add Michael.Ma<wnpllr@gmail.com> 2020-01-08 18:07:50 +08:00
winlin
c08b6f1961 Merge 2.0, support logrotate copytruncate. 3.0.96 2020-01-08 18:05:42 +08:00
winlin
36bfbb902b Refien utest for log heaer generating. 2020-01-08 14:32:24 +08:00
winlin
80bac7d982 Improve test coverage for rtmp client service. 2020-01-08 14:26:38 +08:00
winlin
cc11f36940 Improve test coverage for log service. 2020-01-08 14:24:41 +08:00
winlin
2cc021b2d7 Improve test coverage for http client service. 2020-01-08 14:00:27 +08:00
winlin
06c1d4d7f9 Fix some warnings for compiler 2020-01-05 22:37:25 +08:00
winlin
69e2d94e50 Fix some warnings for compiler 2020-01-05 22:30:57 +08:00
winlin
10464a5fbe Always use string instance to avoid crash risk. 3.0.95 2020-01-05 22:17:15 +08:00
winlin
b794c9e4ec For #460, fix ipv6 hostport parsing bug. 3.0.94 2020-01-05 22:16:21 +08:00
winlin
76d92792b7 For #460, fix ipv6 intranet address filter bug. 3.0.93 2020-01-05 21:25:51 +08:00
winlin
bc6c61e546 Fix #1543, use getpeername to retrieve client ip. 3.0.92 2020-01-05 20:06:25 +08:00
winlin
498f3c5df9 Improve test coverage for service TCP/UDP. 2020-01-05 18:44:07 +08:00
winlin
42ee6570a7 Improve test coverage for service TCP/UDP. 2020-01-05 18:43:23 +08:00
winlin
02c1bd0946 Improve test coverage for service TCP/UDP. 2020-01-05 18:42:37 +08:00
winlin
265b70863c Improve test coverage for service TCP/UDP. 2020-01-05 18:37:20 +08:00
winlin
f5a8810f15 Update author for #1551. 2020-01-05 17:14:32 +08:00
winlin
9bd8b363b3 Improve test coverage for http service. 2020-01-05 17:02:57 +08:00
winlin
6d0ac35db9 Merge 2.0release #1551 2020-01-05 14:43:46 +08:00
winlin
79314f7d4a Improve test coverage for HTTP service 2020-01-03 13:31:08 +08:00
winlin
646eeb05e9 For #1042, improve test coverage for config. 3.0.91 2020-01-02 11:18:45 +08:00
winlin
fa7fd85ca6 Improve test coverage for config. 2020-01-02 11:08:18 +08:00
winlin
45aa325722 Improve test coverage for config. 2020-01-01 21:01:14 +08:00
winlin
4848d3ab91 Improve test coverage for config. 2020-01-01 17:15:21 +08:00
winlin
0fd0114ee6 Improve test coverage for config. 2020-01-01 17:14:59 +08:00
winlin
f7673f6009 Improve test coverage for config. 2020-01-01 16:06:12 +08:00
winlin
a9dba511ab Improve test coverage for config. 2020-01-01 16:04:35 +08:00
winlin
146a095b38 Improve test coverage for config. 2020-01-01 15:52:10 +08:00
winlin
2942955b30 Improve test coverage for config. 2020-01-01 15:49:04 +08:00
winlin
7136c7c9b8 Improve test coverage for config. 2020-01-01 14:21:24 +08:00
winlin
de87b64f59 Improve test coverage for config. 2020-01-01 14:12:36 +08:00
winlin
a71d93188b Improve test coverage for config. 2020-01-01 13:41:19 +08:00
winlin
36236192fa Improve test coverage for mp4 2020-01-01 12:00:48 +08:00
winlin
d2052fd4cd Support sequence header only for mp4 2020-01-01 11:54:53 +08:00
winlin
c3e0dcfa9e Improve test coverage for mp4 decoder 2019-12-31 19:37:48 +08:00
winlin
7597a956ed Improve test coverage for dash init encoder 2019-12-31 19:17:40 +08:00
winlin
1cfadfed3a Improve test coverage for mp4 boxes 2019-12-31 18:59:30 +08:00
winlin
e8dbee1474 Refine url/urn box dumps 2019-12-31 15:55:34 +08:00
winlin
9cb2449175 Fix mp4 url/urn bug. 2019-12-31 15:35:45 +08:00
winlin
adad90d316 Refactor the mock file reader/writer 2019-12-31 15:15:56 +08:00
winlin
d32a7e9770 Improve test coverage for mp4 box 2019-12-30 20:50:58 +08:00
winlin
f3831d2d5b Improve test coverage for mp4 dumps 2019-12-30 16:36:11 +08:00
winlin
b63f2f283d Fix mp4 security issue, check buffer when required size is variable. 2019-12-30 14:34:23 +08:00
winlin
9140e0f19d Improve test coverage for kernel mp4. 2019-12-30 13:50:19 +08:00
winlin
d783a12f89 Happy 2020 2019-12-30 10:10:35 +08:00
winlin
8075628d9e Fix utest fail. 2019-12-29 19:16:16 +08:00
winlin
041b95472a Release SRS3 alpha7, v3.0-a7, 3.0.90 2019-12-29 19:05:15 +08:00
winlin
eb8e7ad479 Fix #1255, support vhost/domain in query string for HTTP streaming. 3.0.90 2019-12-29 18:56:35 +08:00
winlin
8a28a11648 For #299, increase dash segment size for avsync issue. 3.0.89 2019-12-29 18:21:45 +08:00
winlin
d11a7b2e00 For #299, fix some bugs in dash, it works now. 3.0.88 2019-12-27 20:47:33 +08:00
winlin
043781fe81 Fix #1544, fix memory leaking for complex error. 3.0.87 2019-12-27 11:46:07 +08:00
winlin
4e7389b131 Update issue template 2019-12-27 11:16:14 +08:00
winlin
be0cb164ec Add links for flv.js, hls.js and dash.js 2019-12-27 10:40:44 +08:00
winlin
c2e9e96e28 Change the default page to srs_player 2019-12-27 09:11:26 +08:00
winlin
76a7985cbe For #1105, fix dash mp4 bug. 2019-12-26 18:39:14 +08:00
winlin
b9d720c927 For #1105, http server support mp4 range. 2019-12-26 18:33:52 +08:00
winlin
7584c47aaf Fix #1105, dvr mp4 supports playing on Chrome/Safari/Firefox. 3.0.86 2019-12-26 18:05:17 +08:00
winlin
c70bc01ba4 Merge 2.0 2019-12-26 12:32:32 +08:00
winlin
6afdeeee4e Release 3.0 alpha6, r3.0a6, 3.0.85 2019-12-26 12:25:41 +08:00
winlin
32a2b7f0a5 For #1488, improve coverage for parsing client ip. 2019-12-26 12:20:53 +08:00
winlin
2115d5d22a For #1488, add test and improve coverage for parsing client ip. 2019-12-26 12:07:52 +08:00
winlin
316cab794a For #1488, pass client ip to http callback.3.0.85 2019-12-26 11:42:19 +08:00
winlin
c5a8d21db6 For #1537, #1282, use new algorithm for arm. 2019-12-25 20:11:31 +08:00
winlin
84f6f3d051 For #1537, #1282, support aarch64 for armv8. 3.0.84 2019-12-25 19:58:15 +08:00
winlin
ea8111cff5 For #1537, support aarch64 for armv8. 3.0.84 2019-12-25 19:44:33 +08:00
winlin
0e0889af02 For #1538, fresh chunk allow fmt=0 or fmt=1. 3.0.83 2019-12-25 19:04:15 +08:00
winlin
416568f4ab Remove FFMPEG and NGINX, please use srs-docker instead 2019-12-25 18:39:01 +08:00
winlin
ff2001a612 Compress repository, remove gprof files. 2019-12-25 18:30:55 +08:00
winlin
a11461905b Remove FFMPEG and NGINX, please use srs-docker instead . 3.0.82 2019-12-25 18:29:07 +08:00
winlin
bf807778e5 For #1537, #1282, support multiple options for --extra-flags 2019-12-25 17:52:51 +08:00
winlin
f24694fc65 For #1537, #1282, remove cross-build, not used patches, directly build st. 2019-12-25 16:47:29 +08:00
winlin
f47e846bd2 For #1537, #1282, refine build st script 2019-12-25 16:26:40 +08:00
winlin
97bb8a5405 For #1537, #1282, support disable ASM to avoid building bug. 2019-12-25 16:22:00 +08:00
winlin
b672ad4b1f For #1537, #1282, sync with state-threads/srs 2019-12-25 16:09:25 +08:00
winlin
4e93ded864 For #1537, #1282, remove not used file st-1.9.zip 2019-12-25 16:05:50 +08:00
winlin
e42633cd65 For #1537, #1282, when not use builtin setjmp, donot compile md.S 2019-12-25 16:04:28 +08:00
winlin
916ec71801 For #1537, #1282, use ST source code in SRS 2019-12-25 15:55:56 +08:00
winlin
c91ffbee93 For #1537, #1282, remove not used patches, note the patch for ARM already merged to ST in SRS3 2019-12-25 15:49:25 +08:00
winlin
a0c631de9f For #1537, #1282, support --extra-flags for unknown CPU arch. 2019-12-25 15:46:58 +08:00
winlin
71810c0209 For #1537, disable crossbuild for ARM/MIPS. 2019-12-25 13:18:53 +08:00
winlin
dffc96d2fe For #1537, disable crossbuild for ARM/MIPS. 2019-12-25 13:17:49 +08:00
winlin
e6e4bd7fb4 Remove useless warning log for reloading. 2019-12-24 19:26:22 +08:00
winlin
e2def1b24f Ignore some coverage for mp4. 2019-12-24 17:42:00 +08:00
winlin
e2f86464c5 Ignore some coverage for ts. 2019-12-24 17:29:46 +08:00
winlin
995bd5cdd2 Update new AUTHORS 2019-12-24 17:29:30 +08:00
winlin
0c20a45f5c Ignore test coverage for some lines for mp4 2019-12-24 15:41:36 +08:00
winlin
a119305b31 Ignore coverage for codec sps-pps parsing. 2019-12-24 15:36:22 +08:00
winlin
aa4a27b9fa Ignore coverage for codec sps-pps parsing. 2019-12-24 15:35:19 +08:00
winlin
7eccc9da26 For #1508, support chunk length and content in multiple parts. 2019-12-24 14:58:35 +08:00
winlin
a35a7f915e Fix bug for HTTP write jsonp for srs-console. 2019-12-24 10:32:52 +08:00
winlin
40f6ecaee2 Merge SRS2 for running srs-librtmp on Windows. 3.0.80 2019-12-23 21:09:00 +08:00
winlin
6073cde63b Mark some features as experimental. 2019-12-23 14:08:11 +08:00
winlin
2d29e3c4e6 For #1535, deprecate Adobe FMS/AMS edge token traversing authentication. 3.0.79 2019-12-23 12:21:46 +08:00
winlin
9aaf5123ad For #1535, deprecate BWT(bandwith testing). 3.0.78 2019-12-23 12:10:35 +08:00
winlin
1b3fe4eb06 For #1535, deprecate Adobe HDS(f4m). 3.0.77 2019-12-23 12:01:50 +08:00
winlin
ae785eda8d Improve test coverage for kernel fast stream. 2019-12-20 18:56:53 +08:00
winlin
da7e76c96a For#1508, check the error correctly for strtol. 2019-12-20 16:48:51 +08:00
winlin
cab15c348c Fix #1508, http-client support read chunked response. 3.0.76 2019-12-20 16:09:37 +08:00
winlin
788b200e90 For #1508, check the error by http_errno for http-parser. 2019-12-20 16:08:24 +08:00
winlin
2b51cee3ef For #1508, check the chunk header length. 2019-12-20 14:51:01 +08:00
winlin
4382ced3bf For #1508, Refactor srs_is_digital, support all zeros. 2019-12-20 14:49:25 +08:00
winlin
cee4feda61 Fix make -jN random failed. 2019-12-20 11:49:27 +08:00
winlin
7f7b016b8e Modify issue template 2019-12-19 19:16:04 +08:00
winlin
c645be6b98 Modify issue template 2019-12-19 19:11:30 +08:00
winlin
78670d2f6d Modify issue template 2019-12-19 19:07:33 +08:00
winlin
bd0984e944 Release 3.0-a5 alpha5 3.0.75 2019-12-19 15:38:24 +08:00
winlin
fc9855bc7a Refine the RTMP iovs cache increasing to much faster. 2019-12-19 15:04:14 +08:00
winlin
49c737f996 Fix #1524, memory leak for amf0 strict array. 3.0.75 2019-12-19 14:39:34 +08:00
winlin
1e4f22f83d Fix random build failed bug for modules. 2019-12-19 14:30:34 +08:00
winlin
d7078a72d4 For #1520, add TODO list for configing server itself in coworker. 2019-12-19 14:15:21 +08:00
winlin
acfeb8a66f Fix #1520, #1223, bug for origin cluster 3+ servers. 3.0.74 2019-12-19 14:04:26 +08:00
winlin
0200baa179 Improve test coverage for protocols. 2019-12-18 21:19:42 +08:00
winlin
25f132ec2f Improve test coverage for protocols. 2019-12-18 21:18:11 +08:00
winlin
bf92172e62 Improve coverage for RAW AVC protocol. 2019-12-18 20:37:49 +08:00
winlin
4a5323b054 Improve coverage for RAW AVC protocol. 2019-12-18 20:27:48 +08:00
winlin
23a1674ce0 Improve coverage for RAW AVC protocol. 2019-12-18 20:13:11 +08:00
winlin
8047d0df45 For #1042, add test for RAW AVC protocol. 2019-12-18 15:50:17 +08:00
winlin
6eec7c1dfe Refactor the query string for srs-player 2019-12-18 14:46:21 +08:00
winlin
b52628ce01 Refactor the comments to use flash publisher 2019-12-18 14:37:39 +08:00
winlin
931496e3b9 Refactor the comments to use flash publisher 2019-12-18 14:37:10 +08:00
winlin
4e3650b8c7 Refactor the comments to use flash publisher 2019-12-18 14:35:43 +08:00
winlin
dd44d76d72 Refactor the comments to use flash publisher 2019-12-18 14:35:07 +08:00
winlin
7497df7a15 Refactor the comments to enable flash 2019-12-18 13:59:05 +08:00
winlin
4a5afe3428 Add tips when flash is disabled. 2019-12-18 12:06:32 +08:00
winlin
901c69b381 Update srs-player version 2019-12-18 11:54:17 +08:00
winlin
cef7ec79b3 Detect whether flash enabled for srs-bwt. 2019-12-18 11:50:43 +08:00
winlin
c830dc6700 Detect whether flash enabled for srs-publisher. 2019-12-18 11:33:34 +08:00
winlin
b0afc00733 Detect whether flash enabled for srs-player. 3.0.73 2019-12-18 11:06:01 +08:00
winlin
33c7f6d0e4 Temporarily disable chat demo page. 2019-12-18 09:16:56 +08:00
winlin
216a23f709 Fix the http implicit handler bug 2019-12-17 21:24:24 +08:00
winlin
b247c9759a Improve test coverage for http handler 2019-12-17 21:17:44 +08:00
winlin
6c50d85671 Improve test coverage for http message 2019-12-17 21:08:18 +08:00
winlin
43a5cea158 Improve test coverage for HTTP CORS 2019-12-17 21:03:28 +08:00
winlin
dc1afc142f Fix HTTP CORS bug when sending response for OPTIONS. 3.0.72 2019-12-17 20:52:10 +08:00
winlin
ec0fb82c0e Improve test coverage for http server mux. 2019-12-17 19:39:36 +08:00
winlin
81947df819 Enhance HTTP response write for final_request. 2019-12-17 19:09:39 +08:00
winlin
e27cc059e4 Ignore coverage for http-parser 2019-12-17 17:37:29 +08:00
winlin
df359f747a Ignore coverage for json-parser 2019-12-17 17:30:49 +08:00
winlin
191b07668d Refactor HTTP stream to disconnect client when unpublish 2019-12-17 16:54:06 +08:00
winlin
1e83da7812 Refactor HTTP recv request timeout to 15s. 2019-12-17 16:37:00 +08:00
winlin
2df1dcb05a Fix HTTP-FLV and VOD-FLV conflicting bug. 2019-12-17 16:01:04 +08:00
winlin
d9842b0371 Refactor HttpResponseWriter.write, default to single text mode. 2019-12-17 15:14:59 +08:00
winlin
8cdb7cc727 Add test for vod stream handler 2019-12-17 14:33:47 +08:00
winlin
97f2c5bf0c Refactor http static file server path resolving. 2019-12-16 20:07:06 +08:00
winlin
fa362607b2 Add test for http basic handler 2019-12-16 19:32:41 +08:00
winlin
6bad973a7c Fix HTTP parser bug for parsing header from multiple pieces of data. 2019-12-16 18:21:39 +08:00
winlin
45ed458927 Eliminate dead code of ts cache for HTTP message 2019-12-16 16:07:17 +08:00
winlin
ca2b68f428 Refactor header of HTTP message by using SrsHttpHeader. 2019-12-16 16:00:02 +08:00
winlin
dcb7b6aae0 Refactor HTTP Message by decoupling with http_parser 2019-12-16 15:12:26 +08:00
winlin
547cd4f518 Word the comments about the order of HTTP header 2019-12-16 12:25:29 +08:00
winlin
0886acbdb7 Improve test coverage for HTTP header. 2019-12-16 12:11:29 +08:00
winlin
8c10c26f00 Improve the coverage for HTTP error response. 2019-12-16 11:36:39 +08:00
winlin
474266eae7 Refine the comments for http content-type detecting 2019-12-14 23:34:09 +08:00
winlin
4758a284d7 Add test for http status. 2019-12-14 10:12:25 +08:00
winlin
6ce04051e4 Improve test coverage of status for HTTP. 2019-12-13 20:05:18 +08:00
winlin
0394d95e4b Refine file structure for RTMP/HTTP protocol stack utest. 2019-12-13 20:04:33 +08:00
winlin
8d9554df8e Remove dead code in SrsRtmpClient::handshake 2019-12-13 16:31:32 +08:00
winlin
82cbcf442e Release 3.0-alpha4 3.0.71 2019-12-13 11:05:29 +08:00
winlin
1c391c85ae Merge 2.0release 2019-12-13 10:47:04 +08:00
winlin
ebed5472c1 Refine issue template 2019-12-12 19:05:44 +08:00
winlin
dfe086f3f3
Rename -bug.md to ISSUE_TEMPLATE 2019-12-12 19:04:18 +08:00
winlin
37f7312ea1
Delete ---.md 2019-12-12 19:02:27 +08:00
winlin
6f453e7f46 For #547, #1506, default hls_dts_directly to on. 3.0.71 2019-12-12 16:51:34 +08:00
winlin
f298d5204b For #1042, cover RTMP other codes 2019-12-12 15:58:56 +08:00
winlin
cfcb3ce7b2 For #1042, cover RTMP other codes 2019-12-12 15:46:46 +08:00
winlin
2731fe1f3e SrsPacket supports converting to message, so can be sent by one API. 2019-12-12 15:11:31 +08:00
winlin
82c4f41975 For #1042, cover RTMP other codes 2019-12-12 10:12:31 +08:00
winlin
bd3d9f32b7 For #1042, cover RTMP other codes 2019-12-11 20:22:39 +08:00
winlin
22d4159373 For #1042, cover RTMP server response commands. 2019-12-11 18:43:37 +08:00
winlin
9c62a68e15 For #1042, cover RTMP server response commands. 2019-12-11 18:25:47 +08:00
winlin
5516877867 For #1042, cover RTMP client/server protocol. 2019-12-11 18:12:06 +08:00
winlin
4f298134af Fix #1445, limit the createStream recursive depth. 3.0.70 2019-12-11 17:56:31 +08:00
winlin
41a9f15626 For #1042, cover RTMP client protocol. 2019-12-11 15:59:29 +08:00
winlin
69817a9f34 For #1042, cover RTMP handshake protocol. 2019-12-11 15:02:35 +08:00
winlin
f51f1efe42 For #1042, cover RTMP handshake protocol. 2019-12-11 14:32:57 +08:00
winlin
7bd7e1ccca Refine the circleci codecov script. 2019-12-11 12:06:28 +08:00
winlin
06b1b48e7a Fix #1229, vsnprintf security issue. 2019-12-11 11:58:09 +08:00
winlin
78da67e8d1 For #1229, fix the security risk in logger. 3.0.69 2019-12-11 11:56:00 +08:00
winlin
ad70589347 For #1229, fix the security risk in HDS. 3.0.69 2019-12-11 11:31:32 +08:00
winlin
35e0ec27ed The official website https://ossrs.net recovered 2019-12-11 07:39:50 +08:00
winlin
d866c77265 Fix the path for circleci 2019-12-11 07:23:54 +08:00
winlin
20fbb4466f Fix the path for circleci 2019-12-11 07:09:28 +08:00
winlin
f1cca0c360 Fix the path for circleci 2019-12-11 07:02:42 +08:00
winlin
1337f3e243 Fix the path for circleci 2019-12-11 06:54:07 +08:00
winlin
0c673deb81 Fix the path for circleci 2019-12-10 23:25:15 +08:00
winlin
fae3a714a2 Fix the path for circleci 2019-12-10 23:21:26 +08:00
winlin
4c93d3a4c7 Fix the path for circleci 2019-12-10 23:13:56 +08:00
winlin
49e5f8896f Fix the path for circleci 2019-12-10 23:03:02 +08:00
winlin
6ee4473f7a Fix the path for circleci 2019-12-10 22:58:30 +08:00
winlin
d4eb9cf4aa Fix the path for circleci 2019-12-10 22:30:23 +08:00
winlin
749b9fe444 Fix the path for circleci 2019-12-10 22:24:16 +08:00
winlin
0677e378ba Fix the path for circleci 2019-12-10 22:18:31 +08:00
winlin
e3077a8034 Fix the path for circleci 2019-12-10 22:09:52 +08:00
winlin
1b2aff84bc Fix the path for circleci 2019-12-10 21:45:58 +08:00
winlin
c90e321f9c Fix the path for circleci 2019-12-10 21:34:20 +08:00
winlin
94adda5dae Fix the circleci path 2019-12-10 21:14:01 +08:00
winlin
979f82e0dc Fix the circleci path. 2019-12-10 20:32:33 +08:00
winlin
d908ee73db Make the hls_dipose more specific 2019-12-10 16:48:35 +08:00
winlin
1c227f4f8a Refine logger for hls_dts_directly 2019-12-10 15:59:15 +08:00
winlin
b4870a6d6f Fix #1506, support directly turn FLV timestamp to TS DTS. 3.0.68 2019-12-05 20:47:23 +08:00
winlin
31f341e205 For #1506, refine the AAC samples guess algorithm. 2019-12-05 20:16:23 +08:00
winlin
52c6c7c45d For #1506, ignore video when codec is unknown. 2019-12-05 19:21:43 +08:00
winlin
65c66592e9 Refine statistic url 2019-12-04 10:47:02 +08:00
winlin
e59d29a58b Merge branch '2.0release' into 3.0release 2019-12-03 19:52:44 +08:00
winlin
2d85b036cb Refine stat for player index 2019-12-03 18:26:01 +08:00
winlin
25749c64d4 Merge master 2019-12-03 18:24:32 +08:00
winlin
7bfa581518 Merge 2.0release 2019-12-03 18:24:09 +08:00
winlin
b42468d168 Update readme with statistics 2019-12-03 18:23:28 +08:00
winlin
19a4cc46c8 Update readme with statistics 2019-12-03 18:22:48 +08:00
winlin
7d07b9d82c Fix circleci build failed, use the right docker 2019-12-03 10:48:51 +08:00
winlin
643d06473f Refine player with statistics. 2019-12-03 10:18:13 +08:00
winlin
e3488378a4 Refine the readme, remove download site, recommend use docker 2019-12-02 18:41:17 +08:00
winlin
1df1485d34 Update readme about run SRS in docker. 2019-12-02 18:06:02 +08:00
winlin
ef1f6c189e Fix the link problem 2019-12-02 16:33:49 +08:00
winlin
cedf2a603d Update 2019-12-02 15:01:25 +08:00
winlin
67af179352 Release v3.0-a3, 3.0.67 2019-12-01 19:30:08 +08:00
winlin
5a3fd1e68a Release v3.0-a2, 3.0.67 2019-12-01 19:24:17 +08:00
winlin
75fd041279 Release v3.0-a2 2019-11-30 19:16:12 +08:00
winlin
517974d451 Refine redirect flow for origin cluster 2019-11-30 19:06:41 +08:00
winlin
e5285ecabf Fix #1501, use request ip for origin cluster. 3.0.66 2019-11-30 18:50:24 +08:00
winlin
488f16f60c Random tid for docker. 3.0.65 2019-11-30 17:34:25 +08:00
winlin
4cd03a7c06 Refine debug info for edge. 3.0.64 2019-11-30 17:31:27 +08:00
winlin
02f459f784 Update bug template 2019-11-30 13:58:10 +08:00
winlin
fa621433b5 Merge SRS2 2019-11-29 19:21:53 +08:00
winlin
ba02640c46 Refine tid in error log 2019-11-29 12:33:32 +08:00
winlin
f1c42f7ee0 Change docker centos to dev 2019-11-29 12:33:09 +08:00
winlin
7bd704e695 Cover protocol stack RTMP. 3.0.63 2019-11-22 12:06:15 +08:00
winlin
2731afc161 Cover protocol stack RTMP. 3.0.63 2019-11-20 14:08:53 +08:00
winlin
40e60aff4d Cover protocol stack RTMP. 3.0.63 2019-11-20 11:14:02 +08:00
winlin
3365bc6b02 Cover protocol stack RTMP. 3.0.63 2019-11-20 11:05:56 +08:00
winlin
6eab86644e Cover protocol stack RTMP. 3.0.63 2019-11-19 18:18:43 +08:00
winlin
c8bb7e71c9 Cover protocol stack RTMP. 3.0.63 2019-11-19 11:47:31 +08:00
winlin
4e8acf80cb Update issue templates 2019-11-18 17:13:26 +08:00
winlin
0529821580 Update issue templates 2019-11-18 17:08:33 +08:00
winlin
ea96e414ca Cover protocol stack RTMP. 3.0.63 2019-11-08 09:26:57 +08:00
winlin
78e5f46ff7 Cover protocol stack RTMP. 3.0.63 2019-11-05 14:00:00 +08:00
winlin
466f99a1c8 Cover protocol stack RTMP. 3.0.63 2019-11-05 10:31:21 +08:00
winlin
ce8f778fe6 Cover protocol stack RTMP. 3.0.63 2019-11-05 10:17:06 +08:00
winlin
918a2943c9 Cover protocol stack RTMP. 3.0.63 2019-11-05 09:55:45 +08:00
winlin
9067786bd3 Cover protocol stack RTMP. 3.0.63 2019-11-04 09:31:30 +08:00
winlin
a726a14b37 Cover protocol stack RTMP. 3.0.63 2019-10-29 10:02:03 +08:00
winlin
8c214dc967 Cover protocol stack RTMP. 3.0.63 2019-10-28 08:57:11 +08:00
winlin
cf9a6b4f48 Cover protocol stack RTMP. 3.0.63 2019-10-28 08:41:49 +08:00
winlin
1583f6cc3f Cover protocol stack RTMP. 3.0.63 2019-10-25 08:18:21 +08:00
winlin
2b2a62ccba Cover protocol stack RTMP. 0.6.63 2019-10-23 09:26:10 +08:00
winlin
f99ca04bd5 Cover JSON codec. 3.0.62 2019-10-23 08:59:30 +08:00
winlin
1b2449ca3f Cover JSON codec. 3.0.62 2019-10-23 08:47:02 +08:00
winlin
48970389ba Cover JSON codec. 3.0.62 2019-10-22 10:06:12 +08:00
winlin
e816ac28d2 Cover JSON codec. 3.0.62 2019-10-22 10:02:37 +08:00
winlin
1ebec34d5b Cover JSON codec. 3.0.62 2019-10-22 09:58:09 +08:00
winlin
e683f07715 Cover JSON codec. 3.0.62 2019-10-22 09:01:29 +08:00
winlin
c7602d8cee Cover JSON codec. 3.0.62 2019-10-22 08:54:29 +08:00
winlin
aee704fd1f Cover AMF0 codec. 3.0.61 2019-10-22 08:30:46 +08:00
winlin
0a9659b749 Cover AMF0 codec. 3.0.61 2019-10-21 09:29:42 +08:00
winlin
232024ef67 AMF0: Refine utest 2019-10-18 08:54:59 +08:00
winlin
9542cd2ba5 AMF0: Refine utest 2019-10-18 08:54:13 +08:00
winlin
026b2a2a1e Cover AMF0 codec. 3.0.61 2019-10-18 00:48:49 +00:00
winlin
dccf814794 Use http://ossrs.net:8000 as homepage. 2019-10-13 08:51:36 +08:00
winlin
da46091d3c Cover AMF0 codec. 3.0.61 2019-10-12 09:27:32 +08:00
winlin
99ca2b9567 Cover AMF0 codec. 3.0.61 2019-10-12 08:56:04 +08:00
winlin
f8943f8f7d Cover AMF0 codec. 3.0.61 2019-10-12 08:39:40 +08:00
winlin
ebe8fa44e5 Cover AMF0 codec. 3.0.61 2019-10-12 00:36:52 +00:00
winlin
9d1249e256 Cover AMF0 codec. 3.0.61 2019-10-12 00:32:25 +00:00
winlin
b2e4a5f834 Cover AMF0 codec. 3.0.61 2019-10-11 09:28:53 +08:00
winlin
f24d82fada Cover AMF0 codec. 3.0.61 2019-10-10 08:49:57 +08:00
winlin
20e2cd1199 Update readme 2019-10-10 08:06:09 +08:00
winlin
2579c5fc9e Release 3.0a1, 3.0.60 2019-10-07 20:24:28 +08:00
winlin
8ca7f7e5a4 Support log rotate by init.d command. 3.0.60 2019-10-07 17:44:25 +08:00
winlin
e045b0a619 We prefer ipv4, only use ipv6 if ipv4 is disabled. 3.0.59 2019-10-07 10:34:55 +08:00
winlin
b0227e0d22 Fix bug for package script 2019-10-05 20:46:44 +08:00
winlin
7af087652f Add uninstall script 2019-10-05 20:43:04 +08:00
winlin
254549e3f4 Add uninstall script 2019-10-05 20:40:45 +08:00
winlin
5d9bc0658e Fix package bug 2019-10-05 20:37:25 +08:00
winlin
64288d1f1e Support systemctl service for CentOS7. 3.0.58 2019-10-05 20:33:26 +08:00
winlin
f6fc31db66 Add config files for go-oryx 2019-10-05 17:02:25 +08:00
winlin
d42f0d8ffb Remove skype 2019-10-04 20:59:35 +08:00
winlin
9d90a8177f Disable SO_REUSEPORT if not supported. 3.0.57 2019-10-04 20:02:51 +08:00
winlin
6f5809c80b Update README 2019-10-04 19:37:42 +08:00
winlin
e7e9fea866 Release 3.0 alpha0, 3.0.56 2019-10-04 19:25:58 +08:00
winlin
db077254b2 Update README 2019-10-04 19:18:55 +08:00
winlin
2c59aa1c69 Update README 2019-10-04 19:13:52 +08:00
winlin
88df9a2497 Support go-oryx rtmplb with proxy protocol. 3.0.56 2019-10-04 19:03:34 +08:00
winlin
130c545f9a Refine origin cluster log 2019-10-04 06:51:15 +08:00
winlin
3483c1526f Update README 2019-10-03 16:47:09 +08:00
winlin
bccb3ce98f Update README 2019-10-03 16:12:06 +08:00
winlin
8182814965 Update README 2019-10-03 16:11:13 +08:00
winlin
d3b142a0d9 Fix #775, Support SO_REUSEPORT. 3.0.54 2019-10-03 16:10:22 +08:00
winlin
1a65927b1b Remvoe HSTRS warning. 2019-10-03 13:18:28 +08:00
winlin
0741b64b25 Remove KAFKA. 3.0.53 2019-10-03 12:49:22 +08:00
winlin
306ed8dbc8 Remove KAFKA. 3.0.53 2019-10-03 12:49:01 +08:00
winlin
5d17bb8bb0 Remove KAFKA. 3.0.53 2019-10-03 12:45:38 +08:00
winlin
bb3e8a41d1 Cover all kernel flv. 2019-05-23 07:53:03 +08:00
winlin
32b53de46d Cover FLV decoder 2019-05-21 08:51:58 +08:00
winlin
8311f0dc5a Cover FLV decoder 2019-05-21 08:45:53 +08:00
winlin
ea9c4f89af Covert FLV Vod decoder. 2019-05-21 08:43:20 +08:00
winlin
3bd7978b59 Cover FLV decoder. 2019-05-21 08:31:00 +08:00
winlin
7aa5fbee85 Cover FLV transmux. 2019-05-21 08:20:04 +08:00
winlin
f760c04340 Cover FLV vod open 2019-05-20 09:00:16 +08:00
winlin
dd4ccfab79 Cover shared ptr message. 2019-05-20 08:45:42 +08:00
winlin
9cdd506b4f Deprecated srs-librtmp. 2019-05-17 08:14:26 +08:00
winlin
8b595c4cdf Cover more kernel time. 2019-05-15 08:57:46 +08:00
winlin
f7994b85eb Cover more kernel codec. 2019-05-15 08:44:38 +08:00
winlin
77cc148608 Refine utest 2019-05-14 08:42:46 +08:00
winlin
58561b9f76 Refine utest 2019-05-14 08:40:22 +08:00
winlin
c10671cbb3 Cover all kernel file. 2019-05-14 08:24:43 +08:00
winlin
13c4498e11 Cover mp4 header. 2019-05-14 08:17:39 +08:00
winlin
1605000817 Covert Kernel File reader/writer. 3.0.52 2019-05-14 08:13:27 +08:00
winlin
d5661dcc4e Cover kernel file writer. 2019-05-13 08:49:38 +08:00
winlin
a7e0d672a7 Cover kernel file writer. 2019-05-13 08:48:53 +08:00
winlin
6ac5b0a006 Cover tcp socket IO. 2019-05-13 08:08:41 +08:00
winlin
467d5e5f50 Fix build failed bug. 2019-05-09 08:51:14 +08:00
winlin
ccba55cdd8 Migrate is_never_timeout to utility. 2019-05-09 08:42:53 +08:00
winlin
1b37b90b8f Covert tcp read, write and readfully. 2019-05-09 08:38:54 +08:00
winlin
38a6f5e6cf Support TCP server utest. 2019-05-09 08:05:27 +08:00
winlin
9366161871 Refine utest for tcp connection. 2019-05-09 07:54:21 +08:00
winlin
5d8fb01b45 Fix #1352, fix typo of daemon. 2019-05-07 07:46:20 +08:00
winlin
ffe391aa49 Fix HLS no PMT/PAT bug. 2019-05-07 07:40:19 +08:00
winlin
1d3afa5ab9 Add utest for tcp server 2019-05-06 09:53:55 +08:00
winlin
c71b867b4f Refine comments. 2019-05-06 07:43:05 +08:00
winlin
bf2a74f8da Refine readme. 2019-05-05 08:48:53 +08:00
winlin
3d57c1c9bc Refine ST service. 2019-05-05 08:45:11 +08:00
winlin
202a584aab Refine ST service. 2019-05-05 08:17:48 +08:00
winlin
a4160308f5 Refine comments. 2019-05-05 07:55:55 +08:00
winlin
ad1197e706 Update readme 2019-05-05 07:45:49 +08:00
winlin
6730f08f45 Refine core.hpp 2019-05-05 07:44:39 +08:00
winlin
b02527dec0 Refine usage. 2019-04-30 09:15:06 +08:00
winlin
2de3045b25 Remove noisy informations. 2019-04-30 08:53:51 +08:00
winlin
6dbe79ad02 Remove noisy informations. 2019-04-30 08:43:12 +08:00
winlin
ad3749a4d5 Remove noisy informations. 2019-04-30 08:38:57 +08:00
winlin
0564cdedec Refine typo in comments. 2019-04-30 08:31:36 +08:00
winlin
6b2c71d385 Refine typo in files. 3.0.51 2019-04-30 08:30:13 +08:00
winlin
45009785fb Refine typo in app. 2019-04-30 08:24:52 +08:00
winlin
aac8a13f42 Refine typo in app. 2019-04-28 09:08:05 +08:00
winlin
4d25520f99 Refine typo in service. 2019-04-28 08:23:16 +08:00
winlin
224d7c539f Refine typo in service. 2019-04-28 08:21:48 +08:00
winlin
fbe40dc42c Refine code 2019-04-25 11:04:10 +08:00
winlin
c933f8a870 Upgrade http-parser from 2.1 to 2.9.2 and cover it. 3.0.50 2019-04-25 10:41:59 +08:00
winlin
8a94ac4b49 Upgrade http-parser to 2.9.2 2019-04-25 10:39:38 +08:00
winlin
0ee386b656 Refine http parser code. 2019-04-25 08:51:38 +08:00
winlin
cfc92d5e93 Use http-parser 2.9.2 2019-04-24 09:37:25 +08:00
winlin
646d490a18 Reset http-parser 2.1 2019-04-23 08:31:21 +08:00
winlin
6e9bba4220 Refine SrsHttpUri. 2019-04-23 08:26:15 +08:00
winlin
b285029e15 Refine SrsHttpUri.get_uri_field, without depends on http parser. 2019-04-23 08:17:59 +08:00
winlin
8bc77387ff Refine typo in protocol. 2019-04-23 08:06:50 +08:00
winlin
35fe05d62c Refine typo in kernel. 2019-04-22 09:19:05 +08:00
winlin
735176cab4 Refine typo for core 2019-04-22 08:21:56 +08:00
winlin
98adbc4130 Refine typo. 2019-04-22 08:19:03 +08:00
winlin
394cdb5f04 Refine in time unit. 3.0.49 2019-04-22 08:12:17 +08:00
winlin
b2f598dede Refine SrsStSocket in time unit. 2019-04-22 08:07:37 +08:00
winlin
e436cc5665 Refine SrsBasicRtmpClient in time unit. 2019-04-22 08:03:12 +08:00
winlin
c6dcc76fea Refine SrsRequest.duration in time unit. 2019-04-19 08:48:44 +08:00
winlin
cfab73b552 Refine SrsWallClock and SrsKbps in time unit. 2019-04-19 08:39:38 +08:00
winlin
5560b529a7 Remove unused macros in ts. 2019-04-19 08:06:44 +08:00
winlin
73e71d26ea Refine SrsGopCache::start_time in time unit. 2019-04-19 08:04:09 +08:00
winlin
1626942d29 Fix SrsHlsMuxer::segment_close bug, reopen segment when close failed. 2019-04-18 09:28:08 +08:00
winlin
d306ee7506 Refine ms in time unit 2019-04-18 08:50:43 +08:00
winlin
5af572ab50 Refine SrsRtmpConn.duration in time unit. 2019-04-18 08:46:42 +08:00
winlin
f6f49c68da Refine SrsRecvThread timeout in time unit 2019-04-18 08:42:43 +08:00
winlin
6b587c5e0f Refine SrsUdpPacketRecvCycleInterval in time unit. 2019-04-18 08:17:37 +08:00
winlin
283c4c7449 Refine SrsPithyPrint.age or SrsIngesterFFMPEG.alive in time unit. 2019-04-18 08:15:55 +08:00
winlin
522cbf1df8 Refine SrsHourGlass in time unit. 2019-04-18 08:11:16 +08:00
winlin
f5a1f9b774 Refine SrsFragment.start_dts in time unit 2019-04-18 08:01:17 +08:00
winlin
288bed6e26 Refine SrsTcpClient.timeout in time unit. 2019-04-18 07:58:37 +08:00
winlin
33c66b64c5 Refine name TMMS to TIMEOUT 2019-04-18 07:47:35 +08:00
winlin
5505eceeac Refine SrsTcpClient.timeout in time unit. 2019-04-18 07:43:51 +08:00
winlin
feb34ed225 Refine SrsStSocket in time unit 2019-04-17 09:21:38 +08:00
winlin
5a45fd98c3 Refine get_recv_timeout and is_never_timeout in time unit 2019-04-17 08:38:34 +08:00
winlin
d3dc45f357 Refine set_recv_timeout in time unit 2019-04-17 08:31:53 +08:00
winlin
38bbf6b111 Refine get_send_timeout in time unit 2019-04-17 08:23:15 +08:00
winlin
f4bee37e76 Refine set_send_timeout in time unit 2019-04-17 08:18:37 +08:00
winlin
a1398892d0 Refine const timeouts in time unit 2019-04-17 08:08:31 +08:00
winlin
61afca7160 Refine SrsTcpClient timeout in time unit 2019-04-17 07:56:28 +08:00
winlin
e9770933a6 Refine dash controller publish or unpublish 2019-04-17 07:34:01 +08:00
winlin
6380e8f1c0 Fix HLS segment close bug 2019-04-16 09:32:26 +08:00
winlin
138d1e3cad Refine get_vhost_http_remux_fast_cache in time unit 2019-04-16 08:50:48 +08:00
winlin
010e35bec2 Refine get_hds_fragment and get_hds_window in time unit 2019-04-16 08:24:11 +08:00
winlin
917f6d066d Refine get_hls_window in time unit 2019-04-16 08:20:32 +08:00
winlin
ca705a6f62 Refine get_hls_fragment in time unit 2019-04-16 08:14:12 +08:00
winlin
402e614471 Refine get_send_min_interval in time unit 2019-04-16 07:59:27 +08:00
winlin
c1b64ba24f Refine get_queue_length and set_queue_size in time unit 2019-04-16 07:55:19 +08:00
winlin
e3983b3513 Merge 2.0 2019-04-15 08:19:16 +08:00
winlin
465d255940 Refine SRS_AUTO_HLS_SEGMENT_MIN_DURATION_MS in time unit 2019-04-15 07:56:16 +08:00
winlin
980c32aee6 Refine on_hls duration in time unit 2019-04-15 07:53:29 +08:00
winlin
5f3d09c8a0 Refine hls muxer duration in time duration. 2019-04-15 07:47:37 +08:00
winlin
41d1e91540 Fix start and end time bug 2019-04-12 10:00:39 +08:00
winlin
9b91c10e52 Fix timeout bug, use 30s as RTMP default timeout 2019-04-12 08:29:10 +08:00
winlin
bc1189caee Refine SrsFragment.duration in time unit. 2019-04-12 08:04:06 +08:00
winlin
0879bef9b2 Refine SRS_CONSTS_NO_TMMS to SRS_UTIME_NO_TIMEOUT 2019-04-11 09:33:26 +08:00
winlin
f8e6de71f3 Refine headers 2019-04-11 09:28:51 +08:00
winlin
53357e92fe Refine headers 2019-04-11 09:27:16 +08:00
winlin
92980a0ca2 Refine SRS_CONSTS_RTMP_TMMS in time unit 2019-04-11 09:18:20 +08:00
winlin
5b0e0d0838 Refine SRS_CONSTS_RTMP_PULSE_TMMS in time unit 2019-04-11 08:43:42 +08:00
winlin
695d430dcf Refine SrsMessageQueue.duration in time unit. 2019-04-11 08:35:57 +08:00
winlin
170cca1f58 Refine srs_get_system_startup_time in time unit 2019-04-10 09:11:54 +08:00
winlin
6c12aa0eca Refine srs_update_system_time in time unit 2019-04-10 09:07:03 +08:00
winlin
9b7c0802a9 Refine srs_update_system_time in time unit 2019-04-10 08:32:46 +08:00
winlin
9b1222a79c Refine get_publish_normal_timeout in time unit 2019-04-10 07:58:39 +08:00
winlin
170872135d Refine get_publish_1stpkt_timeout in time unit 2019-04-10 07:53:09 +08:00
winlin
d6828a3e58 Refine get_mw_sleep in time unit 2019-04-09 09:39:16 +08:00
winlin
839a496d50 Refine get_mr_sleep in time unit 2019-04-09 09:20:44 +08:00
winlin
5df8f2f6c1 Refine get_pithy_print in time unit 2019-04-09 08:55:54 +08:00
winlin
60f9561d2d Refine get_heartbeat_interval in time unit 2019-04-09 08:47:18 +08:00
winlin
5937304717 Refine get_dash_timeshift in time unit 2019-04-08 09:20:02 +08:00
winlin
12cf17ef6b Refine get_dash_update_period in time unit 2019-04-08 09:10:06 +08:00
winlin
4302ab7708 Refine get_dash_fragment to time unit 2019-04-08 09:02:39 +08:00
winlin
bb6389143f Refine get_bw_check_interval in time unit 2019-04-08 08:46:22 +08:00
winlin
74c1944e15 Refine config, allow parse multiple times. 2019-04-08 08:31:58 +08:00
winlin
6239dfa489 Apply time unit 2019-04-07 16:25:52 +08:00
winlin
7037f6a197 Cover more ST Coroutine code 2019-04-07 15:22:09 +08:00
winlin
1ce040cc2c Cover more ST Coroutine code 2019-04-07 14:35:11 +08:00
winlin
3d5508e088 Cover more ST Coroutine code 2019-04-07 13:52:16 +08:00
winlin
a9a720e32f Cover ST Coroutine and time unit. 3.0.48 2019-04-07 12:59:37 +08:00
winlin
f2b4bc7110 Fix #1304, Fix ST coroutine pull error. 3.0.47 2019-04-06 16:10:33 +08:00
winlin
23a2d8eefd Support HTTP-FLV params. 3.0.46 2019-04-06 15:42:24 +08:00
winlin
633a9a0d35 Merge #1324, Remove dead code 2019-04-05 18:55:33 +08:00
winlin
b9750baa52 For #1339, Support HTTP-FLV params. 2019-04-05 18:44:50 +08:00
winlin
d5ea3c39b3 Update readme 2019-02-11 11:30:10 +08:00
winlin
84438b5c0f Update readme 2019-02-11 11:22:35 +08:00
winlin
251f19718e CI: Cover kernel mp4 print box 2019-02-07 22:49:41 +08:00
winlin
663a003fa5 Update reamde 2019-02-07 21:06:25 +08:00
winlin
f7b2ee4cc9 CI: Cover kernel utility 2019-02-07 20:58:33 +08:00
winlin
a8408de972 CI: Cover kernel mp4 2019-02-05 20:15:32 +08:00
winlin
a0ba17b397 CI: Cover kernel ts 2019-02-05 16:49:29 +08:00
winlin
073d42ca7d CI: Refine hls ts context writer 2019-02-05 16:26:43 +08:00
winlin
36c41715e7 CI: Cover kernel ts 2019-02-05 09:57:06 +08:00
winlin
8eccfeceb9 CI: Cover kernel ts 2019-02-05 08:33:29 +08:00
winlin
3f59c7885e CI: Cover kernel ts 2019-02-04 16:12:37 +08:00
winlin
4187fa0068 CI: Cover kernel utility 2019-02-04 15:11:41 +08:00
winlin
572ce5ccff CI: Cover kernel mp3 2019-02-04 14:24:31 +08:00
winlin
39541b51a1 CI: Cover all kernel log 2019-02-04 13:41:09 +08:00
winlin
492db1a904 CI: Cover kernel flv 2019-02-04 13:15:11 +08:00
winlin
2fec88b769 CI: Fix kernel file case failed. 2019-02-04 12:54:31 +08:00
winlin
ec16e53802 CI: Cover kernel file 2019-02-04 12:48:56 +08:00
winlin
3064b941d5 CI: Cover kernel codec av frame and format 2019-02-04 12:05:07 +08:00
winlin
2bdba63b0b CI: Cover kernel codec 2019-02-03 22:21:52 +08:00
winlin
c2a938473a CI: Cover kernel codec 2019-02-03 22:03:15 +08:00
winlin
1df1d84766 CI: Cover kernel LB round robin 2019-02-03 21:23:06 +08:00
winlin
5b311a06b7 CI: Verify kernel aac write ADTS packet 2019-02-03 21:14:14 +08:00
winlin
917cb4a299 CI: Cover all kernel aac 2019-02-03 20:58:04 +08:00
winlin
2ae3440128 CI: Cover all kernel error 2019-02-03 12:56:29 +08:00
winlin
3cd3739433 CI: Cover all kernel error 2019-02-03 12:51:48 +08:00
winlin
8c9857ff6f CI: Remove macros for utest 2019-02-03 12:38:07 +08:00
winlin
bfeea72eac CI: Cover all kernel buffer 2019-02-03 12:28:18 +08:00
winlin
a2b0767874 Fix build failed. 2019-02-03 09:38:20 +08:00
winlin
c646e3f287 CI: Research support codecov 2019-02-03 09:27:08 +08:00
winlin
19f1bf4e27 Update Readme 2019-02-02 21:54:11 +08:00
winlin
a25efa3764 CI: Update codecov badge 2019-02-02 21:51:08 +08:00
winlin
7243d8e7b8 CI: Support codecov 2019-02-02 21:42:03 +08:00
winlin
62087fdb05 Merge 2.0release 2019-02-02 20:24:26 +08:00
winlin
1e87623a70 CI: Update badges 2019-02-02 20:08:49 +08:00
winlin
4ceef56f1a CI: Migrate to Circle2.0 2019-02-02 20:00:17 +08:00
winlin
bcfb867e2e CI: Migrate to Circle2.0 2019-02-02 19:57:29 +08:00
winlin
b4619e3393 Kbps: Remove the union for kbps slice 2019-02-02 18:20:19 +08:00
winlin
98706f793e Support Opus audio-level 2019-01-17 16:01:43 +08:00
winlin
f1b1f78c4e Parse Opus for tools 2019-01-17 11:35:15 +08:00
winlin
e77b570636 Add codec OPUS/HEVC to FLV 2019-01-17 09:24:17 +08:00
winlin
b2d1d84634 Change to 2019 2019-01-01 21:37:28 +08:00
winlin
66198b6f78 Add utest for RTMP protocol 2019-01-01 21:05:52 +08:00
winlin
a2d6566019 Add kernel utility utest 2019-01-01 20:19:44 +08:00
winlin
6e44aa4a4f Cover Kbps statistic 2019-01-01 18:22:11 +08:00
winlin
6e9c7dd11e Add utest for SrsKbps as RAW statistics 2019-01-01 17:44:39 +08:00
winlin
6234905532 Refactor ISrsKbpsDelta 2019-01-01 17:36:27 +08:00
winlin
dcebf8a31f Refine kbps 2019-01-01 14:04:50 +08:00
winlin
abfc35c6c7 Update readme 2019-01-01 13:41:18 +08:00
winlin
aef838338c Add utest for kbps connections 2018-12-23 21:19:17 +08:00
winlin
c26b475bae Refine kbps, stub wall clock 2018-12-23 20:47:17 +08:00
winlin
4c40370986 Refine kbps more testable 2018-12-23 20:30:12 +08:00
winlin
16fa4c588a Rename ISrsProtocolReaderWriter to ISrsProtocolReadWriter 2018-12-23 20:08:04 +08:00
winlin
6e75993e7f Change public virtual to virtual public 2018-12-23 19:54:08 +08:00
winlin
5d959661e7 No sudoer 2018-12-22 20:51:57 +08:00
winlin
2e9bf2af83 Always enable SRS_StreamCaster 2018-12-22 20:45:25 +08:00
winlin
0d5c86853a Merge branch 3.0release into develop 2018-12-22 20:32:23 +08:00
winlin
1dc95cba78 Always enable SRS_Ingest 2018-12-22 20:31:47 +08:00
winlin
aa1a5442f9 Always enable SRS_Ingest 2018-12-22 20:30:13 +08:00
winlin
c6844527fb Always enable SRS_SSL 2018-12-22 20:23:39 +08:00
winlin
e4e6dd2169 Always enable SRS_SSL 2018-12-22 20:08:42 +08:00
winlin
0bc7fdbb35 Always enable SRS_SSL 2018-12-22 20:03:40 +08:00
winlin
8e294709b0 Always enable SRS_STAT 2018-12-22 19:58:36 +08:00
winlin
71f1ccbf90 Always enable SRS_HLS 2018-12-22 19:54:10 +08:00
winlin
f003ba9a29 Always enable SRS_DVR 2018-12-22 19:50:57 +08:00
winlin
330100769f Always enable SRS_TRANSCODE 2018-12-22 19:48:55 +08:00
winlin
12f9614117 Merge branch '3.0release' into develop 2018-12-16 23:55:05 +08:00
winlin
59d8bb532b Add git 2018-12-16 23:54:44 +08:00
winlin
7ee3dad2f9 Update readme 2018-12-16 23:39:45 +08:00
winlin
0626bc5982 Use openssl in docker 2018-12-10 14:27:55 +08:00
winlin
432a575c7a Use docker for #1274 and #1250 2018-12-10 00:07:38 +08:00
winlin
f1ab8fecac Fix build warning 2018-12-09 22:48:47 +08:00
winlin
ef3e35f173 Fix build warning 2018-12-09 21:04:43 +08:00
winlin
4d157f2148 Fix build warning 2018-12-09 21:00:38 +08:00
winlin
dcc2a73e7a Refine kernel aac 2018-12-09 20:58:40 +08:00
winlin
572a2806c1 Refine utest 2018-12-09 20:36:31 +08:00
winlin
a8be5f8f27 Allow OSX for utest 2018-12-09 19:41:59 +08:00
winlin
acaae0d5c9 Update SRS3 2018-11-27 21:45:57 +08:00
winlin
ba4ef34d27 Merge 2.0release 2018-11-27 21:24:51 +08:00
winlin
ff82ca1233 Merge branch 2.0release into 3.0release 2018-11-11 16:24:09 +08:00
winlin
24f46f5085 #1261, Support _definst_ for Wowza. 3.0.44 2018-11-11 13:51:10 +08:00
winlin
39f1629168 Merge from SRS2 2018-10-28 14:24:18 +08:00
winlin
63ac93a642 Merge #1236 from 2.0release 2018-10-08 07:22:21 +08:00
winlin
3f009937ee Merge #1237 from 2.0release 2018-10-08 07:10:29 +08:00
winlin
580b94c9c8 SRS console support both Chinese and English 2018-08-26 19:38:46 +08:00
winlin
8e55ef4b60 Refine code 2018-08-26 14:29:45 +08:00
winlin
1e2cca4712 For #1093, Refine HLS encryption wiki 2018-08-25 21:59:56 +08:00
winlin
37bc0a253d Merge branch harlanc-3.0release into 3.0release 2018-08-25 21:17:46 +08:00
winlin
5945fb5a24 Fix #1093, Support HLS encryption. 3.0.42 2018-08-25 21:17:33 +08:00
winlin
ee068cf120 For #1109, Support without ssl for HLS key. 2018-08-25 21:15:26 +08:00
winlin
522fba99aa Merge branch 3.0release into harlanc-3.0release 2018-08-25 18:12:39 +08:00
winlin
e73e30de3a Fix #1051, Drop ts when republishing stream. 3.0.41 2018-08-25 18:10:55 +08:00
winlin
74d5d15c9f Merge branch 3.0release of https://github.com/harlanc/srs into harlanc-3.0release 2018-08-25 12:43:52 +08:00
winlin
1e054d2bcc Fix #354, Rename impl__SrsAutoFree to impl_SrsAutoFree 2018-08-25 12:20:52 +08:00
Harlan
22c5af62cf Merge branch '3.0release' of https://github.com/ossrs/srs into 3.0release
# Conflicts:
#	trunk/src/kernel/srs_kernel_utility.hpp
2018-08-15 07:37:12 +08:00
Harlan
bf12a45274 add configuration instructions for hls encryption 2018-08-12 14:18:05 +08:00
Harlan
ac6b37de4b rewrite ff_data_to_hex 2018-08-12 14:10:18 +08:00
winlin
a61bfb2066 Merge 2.0r4 2018-08-12 12:09:18 +08:00
winlin
a9b5d65ca7 For #1202, Support auth_key param for srs player 2018-08-12 11:52:18 +08:00
winlin
728ddd133b For #1202, Support edge/forward to Aliyun CDN. 3.0.40 2018-08-12 10:46:06 +08:00
winlin
1cc72df134 Fix #910, Support HTTP FLV with HTTP callback. 3.0.39 2018-08-11 19:23:51 +08:00
winlin
928c6ab091 For #1181, Add utest 2018-08-11 13:16:59 +08:00
winlin
01d8bba455 For #1181, Refine code to write utest 2018-08-11 12:33:03 +08:00
winlin
c582590bb0 For #1110, Refine params in http callback. 2.0.253 2018-08-11 10:15:14 +08:00
winlin
0e1ddb046d Update readme for FLV realtime 2018-08-05 20:35:33 +08:00
winlin
d607c7f905 Refine HTTP-FLV latency, support realtime mode.3.0.38 2018-08-05 20:30:04 +08:00
winlin
03ac48f8fa Merge 2.0, for FLV latency 2018-08-05 20:25:28 +08:00
winlin
580c94c8c0 Refine code 2018-08-05 18:58:23 +08:00
winlin
31945c244d For #1110, Refine code. 2018-08-05 11:09:48 +08:00
winlin
455a060fa5 Merge 2.0 2018-08-05 10:52:37 +08:00
winlin
ae99131512 Fix #1087, Ignore iface without address. 3.0.37 2018-08-05 10:41:31 +08:00
winlin
82699ff616 Refine code for librtmp 2018-08-05 10:39:52 +08:00
winlin
29b74c7220 For #1110, Support params in http callback. 3.0.36 2018-08-04 19:51:04 +08:00
winlin
68a1656e07 Fix #1031, Always use vhost in stream query, the unify uri. 3.0.35 2018-08-02 09:17:49 +08:00
winlin
8cf5df5afb Merge 2.0release 2018-08-02 07:25:16 +08:00
winlin
a66d450ec1 For #1031, SRS edge support douyu.com. 3.0.34 2018-08-02 07:14:06 +08:00
winlin
41c6e833b9 Replace hex to string to match MIT license. 3.0.33 2018-07-22 18:47:38 +08:00
winlin
84f81983aa Replace base64 to match MIT license. 3.0.32 2018-07-22 17:56:38 +08:00
winlin
0a63448b86 Replace crc32 MPEG and IEEE by pycrc to match MIT license. 3.0.31 2018-07-22 15:21:05 +08:00
winlin
e395878916 Replace crc32 IEEE by golang to match MIT license. 3.0.30 2018-07-21 20:58:20 +08:00
winlin
dea5e5bb48 Add utest or CRC32 IEEE, refine TABs of code 2018-07-21 19:09:32 +08:00
winlin
608c88b8f2 Merge 2.0release 2018-07-21 17:52:12 +08:00
winlin
551863a7ed Refine code 2018-07-21 17:34:31 +08:00
winlin
f5c4d5a539 Release 2.0r3, SRS/2.0.248 2018-07-18 20:31:03 +08:00
winlin
693194dffe Merge 2.0release 2018-07-18 19:26:53 +08:00
winlin
e4742ddac7 Merge 2.0release 2018-07-17 13:59:51 +08:00
Harlan
e9cb8210fc fix default value error 2018-05-15 11:20:52 +08:00
Harlan
90f70d4cd3 CI test 2018-04-06 10:57:46 +08:00
Harlan
45a57acbb4 fix bug 2018-04-06 10:05:13 +08:00
Harlan
43ebd5958d fix bug that only one stream can be encrypted.. 2018-04-03 22:00:32 +08:00
winlin
dba44c7c3f Merge branch 'develop' into 3.0release 2018-03-25 20:00:33 +08:00
xialixin
bb4e16ae3c fix create dir success result check (#1080) 2018-03-25 17:48:07 +08:00
xialixin
aaf2905a9d add: hls configuration adds [duration] variable (#1083) 2018-03-25 17:47:37 +08:00
Harlan
52596a0b04 add HLS encryption feature 2018-03-25 12:05:52 +08:00
winlin
0d78b908a7 Fix client tools resolve dns failed bug 2018-03-20 19:50:46 +08:00
winlin
c20b819a29 Refine readme 2018-03-03 10:04:21 +08:00
winlin
449c632e49 For #464: Add example for origin cluster 2018-03-03 10:01:01 +08:00
winlin
bd797ad385 Fix utest build failed for ::atoi 2018-03-03 09:33:15 +08:00
winlin
459272b94c Merge #1077 from 2.0release 2018-02-28 14:10:09 +08:00
winlin
c528b4170e Refine readme 2018-02-28 13:34:26 +08:00
winlin
4bf5ab2044 Fix #464, support RTMP origin cluster. 3.0.29 2018-02-16 16:40:48 +08:00
winlin
c70421e656 Fix #464, support origin cluster 2018-02-16 16:39:07 +08:00
winlin
2f09ec4353 For #464, refine result of origin cluster api 2018-02-16 14:13:14 +08:00
winlin
92f2bcd878 For #464, support config origin cluster 2018-02-16 10:31:19 +08:00
winlin
55c96192e2 For #464, refine code 2018-02-16 10:19:48 +08:00
winlin
ec362b2774 For #464, query origin info and ip addresses 2018-02-16 09:37:31 +08:00
winlin
469250f850 For #464, support origin cluster api 2018-02-15 20:55:34 +08:00
winlin
d0fbf44d18 For #464, support config for origin cluster. 2018-02-14 21:52:40 +08:00
winlin
db6b8cf914 Fix #1057, switch to simple handshake. 3.0.28 2018-02-13 09:05:01 +08:00
winlin
a2cefe4dbd For #1059, show more information from stream 2018-02-13 09:02:46 +08:00
winlin
681138d2af Fix #1059, merge from 2.0, supports url with vhost in stream. 3.0.27 2018-02-13 08:52:57 +08:00
winlin
93d3e1464a For #1045, revert macro for TCP keepalive detection, use system macro 2018-01-07 17:49:57 +08:00
winlin
049e7c82c0 Merge #1044, for #1045, set TCP SO_KEEPALIVE 2018-01-07 17:23:36 +08:00
winlin
1aa36f3bbc Refine readme 2018-01-07 13:10:47 +08:00
winlin
7d4c4750dd Refine readme 2018-01-07 12:44:54 +08:00
winlin
2e80403ecd Refine readme 2018-01-07 12:44:25 +08:00
winlin
82457cda4b Change date from 2017 to 2018 2018-01-07 11:00:58 +08:00
winlin
ca1395a807 Change date from 2017 to 2018 2018-01-07 10:58:53 +08:00
winlin
c67fe0323b Refine product target 2018-01-07 10:51:18 +08:00
winlin
d9e37d2f54 Merge branch '2.0release' into 3.0release 2018-01-04 13:49:55 +08:00
winlin
5730bf8e43 Fix #913, support complex error. 3.0.26 2018-01-01 23:03:42 +08:00
winlin
922a8f3a5c For #988, refine code. 2018-01-01 22:45:22 +08:00
winlin
823dc2df21 Refine help 2018-01-01 22:44:48 +08:00
Thomas Dreibholz
feaae341b9 IPv6 support (for 3.0 release) (#988)
* IPv6 support, part 1.

* IPv6 support, part 2.

* Some more IPv6 work.

* Made functions for address:port paŕsing IPv6-capable.

* Fixed type (compile warning).

* Fixed formatting.

* Reverted option change.

* Replaced abort() by proper error handling.

* Also retrieving local IPv6 addresses now.
2018-01-01 22:43:58 +08:00
winlin
db08f1586c For #913, APP support complex error. 2018-01-01 22:32:54 +08:00
winlin
e2c1f58674 For #913, APP support complex error. 2018-01-01 21:20:57 +08:00
winlin
6eae93258a For #913, APP support complex error. 2018-01-01 19:39:57 +08:00
winlin
aebbbadf42 For #913, Service support complex error. 2018-01-01 11:41:15 +08:00
winlin
15aea686c3 For #913, KAFKA, RTSP support complex error. 2018-01-01 10:30:31 +08:00
winlin
70a20ffadb For #913, RTMP support complex error. 2018-01-01 09:38:22 +08:00
winlin
60accb6e54 For #913, AMF0 and RTMP support complex error. 2017-12-31 20:52:04 +08:00
winlin
204ef041da For #913, Kernel MP4 FLV HTTP support complex error. 2017-12-31 12:11:48 +08:00
winlin
9802dc326e For #913, source support complex error 2017-09-23 22:12:33 +08:00
winlin
abcaba33ee For #913: TS/HLS/MPEGTS support complex error 2017-09-22 21:50:54 +08:00
winlin
20a42599f3 For #913, http callback use complex error 2017-09-22 19:54:50 +08:00
winlin
59b53dab8b Merge from SRS2 2017-09-22 16:27:24 +08:00
winlin
fd91df9411 For #913, reload use complex error 2017-09-22 16:14:30 +08:00
ME_Kun_Han
3744606c9b fix bug: parsing Exp-Golomb codes failed (#978) 2017-09-19 18:57:37 +08:00
winlin
64e96603b1 Merge branch '2.0release' into 3.0release 2017-08-19 20:20:11 +08:00
winlin
9f5224c34a For #913, use complex error for http 2017-07-29 21:39:57 +08:00
winlin
661eb8b37c For #913, use complex error for reload utc time 2017-07-29 20:02:38 +08:00
winlin
5c9a12e72a For #913, use complex error for listener 2017-07-29 12:45:17 +08:00
winlin
b88265fc78 Update readme 2017-07-26 09:28:40 +08:00
winlin
ba2b82f29c Refine English of Readme 2017-07-24 08:45:36 +08:00
winlin
71dd3f3137 For #913, use complex error for server handler. 2017-07-18 20:24:07 +08:00
winlin
1d35ae21ec Update README.md 2017-06-30 10:30:16 +08:00
winlin
4d6c1b1a17 Update README.md 2017-06-29 09:38:20 +08:00
winlin
9c6d7a71d0 Update README.md 2017-06-29 09:38:03 +08:00
winlin
535fa034af Update README.md 2017-06-29 09:37:16 +08:00
winlin
ad6f318ea6 Update README.md 2017-06-29 09:35:57 +08:00
winlin
92fb9b4a72 Update README.md 2017-06-28 09:54:14 +08:00
winlin
524267d33c Merge branch '3.0release' of github.com:ossrs/srs into 3.0release 2017-06-28 09:44:22 +08:00
winlin
e135ab59d9 Fix the utest failed for chunk_size 2017-06-28 09:44:10 +08:00
winlin
f871c26380 Update README.md 2017-06-28 09:38:05 +08:00
winlin
2207adebed Update README.md 2017-06-28 09:27:45 +08:00
winlin
ec335c692d Update README.md 2017-06-28 09:23:42 +08:00
winlin
6749582f1e Update README.md 2017-06-28 09:21:06 +08:00
winlin
a5925ca904 Update README.md 2017-06-28 09:19:09 +08:00
winlin
159ef9e1c4 Update README.md 2017-06-28 09:18:13 +08:00
winlin
f9056caae0 Merge branch 'develop' into 3.0release 2017-06-28 09:09:00 +08:00
winlin
6d4315fc3c Disable valgrind by default 2017-06-28 09:08:19 +08:00
winlin
494879f6ed Update README.md 2017-06-27 08:26:02 +08:00
winlin
f641f06171 Update README.md 2017-06-27 08:19:48 +08:00
winlin
34c73b6bec Update README.md 2017-06-27 08:15:39 +08:00
winlin
0ad4b65a56 Disable valgrind for osx. 2017-06-13 16:20:00 +08:00
winlin
b3825c4021 Fix warnings 2017-06-13 16:10:46 +08:00
winlin
9db2a04c3b For #913, coroutine support complex error. 2017-06-11 18:44:20 +08:00
winlin
9ae54850bf Update readme for json 2017-06-11 14:06:54 +08:00
winlin
b5c14938d9 For #913, config and log support complex error. 2017-06-11 14:03:19 +08:00
winlin
860aac3e50 For #913, config reload and persistence 2017-06-11 09:54:09 +08:00
winlin
7cac35a289 For #913, source cycle error 2017-06-11 09:40:07 +08:00
winlin
7275fd5397 Fix #916, build failed for headers for error. 2017-06-11 09:03:29 +08:00
winlin
a20e2c3ef6 For #913, refine server utility 2017-06-10 15:20:48 +08:00
winlin
ca9f0bdb1e For #913, refine server initialize st 2017-06-10 14:29:41 +08:00
winlin
4e4091231e Refine object create in server. 2017-06-10 14:19:10 +08:00
winlin
c32afb95ab Release v2.0-r2, 2.0.243 2017-06-10 09:02:16 +08:00
winlin
20cacd5ea0 Update readme for DASH 2017-06-10 08:54:59 +08:00
winlin
372a9e5cb3 Fix #915, string ends with 2017-06-10 08:42:42 +08:00
winlin
93710c7489 For #913, refine the error mechanism 2017-06-09 13:29:23 +08:00
winlin
bb200b5d2d For #913, add complex error. 2017-06-09 11:50:35 +08:00
winlin
58521751c3 Fix #299, support experimental MPEG-DASH. 3.0.25 2017-06-04 19:56:29 +08:00
winlin
69374c8d6d For #299, use format for v/a sequence header. 2017-06-04 19:35:52 +08:00
winlin
9ca36970aa Fix #908, use empty coroutine to avoid NULL pointer. 2017-06-04 19:13:56 +08:00
winlin
0e9e1792fe For #299, write fMP4 for DASH. 2017-06-04 15:10:35 +08:00
winlin
baed1cc043 For #821, support parse dash video segment 2017-06-03 23:12:54 +08:00
winlin
8cc3ab2fa2 For #821, print mdat and udat 2017-06-03 19:00:19 +08:00
winlin
beae090d67 Refine logger header 2017-05-31 13:52:21 +08:00
winlin
4f6f8a8244 Fix verbose bug, for #821 2017-05-30 19:42:20 +08:00
winlin
6c64297264 Fix #821, support MP4 file parser. 3.0.24 2017-05-30 19:40:03 +08:00
winlin
12a55cd0c2 Fix build failed. 2017-05-30 09:58:14 +08:00
winlin
86f3bd7a0f Fix build failed. 2017-05-30 09:57:57 +08:00
winlin
121eadbc07 Fix build failed. 2017-05-30 09:54:38 +08:00
winlin
1bf99e8f3e For #907, Wrap ST, only use in service ST. 2017-05-30 09:05:02 +08:00
winlin
54411e0768 Fix #904, replace NXJSON(LGPL) with json-parser(BSD). 3.0.23 2017-05-30 07:40:18 +08:00
winlin
6993ac226f For #906, #902, use coroutine for reusable2 thread 2017-05-29 20:49:29 +08:00
winlin
ea9a5f26d9 For #906, #902, use coroutine for reusable thread 2017-05-29 20:33:32 +08:00
winlin
2ed2513f08 For #906, #902, use coroutine for one cycle thread 2017-05-29 19:45:19 +08:00
winlin
b21f92f97a For #906, #902, remove the thread start and stop event 2017-05-29 18:42:36 +08:00
winlin
3ffb0980f5 For #906, #902, use connection manager to remove connection 2017-05-29 18:34:41 +08:00
winlin
44f542f77f For #906, #902, replace the endless thread with coroutine 2017-05-29 17:56:26 +08:00
winlin
fc380fe48d For #906, #902, refine thread object. 2017-05-29 17:19:06 +08:00
winlin
5792c462b8 Merge branch 'develop' into 3.0release 2017-05-29 12:17:25 +08:00
winlin
c4966484e1 For #893, #899, merge SRS2 2017-05-29 12:17:16 +08:00
winlin
792ef6795f Merge branch 'develop' of github.com:ossrs/srs into develop 2017-05-24 14:15:28 +08:00
winlin
2677ec8c3f Update license mixing 2017-05-24 14:14:45 +08:00
winlin
1e3550a52c For #821, Parse basic mp4 boxes. 2017-05-21 19:41:15 +08:00
HungMingWu
234904c206 Refine Refine Refine kernel/ts code (#891) 2017-05-21 09:09:58 +08:00
winlin
dd1cca45cc Remove non-exists conf file. 2017-05-18 14:00:04 +08:00
winlin
eaccbd0f85 Support print MP4 box. 2017-05-14 22:16:15 +08:00
winlin
fe43a31d06 Parse all mp4 boxes 2017-05-13 22:37:46 +08:00
winlin
366d6bcb82 Refine code 2017-05-13 21:47:20 +08:00
xialixin
92c8c0505d Fix the timebase bug, change from us to ms. (#876)
* fix SRS_CONSTS_RTMP_PULSE_TMMS (int64_t)(500*1000LL)

* fix SrsBufferCache::cycle st_usleep(SRS_CONSTS_RTMP_PULSE_TMMS * 1000)

* fix st_usleep(SRS_CONSTS_RTMP_PULSE_TMMS * 1000)
2017-05-13 09:21:02 +08:00
HungMingWu
e8ea27088a Refine Refine kernel/ts code (#881) 2017-05-13 09:19:19 +08:00
HungMingWu
815d50f00a Remove warning: C++11 requires a space between string literal and macro (#874)
On Ubuntu 17.04, the default gcc compiler version is 6.3.0.
It switch standard from c++98 to c++11.
So it would generate verbose warnings.
2017-05-06 14:05:22 +08:00
winlin
a58874178b Fix merge build failed. 2017-05-01 16:49:09 +08:00
winlin
f97260be1d Merge SRS2 2017-05-01 16:44:14 +08:00
HungMingWu
98d4b6ae11 Refine srs_kernel_codec audio & video config code (#854) 2017-04-24 10:08:57 +08:00
winlin
c97f2233a2 Merge SRS2 for #851 2017-04-23 21:00:06 +08:00
winlin
d0bf47906d Merge SRS2 2017-04-18 21:11:36 +08:00
winlin
d15c21a034 Merge branch '2.0release' into develop 2017-04-18 11:51:25 +08:00
winlin
9a2a6ab95f Merge SRS2 2017-04-18 11:42:11 +08:00
winlin
bcd24126c5 Update comments for HLS 2017-04-16 21:43:30 +08:00
winlin
a98c9e04e3 Fix #547, support HLS audio in TS. 3.0.22 2017-04-16 21:33:39 +08:00
winlin
6ee85aea83 Refine mp4, extract mp4 box reader. 2017-04-16 20:46:04 +08:00
winlin
c9bed5a8bf Refine mp4 codec for mdat. 2017-04-16 20:16:11 +08:00
winlin
18d9f6c8f1 Fix build failed. 2017-04-16 15:54:30 +08:00
winlin
1054b0a90f Merge SRS2 2017-04-15 20:46:00 +08:00
winlin
d6e28bde69 Merge from SRS2. 2017-04-15 17:09:50 +08:00
HungMingWu
14acc59a19 Refine kernel/mp4 code (#823) 2017-04-15 17:05:05 +08:00
winlin
5fed19941d Update links for compare 2017-04-12 10:39:20 +08:00
winlin
33375db401 Merge from SRS2, for #834 2017-04-09 18:52:21 +08:00
winlin
8b7566a007 Refine code 2017-03-26 18:30:33 +08:00
winlin
032107dbf0 Refine hls ingester 2017-03-26 17:18:34 +08:00
winlin
609605a50b Fix #820, extract service for modules. 3.0.21 2017-03-26 17:05:50 +08:00
winlin
b75a3fad4e For #820, fix ubuntu build failed. 2017-03-26 16:48:43 +08:00
winlin
362b5788cd For #820, fix warnings 2017-03-26 16:45:00 +08:00
winlin
b4b5fb77f3 Add skype for English user. 2017-03-26 14:33:55 +08:00
winlin
7d618fed43 For #820, fix utest failed. 2017-03-26 14:25:08 +08:00
winlin
e3526c0cf6 For #820, modules use service only. 2017-03-26 13:40:39 +08:00
winlin
ff822b55cd For #820, extract service module. 2017-03-26 10:16:21 +08:00
winlin
0a57a46016 Refine LICENSE 2017-03-25 21:29:29 +08:00
winlin
f32aab3d92 For #299, refine code. 2017-03-25 17:21:39 +08:00
winlin
62b7204514 Refine code, add mp4 parser module 2017-03-25 15:40:28 +08:00
winlin
c648fd27bf Refine code 2017-03-25 13:07:09 +08:00
winlin
2980e7d3ef For #813, refine code. 2017-03-25 12:52:54 +08:00
Chengdong Zhang
8ad934a8a4 srs_info use not available variable (#813)
srs_info use not available variable.
Variable has been removed or changed.
2017-03-24 23:42:37 -05:00
winlin
9ab5e6a916 For #299, fix bug of fragment url 2017-03-19 12:49:58 +08:00
winlin
c71e8fa947 For #299, fragment reap workflow 2017-03-19 12:30:02 +08:00
winlin
721a8457c2 For #299, Refine init mp4, use fragment 2017-03-19 12:29:38 +08:00
winlin
8d679a6f9a For #299, use fragment for dvr FLV/MP4 2017-03-18 21:41:01 +08:00
winlin
da4c390d69 For #299, extract fragment and fragment window for hls 2017-03-18 21:29:08 +08:00
winlin
6da6e0511d For #803, should refine code. 2017-03-11 16:28:18 +08:00
Chengdong Zhang
a6eebacc99 Streams API is not correct. (#800)
HTTP API for streams is not correct. When stream stopped, API does not
remove it.
2017-03-11 16:21:33 +08:00
“winlin”
1b26536253 Add SIP RFC 2017-03-06 15:15:26 +08:00
“winlin”
a48fdd9f03 Add ICE RFC 2017-03-06 15:11:02 +08:00
winlin
ce034c3556 Refine docs, add TURN/STUN rfc. 2017-03-06 10:19:19 +08:00
winlin
3ec9df6578 For #299, A/V init mp4 are fine. 2017-03-05 18:44:37 +08:00
winlin
886930c22a For #299, refine the comments. 2017-03-05 14:17:39 +08:00
winlin
14765c2ba5 For #790, play or publish is not neccessary for bandwidth test. 2017-03-04 14:46:48 +08:00
ME_Kun_Han
3562424ee3 fix bug, add param for generating tc url and add play stream to make-bandwidth checking success (#790) 2017-03-04 14:44:34 +08:00
winlin
8ab43b3e78 Fix #794, refine the comments. 2017-03-04 14:29:17 +08:00
winlin
8a53128a37 Merge SRS2 2017-03-02 21:55:52 +08:00
winlin
308c6fee18 Fix #786, simply don't reuse object. 3.0.20 2017-03-02 16:43:06 +08:00
winlin
7680ac04ad Refine srs-librtmp 2017-03-01 18:09:07 +08:00
winlin
1743899a23 Refine code 2017-03-01 13:49:50 +08:00
winlin
16cde27a1e Remove MacOS compile option, for it's on use. It's caused by paralell make 2017-03-01 12:39:42 +08:00
winlin
121a2e5886 For #110, refine thread object. 3.0.19 2017-03-01 12:28:32 +08:00
winlin
44014683e1 Refine thread. 2017-03-01 12:23:44 +08:00
winlin
5bec6a4fdd Refine srs-librtmp 2017-03-01 12:03:49 +08:00
winlin
011b693235 Update srs-librtmp, set errno to ret when failed. 2017-03-01 11:00:54 +08:00
winlin
72c4ae4a8c Refine srs-librtmp API, change print to format 2017-03-01 10:52:57 +08:00
winlin
ad87bd7cf2 Refine configure 2017-03-01 09:21:20 +08:00
winlin
68a5407b3a Remove using of connect_app2. 2017-02-28 20:35:56 +08:00
winlin
26c20db2b3 Fix parse srs version bug 2017-02-28 20:03:46 +08:00
winlin
c849010fe2 Refine api for srs-librtmp 2017-02-28 19:46:09 +08:00
winlin
af73e8ee65 Add log functions for srs-librtmp 2017-02-28 16:19:54 +08:00
winlin
ca43bfe6d9 Fix build failed, for srs librtmp API changed. 2017-02-28 14:54:53 +08:00
winlin
cdfded6a74 Support disable valgrind 2017-02-28 14:47:00 +08:00
winlin
89a5fa69d1 Refine srs-librtmp, set the schema, rather that connect app3 2017-02-28 14:07:14 +08:00
winlin
4e96c443d8 Change the bool to int for C 2017-02-27 17:39:29 +08:00
winlin
747d6f2f52 For #299, write legal MPD, fix CORS. 2017-02-26 21:45:08 +08:00
winlin
8ab727f3c5 For #299, write MPD file. 2017-02-26 20:40:33 +08:00
winlin
e754ab7073 Update readme for Kafka, DVR MP4 and compare 2017-02-26 09:24:46 +08:00
winlin
35de69c0c2 Merge branch 'HungMingWu-develop' into develop 2017-02-25 22:06:41 +08:00
winlin
988618cb6c Merge branch 'develop' of https://github.com/HungMingWu/srs into HungMingWu-develop 2017-02-25 22:00:09 +08:00
winlin
bd84e476e6 For #730, remove the test code. 2.0.234 2017-02-25 20:24:56 +08:00
HungMingWu
a6582c6208 Disable openssl thread support to prevent ubuntu linking pthread error 2017-02-25 09:47:29 +00:00
winlin
764cf245e9 For #774, build librtmp exmaples failed for -lpthread 2017-02-25 12:13:12 +08:00
winlin
ac0e27b936 For #774, refine code style 2017-02-25 12:10:41 +08:00
HungMingWu
01d5e4da17 Replace openssl from l-1.0.1f to 1.10e (#774)
DUe to API breakchange, add a wrapper for backward compatibility
2017-02-25 12:06:39 +08:00
winlin
695ceeab48 Refine code for #777 2017-02-25 11:30:25 +08:00
Chengdong Zhang
a3df4e3bfb Fix #744 http callback set a wrong default port (#777)
* Add port verify

Code is more robust

* Verify port

Verify port

* Change hard code to defined.

Change hard code to defined.
2017-02-25 11:28:59 +08:00
winlin
d786d61685 Merge branch '2.0release' into develop 2017-02-25 11:21:56 +08:00
winlin
cee9d736a4 for #299, refine code. 2017-02-19 22:03:51 +08:00
winlin
ede1c34a25 for #299, refine the signature of api for hls/dash 2017-02-19 21:48:32 +08:00
winlin
711b58e0b2 Merge pull request #763 from HungMingWu/develop
Replace ffmpeg version from 2.1.1 to 3.2.4
2017-02-18 14:04:39 +08:00
HungMingWu
33d6274217 Replace ffmpeg version from 2.1.1 to 3.2.4 2017-02-13 23:29:39 +08:00
winlin
2fcd3972c1 for #299, refine the encoder object name 2017-02-12 21:50:02 +08:00
winlin
2a4f57a587 Fix #301, User must config the codec in right way for HLS. 3.0.18 2017-02-12 20:55:35 +08:00
winlin
d612a21bad for #299, refine audio codec object name 2017-02-12 20:46:24 +08:00
winlin
caf69f193d for #299, refine the codec object name 2017-02-12 20:38:39 +08:00
winlin
d7458c4e72 For #299, refine the codec to format-frame-sample chain. 2017-02-12 18:18:18 +08:00
winlin
c4a510b834 For #299, refine the codec info structure. 2017-02-11 23:09:23 +08:00
winlin
5e419c66f8 For #299, add dash files. 2017-02-11 21:14:28 +08:00
winlin
7fd221ef63 Always enable DVR 2017-02-11 17:27:40 +08:00
winlin
b0789c54e4 Update HLS wiki to v3 2017-02-11 14:28:40 +08:00
winlin
292f62ab0f Update the wiki links 2017-02-11 14:13:55 +08:00
winlin
fdd81fa886 Update index 2017-02-11 14:03:13 +08:00
winlin
af0d98619a Merge srs2 2017-02-11 13:55:45 +08:00
winlin
8e5d4dc73d always enable http and hls 2017-02-11 13:29:53 +08:00
winlin
11e8fe5bc0 refine options, remove rtmp-hls 2017-02-11 12:45:49 +08:00
winlin
477414106a add dash files. 2017-02-11 12:30:21 +08:00
winlin
ebc1be913f Merge branch '2.0release' into develop 2017-02-10 13:15:51 +08:00
winlin
72ceeaf2ff Merge branch '2.0release' into develop 2017-02-10 12:54:55 +08:00
winlin
e2d85d099e update readme for DVR mp4 2017-02-09 15:43:40 +08:00
winlin
00abaf4df2 merge srs2, remove donation 2017-02-09 15:42:42 +08:00
winlin
5fec59ace2 merge from srs2, fix #503 2017-02-09 14:33:56 +08:00
winlin
61d8ca7e70 merge srs2 2017-02-09 13:56:54 +08:00
winlin
afbc3443f3 fix #738, support DVR general mp4. 3.0.17 2017-02-07 21:56:20 +08:00
winlin
3209ad29e0 for #738, refine code for DVR mp4. 2017-02-06 20:58:52 +08:00
winlin
0a054cd6bd for #738, remove the dvr plan append for it's no use 2017-02-06 20:22:07 +08:00
winlin
8c01f52372 for #738, refine the dvr segmenter. 2017-02-06 18:33:26 +08:00
winlin
31191f2650 for #738, support srs ingest mp4 2017-02-05 21:22:07 +08:00
winlin
4fe79a1025 for #738, fix the audio sample offset error. 2017-02-05 20:27:37 +08:00
winlin
733252dc21 for #738, remove test code 2017-02-05 09:23:38 +08:00
winlin
733ba73d54 for #738, write mp4 samples. 2017-02-05 09:15:46 +08:00
winlin
e24674e9cf for #738, refine build mp4 samples from moov. 2017-02-04 22:45:52 +08:00
winlin
3025aebf42 for #738, mp4 build samples from moov. 2017-02-04 22:25:03 +08:00
winlin
253ac40312 for #738, parse avcc/sps/pps/asc from mp4. 2017-02-04 14:57:07 +08:00
winlin
9d21a8bb33 for #738, use reader and seeker for mp4 demuxer to seek for general mp4(ftyp-mdat-moov). 2017-02-03 22:49:19 +08:00
winlin
bbee16e4db for #738, parse moov, get the h.264/avcC and aac/asc 2017-02-03 21:03:26 +08:00
winlin
e8eb050bf2 update readme 2017-02-03 14:57:28 +08:00
winlin
ac7ee10b60 fix #751,#756, refine code 2017-02-03 11:56:02 +08:00
winlin
f15fb27745 Merge pull request #756 from eagle-zhang/develop
Clients Api support start and count
2017-02-03 11:51:13 +08:00
Chengdong Zhang
80540e4dc1 change TAB space
change TAB space for line 794
2017-02-03 10:58:32 +08:00
eagle-zhang
7b02e3543f Clients Api support start and count
Clients Api support start and count
line 794~810 && line 830
2017-02-03 10:49:06 +08:00
winlin
7ee1df33d1 for #738, parse mp4 udta(user data) box. 2017-02-02 22:20:33 +08:00
winlin
ffe0a4426d for #738, parse mp4 moov boxes. 2017-02-02 22:02:39 +08:00
winlin
96f2e18d3a for #738, demux the aac mp4a and esds 2017-02-02 19:05:08 +08:00
winlin
128a1fd3db for #738, decode mp4 video track boxes. 2017-02-02 15:10:11 +08:00
winlin
5a84b6ca94 for #738, complete all mp4 boxes codec. 2017-02-02 12:36:48 +08:00
winlin
2ad265bd5a for #738, implements boxes codec 2017-02-01 21:57:32 +08:00
winlin
b6bb3f2446 fix c99 build failed. 2017-01-31 22:17:27 +08:00
winlin
858951da49 for #738, add srs ingest mp4 2017-01-31 21:36:51 +08:00
winlin
34a8eb6113 for #738, add srs ingest mp4 tool 2017-01-31 20:43:48 +08:00
winlin
33ba6cdee2 change utest when demuxer use io interface. 2017-01-30 20:58:32 +08:00
winlin
01d401c270 for #738, refine flv codec to use io interface. 2017-01-30 20:12:36 +08:00
winlin
d3bb8b6a86 for #742, refine the io interfaces. 2017-01-30 19:59:59 +08:00
winlin
eaa222f034 for #742, refine the file reader and writer interface. 2017-01-30 19:35:04 +08:00
winlin
bb5bd0ee1c include for uintxx_t 2017-01-30 17:38:30 +08:00
winlin
b16ab038ce for #742, refine the u_intxx_t to uintxx_t 2017-01-30 17:32:18 +08:00
winlin
011ac4f6a9 for #738, add mp4 demuxer to librtmp 2017-01-30 17:19:07 +08:00
winlin
3f3e98e9db for #738, major boxes from isom 2017-01-29 17:16:20 +08:00
winlin
8588a10775 Merge branch '2.0release' into develop 2017-01-29 17:15:43 +08:00
winlin
b09183010b for #738, add isom boxes. 2017-01-29 15:45:27 +08:00
winlin
ca02aaa7b3 for #738, add doc, moov box. 2017-01-28 19:32:43 +08:00
winlin
6b6ac9a054 for #738, add box and fullbox. 2017-01-27 20:54:05 +08:00
winlin
91a3989372 for #738, add mp4 demuxer files to kernel. 2017-01-27 11:27:02 +08:00
winlin
136a7ef488 for #299, refine docs. 2017-01-26 17:28:49 +08:00
winlin
e8353cba3b for #299, add mp4 and dash doc. 2017-01-26 16:53:30 +08:00
winlin
38a683fe14 disable glibc memory check 2017-01-23 18:06:30 +08:00
winlin
7057bb1ef5 for #742, always enable http utilities. 2017-01-23 17:55:52 +08:00
winlin
a1fcf66f32 for #742, always enable http utilities. 2017-01-23 17:43:59 +08:00
winlin
79def81792 for #742, refine the rtmp conn, use info as data cluster. 2017-01-23 17:12:04 +08:00
winlin
39aee2b318 for #742, fix publish recv thread bug. 2017-01-23 16:44:42 +08:00
winlin
4583a63789 for #742, refine code for recv thread. 2017-01-23 16:38:23 +08:00
winlin
a07986f4ee for #742, refine code 2017-01-22 17:07:55 +08:00
winlin
5c959fc781 merge from srs2, for kbps free io 2017-01-22 13:16:05 +08:00
winlin
a3ea83f504 directly free the transport, not need to close for maybe NULL 2017-01-20 12:11:52 +08:00
winlin
99c13fb1c1 convert ms to us for st 2017-01-19 15:51:55 +08:00
winlin
7bfb648bd8 refine the meta cache name 2017-01-19 15:51:34 +08:00
winlin
4cff49afd2 for #742, refine source, meta and origin hub. 3.0.16 2017-01-19 12:38:55 +08:00
winlin
6209945a07 Merge branch '2.0release' into develop 2017-01-18 19:34:00 +08:00
winlin
8acb99f96c refine comments for librtmp 2017-01-18 16:59:19 +08:00
winlin
c5fcc15989 update the date info 2017-01-18 16:41:47 +08:00
winlin
0e6f7e66f0 add srs_rtmp_free_packet for srs-librtmp 2017-01-18 16:31:41 +08:00
winlin
7acc3aca16 refine hijack io for srslibrtmp 2017-01-18 16:23:59 +08:00
winlin
e8c48ac8f8 merge srs2, use specific error code for dns resolve 2017-01-18 16:05:33 +08:00
winlin
2656c97ccd merge srs2. release r2.0b4 2017-01-18 12:18:59 +08:00
winlin
310032d8d8 merge srs2, timestamp overflow for ATC. 2017-01-18 11:48:31 +08:00
winlin
2ef1ef06e9 increase the nb_samples because some large video may overflow. 2017-01-18 11:11:36 +08:00
winlin
3fe338d1c5 for #742, use ms for application clock tbn. 2017-01-17 12:25:30 +08:00
winlin
dca9749f37 for #742, refine the object live cycle. 3.0.15 2017-01-17 10:44:13 +08:00
winlin
f4c0af8bfc refine code remove dup api for #742 2017-01-16 16:20:34 +08:00
winlin
1ed5118246 refine the spaces, no TABS 2017-01-16 15:47:26 +08:00
winlin
750f4413c8 merge srs2 for #536 2017-01-16 12:47:48 +08:00
winlin
ccb250f3bc merge srs2. convert ts aac audio private stream 1 to common. 2017-01-11 17:43:29 +08:00
winlin
dda4f3381f no donation anymore for SRS3+ 2017-01-11 16:20:15 +08:00
winlin
c902d0eb01 no donation anymore. 2017-01-11 13:06:39 +08:00
winlin
f92db0f87e merge srs2 for kbps 2017-01-11 11:46:50 +08:00
winlin
7fe60b5bbf fix #735 config transform refer_publish invalid. 3.0.14 2017-01-11 09:45:22 +08:00
winlin
7bbb3bae42 merge srs2 2017-01-11 09:33:26 +08:00
winlin
0168589ab4 Merge pull request #737 from Himer/develop
Update srs_app_source.cpp
2017-01-11 09:10:05 +08:00
Himer
afa704bca5 Update srs_app_source.cpp
enabled 为true才进行转发实例创建
2017-01-10 21:16:49 +08:00
winlin
db231f6d37 refine hls html5 video template. 2017-01-10 18:43:36 +08:00
winlin
df983cc9ec fix typo 2017-01-10 18:14:06 +08:00
winlin
a1ae48f4ac Merge branch '2.0release' into develop 2017-01-10 18:07:52 +08:00
winlin
07871a442e fix typo 2017-01-10 17:18:22 +08:00
winlin
ae1920e91a Merge branch '2.0release' into develop 2017-01-10 17:17:31 +08:00
winlin
1dd877c0d6 merge srs2 2017-01-10 11:17:37 +08:00
winlin
d49f195bbf fix #734, log format error. 2017-01-10 09:36:51 +08:00
winlin
c46e925be5 add utest for avc uev 2017-01-09 18:14:25 +08:00
winlin
b7dd764920 update gitignore 2017-01-09 15:17:08 +08:00
winlin
15dfb0957c update introduction for SRS3 2017-01-06 19:02:49 +08:00
winlin
8017311369 update introduction for SRS3 2017-01-06 19:01:43 +08:00
winlin
463ff9374f update introduction for SRS3 2017-01-06 18:50:56 +08:00
winlin
7119b2a31e update introduction for SRS3 2017-01-06 18:50:22 +08:00
winlin
309abde790 merge srs2 2017-01-06 18:18:02 +08:00
winlin
10a0c6c10c update for srs3 2017-01-06 17:55:06 +08:00
winlin
1b1ae00910 fix #727, install valgrind-devel 2017-01-06 17:51:07 +08:00
winlin
517812dbe2 remove test code for #730 2017-01-06 15:19:27 +08:00
winlin
1b175b1107 for #730, support config in/out ack size. 3.0.13 2017-01-06 14:57:54 +08:00
winlin
bbbc40f9c2 Merge branch '2.0release' into develop 2017-01-06 14:32:07 +08:00
winlin
e434c09dc0 for #730, merge srs2 2017-01-06 14:13:19 +08:00
winlin
d29416a5f0 add conf sample for ingest rtsp 2017-01-06 10:47:05 +08:00
winlin
4709d0214c for #711, support prefile for transcode. 3.0.12 2017-01-06 10:39:37 +08:00
winlin
35cd4c407c patch ST for valgrind and ARM. 3.0.11 2017-01-05 10:50:02 +08:00
winlin
f9a159cd21 patch ST for valgrind and ARM. 3.0.11 2017-01-05 10:45:41 +08:00
winlin
1581b15d86 update feature list 2017-01-05 10:10:27 +08:00
winlin
a4b82d7def update feature list 2017-01-05 09:55:57 +08:00
winlin
0f95964a8e update feature list 2017-01-05 09:32:24 +08:00
winlin
5a1b067fcf update feature list 2017-01-05 09:31:14 +08:00
winlin
8bdf50b14d update feature list 2017-01-05 09:29:12 +08:00
winlin
f2efa96015 for #324, always enable hstrs. 3.0.10 2017-01-05 09:08:56 +08:00
winlin
b4a815641b refine the links 2017-01-04 17:50:06 +08:00
winlin
df8ad774ef refine the content 2017-01-04 11:52:30 +08:00
winlin
704038e36e refine the content 2017-01-04 11:49:31 +08:00
winlin
977f82ad1d refine the content 2017-01-04 11:46:22 +08:00
winlin
6cf7089bae refine the content 2017-01-04 11:45:45 +08:00
winlin
9b85d9fca5 refine the content 2017-01-04 11:45:22 +08:00
winlin
412f6f3b47 refine the content 2017-01-04 11:42:56 +08:00
winlin
85ceea1c98 refine the content 2017-01-04 11:34:59 +08:00
winlin
e292d4fdcc update to 2017 2016-12-16 12:49:48 +08:00
winlin
7ac932cfa0 update to 2013-2017 2016-12-16 11:57:25 +08:00
winlin
b231550c32 fix #717, #691, http api/static/stream support cors. 3.0.9 2016-12-15 16:22:04 +08:00
winlin
f6661989af fix typo for #513, #691 2016-12-15 15:00:08 +08:00
winlin
664844b5f5 merge from srs2. for #513. 2016-12-15 14:54:09 +08:00
winlin
f30b3073a2 refine the cros of api for flv 2016-12-15 14:10:02 +08:00
winlin
3df8f11884 refine thread stop 2016-12-14 18:21:50 +08:00
winlin
fd693915c3 Merge branch '2.0release' into develop 2016-12-13 19:14:36 +08:00
winlin
c8aa34f0be merge srs2 2016-12-13 19:08:09 +08:00
winlin
8935fe8897 merge srs2. 2016-12-13 18:43:22 +08:00
winlin
9ba4bed648 merge srs2 2016-12-13 17:58:42 +08:00
winlin
439c67018d remove unused macros. 2016-12-09 15:58:59 +08:00
winlin
2955b1fd2d support log rotate signal SIGUSR1. 3.0.8 2016-12-08 18:23:22 +08:00
winlin
9e9cad1826 refine messages 2016-12-08 17:55:11 +08:00
winlin
dd1c769f65 refine main 2016-12-08 17:35:33 +08:00
winlin
83c251fc1c fix bug 2016-12-08 17:29:13 +08:00
winlin
2d387035cd refine the global variables. 2016-12-08 17:26:04 +08:00
winlin
b06203e777 dispose kafka 2016-12-08 11:48:50 +08:00
winlin
9a3674c624 refine kafka 2016-12-08 11:44:49 +08:00
winlin
5a76f15e4e fix typo and refine grammar. 3.0.7 2016-12-07 14:43:14 +08:00
winlin
cda9beeba7 refine comments 2016-12-07 14:40:25 +08:00
winlin
d194691c09 refine comments 2016-12-07 14:37:28 +08:00
winlin
28517849ed refine typo 2016-12-07 12:09:39 +08:00
winlin
f6c8e02cca Merge branch '2.0release' into develop 2016-11-24 18:12:31 +08:00
winlin
6dfb44b7b5 Merge branch '2.0release' into develop 2016-11-15 10:43:42 +08:00
winlin
0a8d40925f merge from 2.0 2016-11-09 09:44:19 +08:00
winlin
2f5f7d4a7b merge srs2 2016-10-26 09:55:24 +08:00
winlin
5796e4bf89 merge from srs2 2016-10-26 09:53:27 +08:00
winlin
112d98ffdb merge srs2. 2016-10-10 11:56:10 +08:00
winlin
7deda9370c Merge branch '2.0release' into develop 2016-09-27 14:55:07 +08:00
winlin
78aa518ecc merge srs2 2016-09-27 11:00:13 +08:00
winlin
9cc528cd33 merge srs2 2016-09-23 15:47:17 +08:00
winlin
0e308b0fa1 merge srs2, support oryx 2016-09-23 15:33:43 +08:00
winlin
b5d466f3d2 update utest 2016-09-15 14:47:42 +08:00
winlin
0fb71281a9 add circleci 2016-09-15 14:28:54 +08:00
winlin
e15e07c4d1 merge srs2 2016-09-15 13:39:25 +08:00
winlin
0596550a72 Merge branch '2.0release' into develop 2016-09-15 13:31:28 +08:00
winlin
77bca7cc05 Merge branch '2.0release' into develop 2016-09-13 18:08:19 +08:00
winlin
6b8fe92afa Merge branch '2.0release' into develop 2016-09-13 15:53:40 +08:00
winlin
504352d17a merge srs2. 2016-09-12 18:21:44 +08:00
winlin
c231f45fe8 Merge branch '2.0release' into develop 2016-09-09 14:57:58 +08:00
winlin
66f251c6be update readme 2016-09-09 14:33:07 +08:00
winlin
8a4e241eec merge from srs2 2016-09-09 14:29:33 +08:00
winlin
eb915413ad Merge branch '2.0release' into develop 2016-09-09 14:14:22 +08:00
winlin
93eb961b4c Merge branch '2.0release' into develop 2016-09-09 11:33:58 +08:00
winlin
09895fcfc2 Merge branch '2.0release' into develop 2016-09-09 11:03:39 +08:00
winlin
4342d3ed18 Merge branch '2.0release' into develop 2016-09-09 10:59:24 +08:00
winlin
17df61724d Merge branch '2.0release' into develop 2016-09-08 19:56:17 +08:00
winlin
2cf077abe9 Merge branch '2.0release' into develop 2016-09-08 18:55:40 +08:00
winlin
b24d1de377 Merge branch '2.0release' into develop 2016-09-05 14:56:41 +08:00
winlin
0e9318e5d8 merge from 2.0 2016-09-05 14:16:24 +08:00
winlin
815f2491a4 merge from 2.0 2016-09-05 09:39:20 +08:00
winlin
39a46f7b97 Merge branch '2.0release' into develop 2016-09-03 23:11:58 +08:00
winlin
c0498c82ee merge 2.0 2016-09-03 18:48:19 +08:00
winlin
8ad7da1cb6 merge from 2.0 2016-09-02 15:25:20 +08:00
winlin
7933b6abd2 update readme 2016-09-01 17:11:18 +08:00
winlin
ce6f4bfbe0 refine readme 2016-09-01 17:07:54 +08:00
winlin
861d845f54 refine readme 2016-09-01 17:05:43 +08:00
winlin
7d96a33207 Merge branch '2.0release' into develop 2016-09-01 16:51:18 +08:00
winlin
b49cb3d379 Merge branch '2.0release' into develop 2016-08-30 19:30:05 +08:00
winlin
5d5fa7204d Merge branch '2.0release' into develop 2016-08-18 12:22:30 +08:00
winlin
bf22acd689 Merge branch '2.0release' into develop 2016-08-18 11:29:22 +08:00
winlin
7df7156e07 Merge branch '2.0release' into develop 2016-08-17 10:12:34 +08:00
winlin
31a1b7bed2 Merge branch '2.0release' into develop 2016-08-10 22:30:05 +08:00
winlin
d68a459198 Merge branch '2.0release' into develop 2016-08-10 22:13:30 +08:00
winlin
14760003ba merge from 2.0 2016-08-10 22:05:21 +08:00
winlin
516f33888c refine config 2016-08-09 12:37:48 +08:00
winlin
36eb0981ec merge from 2.0release 2016-08-08 14:09:10 +08:00
winlin
84c2a3c190 merge 2.0release 2016-08-08 13:59:41 +08:00
winlin
abeb4f46a9 merge 2.0 2016-08-06 17:28:43 +08:00
winlin
499fc07db1 refine the hls m3u8 refresh interval. 2016-08-02 16:52:23 +08:00
winlin
5fa500646e update srs player version 2016-08-02 16:37:52 +08:00
winlin
ec57e2170d refine hls m3u8 refresh interval and buffer time 2016-08-02 16:31:59 +08:00
winlin
c0c83848a4 update donation 2016-07-17 08:29:06 +08:00
winlin
b463e4a2f4 Merge branch '2.0release' into develop 2016-05-17 10:54:34 +08:00
winlin
c746753c6a update player, add pst(player startup time) 2016-04-22 13:33:29 +08:00
winlin
892591f9a6 merge from @mbeacom 2016-04-22 10:18:13 +08:00
winlin
2e75c9f45f add more buffer 2016-04-19 18:15:47 +08:00
winlin
9312d77c20 default not to preview the stream for publisher. 2016-04-12 11:32:13 +08:00
winlin
6b5c880ff9 refine player to support status change. 2016-03-22 18:35:44 +08:00
winlin
4841435b14 fix default http port bug. 2016-03-19 22:45:39 +08:00
winlin
a2d235f015 refresh js cache. 2016-03-19 22:14:56 +08:00
winlin
d7a28059ed remove jwplayer and osmf 2016-03-19 22:09:36 +08:00
winlin
d9f1ced732 change srs player to 1.28 2016-03-19 22:00:22 +08:00
winlin
77167f3331 refine srs player for hls, extract a HlsNetStream. 2016-03-19 21:54:46 +08:00
winlin
2492562d25 use xpsid X-Playback-Session-Id to more useful. 2016-03-19 19:48:01 +08:00
winlin
b2bd63e833 refine srs player to play hls. 2016-03-19 19:11:31 +08:00
winlin
46a31f4884 support play hls 2016-03-19 16:35:13 +08:00
winlin
69ec66ee36 refine js for player. 2016-03-19 11:08:25 +08:00
winlin
0a2e00f8c5 dump logs 2016-03-19 10:18:11 +08:00
winlin
9ab5039b36 extract iplayer for srs-player. 2016-03-19 10:06:08 +08:00
winlin
10ce961a00 update version for bwtc 2016-03-14 10:23:20 +08:00
winlin
b3c13f2550 refine the bwtc, to compatible with bms4. 2016-03-12 20:53:37 +08:00
winlin
eed4626c35 use larger limit 2016-03-10 12:28:46 +08:00
winlin
a3038b1274 fix the rtmp url parse bug. 2016-03-10 12:16:51 +08:00
winlin
82aa9d120c for #5114, display metadata. 2016-03-07 16:02:37 +08:00
winlin
a8ee3162d4 Merge branch '2.0release' into develop 2016-03-03 15:30:38 +08:00
winlin
1df29de19d update donation 2016-03-03 14:11:33 +08:00
winlin
00c60db7c3 Merge branch '2.0release' into develop 2016-01-31 22:47:48 +08:00
winlin
6008160ef4 update donation 2016-01-27 14:25:04 +08:00
winlin
4a56003798 update donation 2016-01-21 22:32:10 +08:00
winlin
8db25a0bf5 fix the log for mmap. 2016-01-21 16:18:42 +08:00
winlin
214eda745d open null dev, not close stdout or stderr. 2016-01-20 14:53:25 +08:00
winlin
a5e5fd3784 refine readme 2016-01-20 14:21:58 +08:00
winlin
6c80ecbbf9 update readme 2016-01-20 14:19:53 +08:00
winlin
03469fc37d refine code for process fork. 2016-01-20 14:09:14 +08:00
winlin
ce8f3b4478 refine the dup2 of stdout and stderr. 2016-01-20 14:05:48 +08:00
winlin
ae8bd4c2aa should never close the fd 3+, for it myabe used. 2016-01-20 14:01:18 +08:00
winlin
a6dc17a67d support redirect stdout by > 2016-01-20 14:00:01 +08:00
winlin
0cd15068de set default buffer time to 0.5 for srs player. 2016-01-18 18:02:56 +08:00
winlin
27690f9e52 Merge branch '2.0release' into develop 2016-01-13 17:31:40 +08:00
winlin
f8358da316 refine ingester log. 2016-01-13 16:20:05 +08:00
winlin
dfe5306327 fix process bug. 2016-01-13 16:18:50 +08:00
winlin
61c0c168b9 merge from srs2. 2016-01-13 12:52:19 +08:00
winlin
266397acee merge from srs2 2016-01-13 12:46:23 +08:00
winlin
f971538cf3 refine http, support no host. 2016-01-12 11:53:52 +08:00
winlin
2941328ee8 rtmp edge support 302 redirect. 2016-01-11 15:46:23 +08:00
winlin
a11ab5ad24 merge from srs2. 2016-01-11 13:22:45 +08:00
winlin
d81b2cb140 support hls mount to vhost and reload 2016-01-11 13:15:46 +08:00
winlin
041040b846 ignore ingester when vhost disabled. 2016-01-11 13:11:14 +08:00
winlin
eac5440559 merge from srs2 #558 #559 2016-01-09 16:06:22 +08:00
winlin
d24aef50ba for #369, support RTMP 302 api at protocol level. 2016-01-08 18:17:37 +08:00
winlin
f1e7e9d933 support gmd. change work_dir. hourglass. add utilies. 2016-01-08 13:58:19 +08:00
winlin
c9b977d337 update donation 2016-01-06 16:34:47 +08:00
winlin
5338f21439 merge from srs2 2016-01-05 16:58:21 +08:00
winlin
e150fb3f70 merge from srs2 2016-01-04 17:42:50 +08:00
winlin
9d22d09646 show signature of server. 2016-01-04 17:28:18 +08:00
winlin
973194c663 merge from srs2. 2015-12-31 16:02:01 +08:00
winlin
f516636448 refine code for hooks and http core. 2015-12-29 18:33:02 +08:00
winlin
79fdc4e766 fix bug for rtmp client use NULL ptr. 2015-12-28 18:13:40 +08:00
winlin
96a4428bdb refine the http request parse. edge retry timeout. 2015-12-28 18:02:20 +08:00
winlin
190db75835 refine code for nx_json modify the data when loads. 2015-12-28 17:39:24 +08:00
winlin
86a7db0adb refine edge ingester, use upstream adapter. 2015-12-28 17:15:44 +08:00
winlin
7ae2c6bf50 merge from srs2. 2015-12-26 12:17:51 +08:00
winlin
11e11005ac specifies the try default vhost 2015-12-24 19:14:23 +08:00
winlin
d267b8fa19 fix bug for create connection with ip. 2015-12-24 17:38:49 +08:00
winlin
a7bf4bfda5 refine code, ignore client when no ip. 2015-12-24 17:25:05 +08:00
winlin
49308dddfb update 2015 to 2016 2015-12-23 11:41:41 +08:00
winlin
d0c74fa7cd update 2015 to 2016 2015-12-23 11:35:40 +08:00
winlin
384de15094 merge srs2 2015-12-23 10:18:18 +08:00
winlin
714c13d88d merge from srs2 2015-12-22 19:19:28 +08:00
winlin
65b81a4e68 merge from srs2 2015-12-22 17:01:06 +08:00
winlin
b881166f9a merge from srs2 2015-12-22 16:18:09 +08:00
winlin
5f915aa959 merge from srs2 2015-12-22 15:40:03 +08:00
winlin
e124aeb614 Merge branch '2.0release' into develop 2015-12-15 16:25:27 +08:00
winlin
0ab64ccd2a merge from srs2. 2015-12-15 16:06:40 +08:00
winlin
f6ff116505 refine code, persistence use isolate method. 2015-12-15 14:27:49 +08:00
winlin
b486f6fe6b refine /api/v1/summaries, with code and server id. 2015-12-15 12:46:47 +08:00
winlin
9b3fdc74d8 fix bug for api, level should be string. 2015-12-14 18:43:49 +08:00
winlin
ffef3905af merge from srs2. 2015-12-11 11:35:56 +08:00
winlin
1e4c8f8bf3 fast stop server. 2015-12-11 10:30:13 +08:00
winlin
3ab5892863 refine comments. 2015-12-10 18:02:23 +08:00
winlin
5ac8177ce6 fix bugs 2015-12-08 18:32:37 +08:00
winlin
fabcc91a0e refine codes. 2015-12-07 18:22:55 +08:00
winlin
b2ae1acaa4 copy http-parser-2.1 into srs http stack. 2015-12-07 11:35:05 +08:00
winlin
fba1122835 private the srs_vhost_resolve 2015-12-07 10:15:08 +08:00
winlin
17bb31cab1 fix the config bug. 2015-12-04 15:22:13 +08:00
winlin
eec2c34b5c refine publisher. 2015-12-01 10:42:13 +08:00
winlin
cfe230438a revert test code 2015-11-30 19:07:52 +08:00
winlin
6191e0af90 s1 compute key. 2015-11-30 19:05:25 +08:00
winlin
cafe886c3f merge srs2 2015-11-27 17:46:00 +08:00
winlin
18eb8c81b3 merge from srs2 2015-11-16 18:10:06 +08:00
winlin
51ed4b1e82 update donation 2015-11-13 14:57:00 +08:00
winlin
7ea0394b67 update donations 2015-11-12 17:37:44 +08:00
winlin
44b26271bf Merge branch '2.0release' into develop 2015-11-11 17:12:34 +08:00
winlin
01c46bdbfd rename org simle-rtmp-server to ossrs 2015-11-11 10:45:45 +08:00
winlin
6c7a51d310 Merge branch '2.0release' into develop 2015-11-10 12:16:08 +08:00
winlin
d2ccc4f661 Merge branch '2.0release' into develop 2015-11-10 12:15:00 +08:00
winlin
7db7d43aea Merge branch '2.0release' into develop 2015-11-09 15:25:55 +08:00
winlin
aca9fe805c Merge branch '2.0release' into develop 2015-11-09 14:51:47 +08:00
winlin
a3a6282fe9 merge srs2. 2015-11-06 10:52:29 +08:00
winlin
75be18133d fix build failed for utest. 2015-11-06 10:26:18 +08:00
winlin
6df4d1f05a merge from srs2. 2015-11-05 15:12:49 +08:00
winlin
97f5bb8b99 merge from srs2 2015-11-05 14:48:25 +08:00
winlin
6e3eb50b78 Merge branch '2.0release' into develop 2015-11-02 13:51:07 +08:00
winlin
302be41d00 merge from srs2.0.198 2015-11-02 13:49:27 +08:00
winlin
2b21a63d8f merge from srs2. 2015-11-02 13:43:22 +08:00
winlin
4b5eb5ea2d fix the parse rtmp url bug for ingest. 2015-11-02 13:37:44 +08:00
winlin
e3407c1dd2 merge from srs2. 2015-11-02 11:49:23 +08:00
winlin
9d7826c681 quit child process when fork failed. 2015-11-02 11:44:22 +08:00
winlin
f57e537686 for #515, merge from srs2, use SrsAutoFreeA. 2015-11-02 11:29:20 +08:00
winlin
604486b0a3 for #515, use srs_freepa to free array. 2015-11-02 11:11:49 +08:00
winlin
8cec06e898 merge srs2, use srs_freepa for array 2015-11-02 11:05:39 +08:00
winlin
cef1ae5a8e fix the config bug. 2015-10-28 12:55:16 +08:00
winlin
9ebb77d711 fix the warnings 2015-10-28 11:58:49 +08:00
winlin
e9e202dbf1 merge srs2 2015-10-28 11:51:32 +08:00
winlin
8c96472cea merge srs2 2015-10-28 11:03:15 +08:00
winlin
59f5c5d6a5 Merge branch '2.0release' into develop 2015-10-27 18:21:04 +08:00
winlin
390f58e186 fix compile failed. 2015-10-27 17:57:58 +08:00
winlin
a416e891b4 fix compile failed. 2015-10-27 17:54:07 +08:00
winlin
1d57e53910 merge from 2.0release 2015-10-27 17:45:14 +08:00
winlin
fe27e76492 support schema 2015-10-26 18:34:55 +08:00
winlin
a501f5bd7a update htbt script 2015-10-26 14:54:41 +08:00
winlin
dd2945add1 update htbt script 2015-10-26 14:53:54 +08:00
winlin
6f6d495a19 update htbt script 2015-10-26 14:50:16 +08:00
winlin
3933819686 add htbt script 2015-10-26 14:18:19 +08:00
winlin
0a8cb8a391 add heartbeat script 2015-10-26 14:17:24 +08:00
winlin
11979229e6 Merge branch '2.0release' into develop 2015-10-26 13:34:44 +08:00
winlin
1cfd678102 Merge pull request #510 from simple-rtmp-server/feature/kafka
Feature/kafka
2015-10-23 14:45:29 +08:00
winlin
b8f2ba4f0d complete kafka 2015-10-23 14:42:05 +08:00
winlin
cbe4252b4d refine code. 2015-10-23 14:42:04 +08:00
winlin
d2ca51ac50 notify kafka when client close 2015-10-23 14:42:04 +08:00
winlin
71451878c9 refine kafka, simplify code. 2015-10-23 14:42:04 +08:00
winlin
9a47390253 fix #467, support write log to kafka. 3.0.6 2015-10-23 14:42:04 +08:00
winlin
76cd3f8749 kafka convert json to producer message. 2015-10-23 14:42:04 +08:00
winlin
8e344f1c26 add producer api messages. 2015-10-23 14:42:04 +08:00
winlin
7a0aaf5900 kafka refine code 2015-10-23 14:42:04 +08:00
winlin
f9f5b56951 kakfa erase messages when wrote. 2015-10-23 14:42:04 +08:00
winlin
22fa9a0f1f kafka use temp transport to fetch metadata. 2015-10-23 14:42:04 +08:00
winlin
531b658f8e retry when metadata empty 2015-10-23 14:42:04 +08:00
winlin
61486a82aa kafka use topic and partition cache 2015-10-23 14:42:04 +08:00
winlin
7013993c7a kafka send the accept message. 2015-10-23 14:42:04 +08:00
winlin
de41c1c9d2 kafka refine comments. 2015-10-23 14:42:04 +08:00
winlin
31a77a83ed convert metadata to partitions 2015-10-23 14:42:04 +08:00
winlin
f0e39cc330 support show the summary of kafka metadata. 2015-10-23 14:42:04 +08:00
winlin
d013374871 rename ISrsCodec size to nb_bytes. 2015-10-23 14:42:03 +08:00
winlin
33a015329d add function to convert kafka array to vector 2015-10-23 14:42:03 +08:00
winlin
84b3981d47 refs #1670: support decode the metadata response. 2015-10-23 14:42:03 +08:00
winlin
7106934c3a kafka producer use async interface to request metadata. 2015-10-23 14:42:03 +08:00
winlin
a108fa8d01 kafka recv and decode message. 2015-10-23 14:42:03 +08:00
winlin
493d282255 kafka refine array, to decode and create object. 2015-10-23 14:42:03 +08:00
winlin
c4862878d1 kafka rename message set to raw message set. 2015-10-23 14:42:03 +08:00
winlin
6e5ed11a00 for kafka, support correlation id cache. 2015-10-23 14:42:03 +08:00
winlin
2e67eb8786 refine comments for kafka messages. 2015-10-23 14:42:03 +08:00
winlin
3c64e4b957 kafka encode and send packet. 2015-10-23 14:42:03 +08:00
winlin
9117e1e918 extract ISrsCodec for code and decode object. 2015-10-23 14:42:03 +08:00
winlin
45755fd1e7 refine code for kakfa request/response, string/bytes. 2015-10-23 14:42:03 +08:00
winlin
8a4ec49064 add graph comments for size of request and response. 2015-10-23 14:42:03 +08:00
winlin
8974fe298b connect to kafka and send metadata request. 2015-10-23 14:42:03 +08:00
winlin
a9fdb630d9 refine code, replace all rtmp connect by simple rtmp client. 2015-10-23 14:42:02 +08:00
winlin
a08d8f83d6 refine mpegts code, use simple rtmp client 2015-10-23 14:42:02 +08:00
winlin
ad9b377d96 refine forwarder code, use simple rtmp client. 2015-10-23 14:42:02 +08:00
winlin
0f4cb8ee00 refine code, remove the rtmp recv/send macro, use one macro. 2015-10-23 14:42:02 +08:00
winlin
12e013142d refine code, use simple rtmp client. 2015-10-23 14:42:02 +08:00
winlin
bc27481886 refine code, use simple rtmp client. 2015-10-23 14:42:02 +08:00
winlin
e4c852945f refine code, support override vhost 2015-10-23 14:42:02 +08:00
winlin
a9ad7b211b refine simple rtmp client for post flv stream. 2015-10-23 14:42:02 +08:00
winlin
adb8f243bf use simple rtmp client for raw connect app 2015-10-23 14:42:02 +08:00
winlin
24b3899972 use SrsTcpClient instead raw socket. 2015-10-23 14:42:02 +08:00
winlin
a9bb6061c3 use tcp client for raw connect. 2015-10-23 14:42:02 +08:00
winlin
20fcfb3eee fix bug, use system utility 2015-10-23 14:42:02 +08:00
winlin
69cc01b696 use system utilities 2015-10-23 14:42:02 +08:00
winlin
908365a61a use string for const char* 2015-10-23 14:42:02 +08:00
winlin
d9f991ed2f use system utility for string finds 2015-10-23 14:42:02 +08:00
winlin
ca73534d7e refine comments for api key 2015-10-23 14:42:01 +08:00
winlin
21deeb8649 update donation for zanjie. 2015-10-22 23:54:25 +08:00
winlin
9d471199ea update donations 2015-10-21 21:40:55 +08:00
winlin
d115f53770 merge from srs2 2015-10-20 16:41:59 +08:00
winlin
29122b6e70 fix #502, transcoder support snapshot. 2015-10-20 14:52:34 +08:00
winlin
2bae6e09d3 for #502, snapshot 1 image per 1 seconds, choose best from 5 images. 2015-10-20 14:10:14 +08:00
winlin
1aa4502d5f for snapshot, choose the best to link to the [stream]-best.png 2015-10-20 13:38:03 +08:00
winlin
33a282e576 support snapshot by http hooks for #152. 2015-10-20 12:30:57 +08:00
winlin
9eebb89432 Merge branch '2.0release' into develop 2015-10-20 10:17:54 +08:00
winlin
57a3b11b86 merge from srs2 2015-10-13 11:48:02 +08:00
winlin
b5ba1043e8 Merge branch '2.0release' into develop 2015-10-08 16:07:54 +08:00
winlin
c8c4673231 release srs 2.0 alpha2, 2.0.195 2015-10-08 09:27:53 +08:00
winlin
fbff42b33a release srs 2.0 alpha2, 2.0.195 2015-10-08 09:27:04 +08:00
winlin
56412edb5f release srs 2.0 alpha2, 2.0.195 2015-10-08 09:25:28 +08:00
winlin
ed80d9d281 merge from srs2 2015-10-04 08:10:57 +08:00
winlin
6587c5b2f1 merge from srs2 2015-10-01 13:22:51 +08:00
winlin
8862ec1988 merge from srs2 2015-10-01 13:05:25 +08:00
winlin
070ada1d6e Merge branch '2.0release' into develop 2015-10-01 12:30:55 +08:00
winlin
d8f18aee37 use the right int type for port. 2015-09-24 18:33:07 +08:00
winlin
1c7d5f1852 Merge branch '2.0release' into develop 2015-09-24 17:55:33 +08:00
winlin
9ead08725d use kernel utility int2str and float2str 2015-09-24 17:54:58 +08:00
winlin
6efd2dd27e add load balance round robin for brokers. 2015-09-24 17:20:04 +08:00
winlin
2a4ab8a923 add brokers to config 2015-09-24 14:53:22 +08:00
winlin
f187a7deef refine the startup logs. 2015-09-24 12:15:12 +08:00
winlin
3ab0ccaa27 Merge branch '2.0release' into develop 2015-09-23 18:23:17 +08:00
winlin
afd6428366 refine code of server. 2015-09-23 17:21:57 +08:00
winlin
8b6c78b862 Merge branch '2.0release' into develop 2015-09-23 16:42:47 +08:00
winlin
396bb43672 Merge branch '2.0release' into develop 2015-09-23 15:46:58 +08:00
winlin
4e88262512 merge from srs2 to check cpus. 2015-09-23 15:11:33 +08:00
winlin
d94a88a797 merge from srs2 for pi and cubie. 2015-09-23 11:23:55 +08:00
winlin
f75058413d Merge branch '2.0release' into develop 2015-09-23 10:39:24 +08:00
winlin
9a9483e7d5 support without kafka 2015-09-22 17:46:07 +08:00
winlin
abb5c5ad31 add kafka producer 2015-09-22 17:40:05 +08:00
winlin
b5ccc35340 add kafka config 2015-09-22 15:10:43 +08:00
winlin
ab1e62a886 create the metadata request message 2015-09-22 14:33:17 +08:00
winlin
ca3b89aa7d add kafka array, use c++ template. 2015-09-22 14:09:24 +08:00
winlin
8a6edac4e8 add --x86-64 alias for --x86-x64. 2015-09-22 13:52:14 +08:00
winlin
edead21a25 refine the options 2015-09-22 12:51:29 +08:00
winlin
e415824576 refine the options 2015-09-22 12:43:22 +08:00
winlin
2d5cc7a3e4 add structures for kafka 2015-09-22 12:38:07 +08:00
winlin
83f40697e2 refine the hpp macro defines. 2015-09-22 09:15:51 +08:00
winlin
df6ac8842c rename rtmp utility to protocol utility 2015-09-22 09:11:07 +08:00
winlin
82ff05c1d4 rename rtmp io to protocol io 2015-09-22 09:07:07 +08:00
winlin
168625dce2 rename rtmp amf0 to protocol amf0. 2015-09-22 09:05:21 +08:00
winlin
1310c0f577 rename srs_protocol_buffer to srs_protocol_stream 2015-09-22 09:02:37 +08:00
winlin
d32632ee8a rename SrsFastBuffer to SrsFastStream 2015-09-22 09:01:47 +08:00
winlin
4f3d2c8607 rename SrsSimpleBuffer to SrsSimpleStream 2015-09-22 08:59:52 +08:00
winlin
dadfe101b4 rename SrsBitStream to SrsBitBuffer 2015-09-22 08:59:21 +08:00
winlin
0e52fc6d5b rename SrsStream to SrsBuffer 2015-09-22 08:57:31 +08:00
winlin
ca3577e11b rename temp to stream 2015-09-22 08:52:00 +08:00
winlin
f33d736442 rename kernel stream to buffer 2015-09-22 08:50:14 +08:00
winlin
a4f51564db rename kernel stream to buffer 2015-09-22 08:48:55 +08:00
winlin
495f575ac3 rename kernel buffer to temp 2015-09-22 08:43:56 +08:00
winlin
ac2b03a3ed rename srs_kernel_buffer to temp 2015-09-22 08:42:54 +08:00
winlin
faf6d15878 add replace script. 2015-09-21 18:32:17 +08:00
winlin
1de2bb0801 add kafka protocol files. 2015-09-21 17:12:28 +08:00
winlin
874ae85e47 update readme. 2015-09-21 14:26:31 +08:00
winlin
22d6ec4f93 update readme. 2015-09-21 14:24:06 +08:00
winlin
841d9ee5ad update readme. 2015-09-21 14:20:30 +08:00
winlin
f07d7dcf35 update readme. 2015-09-21 14:19:07 +08:00
winlin
ddb0dcdcaa update readme. 2015-09-21 14:13:07 +08:00
winlin
99e27c035a update readme. 2015-09-21 13:52:16 +08:00
winlin
0fb353f1f6 update readme. 2015-09-21 13:50:01 +08:00
winlin
e5581981d4 Merge branch '2.0release' into develop 2015-09-21 13:39:15 +08:00
winlin
bbbb4e5025 update readme. 2015-09-21 13:37:42 +08:00
winlin
e5429fef02 update readme. 2015-09-21 13:34:28 +08:00
winlin
a6377fe456 refine readme 2015-09-21 13:26:08 +08:00
winlin
533b9a5cfb Merge branch '2.0release' into develop 2015-09-21 13:24:34 +08:00
winlin
f42cd55078 refine readme 2015-09-21 13:24:05 +08:00
winlin
03c2884f8c refine readme 2015-09-21 13:17:54 +08:00
winlin
c90e117bbf refine readme 2015-09-21 12:41:45 +08:00
winlin
d98fc58e8b refine readme 2015-09-21 12:32:14 +08:00
winlin
b5996567e8 refine the role of srs, to cluster. 2015-09-21 12:09:09 +08:00
winlin
e4e36a0166 merge from srs2, fix openssl build 2015-09-21 12:03:47 +08:00
winlin
b471c6e61c refine code, use json integter rather than number. 2015-09-19 14:40:32 +08:00
winlin
c5cd58761c move the srs thread to st. 2015-09-19 13:46:55 +08:00
winlin
3042115385 refine json to_str to dumps. 2015-09-19 13:37:56 +08:00
winlin
b59d9ba6a1 support amf0 and json to convert with each other. 2015-09-19 13:31:57 +08:00
winlin
3f7e69b617 json objects support dumps to string. 2015-09-19 12:27:31 +08:00
winlin
b78781707e update the srs player 2015-09-17 18:07:02 +08:00
winlin
5073a6fa08 merge from srs2 2015-09-17 18:06:03 +08:00
winlin
225e742657 add args3 2015-09-17 14:03:25 +08:00
winlin
1fd83d9314 refine the order. 2015-09-17 13:36:02 +08:00
winlin
7b2b11e932 async call worker fast execute tasks. 2015-09-17 11:57:17 +08:00
winlin
087f7740b7 fix the build failed bug 2015-09-17 11:41:23 +08:00
winlin
256459e1ec fix the utest bug 2015-09-17 11:37:35 +08:00
winlin
240a1bfadb rename kafka protocol 2015-09-16 13:56:52 +08:00
winlin
c4e4711b93 add kafka protocol 2015-09-16 13:55:11 +08:00
winlin
8a90e76637 fix #459, support dvr raw api. 3.0.4 2015-09-15 23:00:00 +08:00
winlin
2b9869ee52 update the wiki for dvr 2015-09-15 17:58:35 +08:00
winlin
2a1b2b69a0 for #459, dvr support apply filter for ng-control dvr module. 2015-09-15 15:58:57 +08:00
winlin
8f9cfcdcf4 fix #319, http raw api support update global and vhost. 3.0.4 2015-09-15 13:03:18 +08:00
winlin
e8a00de4a3 for #319, support enable or disable vhost. 2015-09-15 12:51:14 +08:00
winlin
631e76cd32 for #319, support update and delete the disabled vhost 2015-09-15 12:15:18 +08:00
winlin
95979674f9 merge srs 2 2015-09-14 21:09:34 +08:00
winlin
a865eb9ccb merge from srs2 2015-09-14 20:58:54 +08:00
winlin
a7c4b786cf merge from 2.0 2015-09-14 18:42:31 +08:00
winlin
eb9aa47ab1 merge from 2.0 2015-09-14 13:48:27 +08:00
winlin
3b483094bd merge from 2.0 2015-09-14 12:24:57 +08:00
winlin
adb74dc74e Merge branch '2.0release' into develop 2015-09-14 11:17:19 +08:00
winlin
ad6de898a5 Merge branch '2.0release' into develop 2015-09-14 09:29:09 +08:00
winlin
88e7e1c784 update donation. 2015-09-14 09:08:01 +08:00
winlin
0038c9a88d Merge branch '2.0release' into develop 2015-09-13 18:16:07 +08:00
winlin
589d430086 Update README.md 2015-09-13 18:14:56 +08:00
winlin
61d817bad5 Update README.md 2015-09-13 18:07:26 +08:00
winlin
00fef04bcd merge from 2.0 2015-09-13 18:06:21 +08:00
winlin
f09019ea0d update donation 2015-09-13 17:57:40 +08:00
winlin
01308ecc98 for #319, support initialize the parser to whether use jsonp 2015-09-12 22:22:33 +08:00
winlin
491ec11833 for #319, raw api support add new vhost 2015-09-12 21:55:53 +08:00
winlin
0d6c24581d refine json number, use int64 when number is int. 2015-09-12 16:36:29 +08:00
winlin
7ae76b579e refine the conf, use srs3 style 2015-09-11 08:21:06 +08:00
winlin
77d21f7e32 refine readme, fix typo 2015-09-11 08:02:45 +08:00
winlin
6931bdd6d5 refine readme, the module and arch 2015-09-11 08:00:16 +08:00
winlin
d76eda35ab refine readme, add exec for stream arch 2015-09-11 07:47:40 +08:00
winlin
a0c6e4ee8c refine readme, add exec for stream arch 2015-09-11 07:47:08 +08:00
winlin
9d85025114 Update README.md 2015-09-11 07:38:58 +08:00
winlin
db1ed513be Update README.md 2015-09-11 07:37:57 +08:00
winlin
d56b9fd90f refine readme 2015-09-11 07:35:42 +08:00
winlin
a88f321d8b for #319, merge from 2.0release 2015-09-09 23:41:11 +08:00
winlin
c4feb8f6ed for #319, raw api support update all globals. 2015-09-09 23:32:02 +08:00
winlin
6aafd072db for #319, raw api support update srs log tank, level and file. 2015-09-09 22:44:34 +08:00
winlin
8107e5f9a6 for #319, raw api support set the ff_log_dir 2015-09-09 21:46:29 +08:00
winlin
c8466c36bd for #319, raw api support update the global RTMP chunk_size. 2015-09-01 21:27:04 +08:00
winlin
2cfb71616e for #319, copy all data to request for source. 2015-09-01 18:52:29 +08:00
winlin
2bdd974227 for #319, reorder the ingesters. 2015-09-01 18:41:30 +08:00
winlin
342483bf04 for #319, when reload the listen, restart all ingesters. 2015-09-01 18:39:14 +08:00
winlin
310b5a14cb for #319, support minimal query api 2015-09-01 13:33:49 +08:00
winlin
06c7ae62ee for #319, refine the error code for RAW APi. 2015-09-01 12:27:53 +08:00
winlin
11c409688b for #319, http raw api support query. 3.0.3 2015-08-31 23:34:03 +08:00
winlin
8a2709dd2c for #319, do not apply when config not changed. 2015-08-31 12:06:22 +08:00
winlin
a62c82bd46 for #319, api raw update global.listen 2015-08-30 23:42:21 +08:00
winlin
364460f2ab for #319, support raw update global.listen 2015-08-30 23:18:14 +08:00
winlin
f8d8c3ace4 use function to dumps the engine. 2015-08-30 23:08:27 +08:00
winlin
01878e5a9c for #319, query vhost detail. 2015-08-30 22:23:47 +08:00
winlin
b1b76a4a80 for #319, allow multiple ingest and transcode. 2015-08-30 14:52:12 +08:00
winlin
873aa7bf9f for #319, refine the query global, only show true options. 2015-08-30 12:16:26 +08:00
winlin
d1336e0d80 refine conf 2015-08-30 10:52:05 +08:00
winlin
dc11013c01 for #319, render the detail of vhost 2015-08-30 10:17:39 +08:00
winlin
0109a74840 for #319, refine the config structure. 2015-08-30 08:34:52 +08:00
winlin
2b4fa2d73e for #319, move the edge configs to cluster. 2015-08-30 08:30:04 +08:00
winlin
6bd05f9cfc for #319, refine the config forward. 2015-08-30 07:59:25 +08:00
winlin
bc24c0407b for #319, move smi and rsh to play 2015-08-30 07:36:06 +08:00
winlin
f7c893d907 for #319, move gop_cache and queue_length to play 2015-08-30 07:26:55 +08:00
winlin
06ae74dd3f for #319, move mw_latency to play. 2015-08-30 07:05:57 +08:00
winlin
4eb1874955 for #319, the vhost scope config is enabled, chunk_size, tcp_nodelay and min_latency. 2015-08-30 06:49:20 +08:00
winlin
9c4340f789 for #319, move atc and atc_auto to play 2015-08-29 23:36:03 +08:00
winlin
d6b0aa3a5b for #319, move time_jitter and mix_correct to play 2015-08-29 23:18:25 +08:00
winlin
738642073e for #319, refine config, collect the mr and publish timeout 2015-08-29 22:41:50 +08:00
winlin
bc100c2867 refine the log, move default to each functions. 2015-08-29 19:46:56 +08:00
winlin
7ef3ff90c0 refine the config structure, compatible with SRS1/2 2015-08-29 18:40:18 +08:00
winlin
a79e19599c for #319, support query the vhost info. 2015-08-29 16:12:30 +08:00
winlin
bdfd0ae09e for #319, dumps the http static, remux and globals. 2015-08-28 23:51:23 +08:00
winlin
5efd1912f2 refine readme 2015-08-28 22:21:18 +08:00
winlin
871ac95c2e merge from srs 2 2015-08-28 18:49:41 +08:00
winlin
c290951d20 merge from srs2 2015-08-28 18:18:49 +08:00
winlin
1b1a2a1e63 fix #471, api response the width and height. 3.0.2 2015-08-28 18:00:24 +08:00
winlin
04bea781ca use amf0 encode for json encode. 2015-08-28 15:11:11 +08:00
winlin
e0219bd7aa refine code, merge json encode to amf0. 2015-08-28 14:39:29 +08:00
winlin
66ffcad635 for #319, always allow raw query. 2015-08-28 13:17:46 +08:00
winlin
f167616379 rename the config_query to query 2015-08-28 13:01:04 +08:00
winlin
75ca759e5d fix the reload http api bug. 2015-08-28 12:38:09 +08:00
winlin
2dcf3bc606 for #319, support rpc raw api to query the HTTP RAW API configs. 2015-08-28 12:28:18 +08:00
winlin
af0a76e51a fix the build failed bug on centos 2015-08-28 00:03:10 +08:00
winlin
e03d8a0115 fix the build failed bug on centos 2015-08-28 00:01:19 +08:00
winlin
555a3fbf5f for #319, support render HTTP RAW API in console. 2015-08-27 23:55:59 +08:00
winlin
8e635d9749 for #319, support HTTP RAW API config_query global data. 2015-08-27 22:46:56 +08:00
winlin
d921d59e57 for #319, support HTTP RAW API reload. 2015-08-27 18:11:50 +08:00
winlin
f74dc62046 fix the process restart bug. 2015-08-26 23:20:19 +08:00
winlin
e39e006d63 fix the exec clear bug. 2015-08-26 23:11:42 +08:00
winlin
c081a5370b Merge branch '2.0release' into develop 2015-08-26 23:03:01 +08:00
winlin
1e0481a2d0 for #319, support signal to persistence config 2015-08-26 21:49:05 +08:00
winlin
980e3921e4 for #319, add signal to write config to file. 2015-08-26 21:11:28 +08:00
winlin
cdde293785 add todo for reload the source components. 2015-08-25 22:59:17 +08:00
winlin
53f4ce3604 for #367, update wiki to v3 2015-08-25 22:41:57 +08:00
winlin
c34b0c86e1 fix #367, support nginx-rtmp exec. 3.0.1 2015-08-25 22:29:00 +08:00
winlin
7de181004f Merge branch '2.0release' into develop 2015-08-25 11:55:44 +08:00
winlin
039af7243c for #367, refine the comments for process. 2015-08-24 22:26:19 +08:00
winlin
6fe88d088c for #367, process support redirect stdout and stderr. 2015-08-24 22:19:57 +08:00
winlin
0e1861b084 for #367: extract the process from ffmpeg to exec programs. 2015-08-24 21:51:05 +08:00
winlin
3a8c03a471 Merge branch '2.0release' into develop 2015-08-24 16:00:41 +08:00
winlin
a242aa35dc add pid to srs rtmp dump 2015-08-24 16:00:11 +08:00
winlin
2a4b448cce Merge branch '2.0release' into develop 2015-08-24 11:04:48 +08:00
winlin
d8030faabe Merge branch '2.0release' into develop 2015-08-24 10:59:39 +08:00
winlin
b25c45c643 refine srs player, support set the bufferTimeMax. 2015-08-24 07:55:30 +08:00
winlin
74d4c96423 for #367, design the config for exec. 2015-08-23 21:58:06 +08:00
winlin
cbfe438e73 for #367, design the config for exec. 2015-08-23 21:53:20 +08:00
winlin
5e48dab2b9 Merge branch '2.0release' into develop 2015-08-23 09:57:07 +08:00
winlin
ce1627eb34 Merge branch '2.0release' into develop 2015-08-23 09:55:46 +08:00
winlin
8d2b2d0148 Merge branch '2.0release' into develop 2015-08-23 09:39:23 +08:00
winlin
b4040a5fc9 Merge branch '2.0release' into develop 2015-08-23 09:11:38 +08:00
winlin
7e475e15b0 release 2.0a0 2015-08-23 09:00:57 +08:00
winlin
5721bc371c Merge branch '2.0release' into develop 2015-08-23 00:01:11 +08:00
winlin
7a2836ae2a Merge branch '2.0release' into develop 2015-08-22 19:49:39 +08:00
winlin
22485ce5e9 Merge branch '2.0release' into develop 2015-08-22 13:57:45 +08:00
winlin
1962449770 Merge branch '2.0release' into develop 2015-08-22 11:09:11 +08:00
winlin
0a4d78383c Merge branch '2.0release' into develop 2015-08-21 17:15:42 +08:00
winlin
32a484164a Merge branch '2.0release' into develop 2015-08-21 15:22:46 +08:00
winlin
9528243b81 Merge branch '2.0release' into develop 2015-08-21 13:43:40 +08:00
winlin
71aacebcbc Merge branch '2.0release' into develop 2015-08-21 12:08:35 +08:00
winlin
0afe4963bc Merge branch '2.0release' into develop 2015-08-20 18:33:47 +08:00
winlin
ce8f446494 Merge branch '2.0release' into develop 2015-08-20 18:13:17 +08:00
winlin
77765b463a Merge branch '2.0release' into develop 2015-08-20 14:20:58 +08:00
winlin
f10e399991 Merge branch '2.0release' into develop 2015-08-19 19:02:40 +08:00
winlin
a5dd3a8e7b Merge branch '2.0release' into develop 2015-08-19 15:14:35 +08:00
winlin
22491b0c99 merge from 2.0 2015-08-19 14:21:12 +08:00
winlin
0cb7ddfe8c Merge branch '2.0release' into develop 2015-08-18 14:09:05 +08:00
winlin
f53b2556bb Merge branch '2.0release' into develop 2015-08-17 16:34:21 +08:00
winlin
53351cd645 Merge branch '2.0release' into develop 2015-08-14 15:51:15 +08:00
winlin
0b90af7e46 Merge branch '2.0release' into develop 2015-08-14 15:47:36 +08:00
winlin
8d3d5dd10b Merge branch '2.0release' into develop 2015-08-14 14:35:47 +08:00
winlin
9fbff4b8f9 Merge branch '2.0release' into develop 2015-08-14 11:15:29 +08:00
winlin
807299589e merge from srs2. 2015-08-14 11:14:33 +08:00
winlin
a64340c2b5 Merge branch '2.0release' into develop 2015-08-13 21:58:08 +08:00
winlin
0b84c1d962 Merge branch '2.0release' into develop 2015-08-12 18:02:40 +08:00
winlin
653afd0700 merge from 2.0 2015-08-12 13:23:00 +08:00
winlin
b27bb48447 refine the version 2015-08-12 08:18:45 +08:00
winlin
5b34a4f975 Merge branch '2.0release' into develop 2015-08-12 08:17:10 +08:00
winlin
6a39bf4731 refine for srs3 2015-08-11 15:52:25 +08:00
500 changed files with 151576 additions and 50983 deletions

View file

@ -5,13 +5,13 @@ jobs:
- image: ossrs/srs:dev
steps:
- checkout
- run: cd trunk && ./configure && make
- run: cd trunk && ./configure --with-utest && make
test:
docker:
- image: ossrs/srs:dev
steps:
- checkout
- run: cd trunk && ./configure && make && ./objs/srs_utest
- run: cd trunk && ./configure --with-utest --gcov && make && ./objs/srs_utest && bash auto/coverage.sh
workflows:
version: 2
build_and_test:

34
.github/ISSUE_TEMPLATE vendored Normal file
View file

@ -0,0 +1,34 @@
---
name: File bug
about: File bug to improve SRS
title: ''
labels: ''
assignees: ''
---
**描述(Description)**
> 描述你遇到了什么问题(Please description your issue here)
1. SRS版本(Version): `xxxxxx`
1. SRS的日志如下(Log):
```
xxxxxxxxxxxx
```
1. SRS的配置如下(Config):
```
xxxxxxxxxxxx
```
**重现(Replay)**
> 重现Bug的步骤(How to replay bug?)
1. `xxxxxx`
1. `xxxxxx`
1. `xxxxxx`
**期望行为(Expect)**
> 描述你期望发生的事情(Please describe your expectation)

75
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,75 @@
name: "Release"
on:
push:
tags:
- v3*
jobs:
k8s:
name: actions-release-k8s
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
# The github.ref is, for example, refs/tags/v3.0.145 or refs/tags/v3.0-r8
# Generate variables like:
# SRS_TAG=v3.0.145
# SRS_TAG=v3.0-r8
# SRS_MAJOR=3
# @see https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Generate varaiables
shell: bash
run: |
SRS_TAG=$(echo ${{ github.ref }}| awk -F '/' '{print $3}')
echo "SRS_TAG=$SRS_TAG" >> $GITHUB_ENV
SRS_MAJOR=$(echo $SRS_TAG| cut -c 2)
echo "SRS_MAJOR=$SRS_MAJOR" >> $GITHUB_ENV
- name: Build SRS
shell: bash
run: |
echo "Release ossrs/srs:$SRS_TAG"
docker build --tag ossrs/srs:$SRS_TAG -f trunk/Dockerfile .
- name: Login docker hub
uses: docker/login-action@v1
with:
username: "${{ secrets.DOCKER_USERNAME }}"
password: "${{ secrets.DOCKER_PASSWORD }}"
- name: Push to docker hub
shell: bash
run: |
docker push ossrs/srs:$SRS_TAG
docker tag ossrs/srs:$SRS_TAG ossrs/srs:$SRS_MAJOR
docker push ossrs/srs:$SRS_MAJOR
- name: Login Aliyun docker hub
uses: aliyun/acr-login@v1
with:
login-server: https://registry.cn-hangzhou.aliyuncs.com
username: "${{ secrets.ACR_USERNAME }}"
password: "${{ secrets.ACR_PASSWORD }}"
- name: Push to Aliyun docker hub
shell: bash
run: |
docker tag ossrs/srs:$SRS_TAG registry.cn-hangzhou.aliyuncs.com/ossrs/srs:$SRS_TAG
docker push registry.cn-hangzhou.aliyuncs.com/ossrs/srs:$SRS_TAG
docker tag ossrs/srs:$SRS_TAG registry.cn-hangzhou.aliyuncs.com/ossrs/srs:$SRS_MAJOR
docker push registry.cn-hangzhou.aliyuncs.com/ossrs/srs:$SRS_MAJOR
- name: Setup KUBCONFIG for Aliyun ACK
shell: bash
run: |-
KUBECONFIG=$RUNNER_TEMP/kubeconfig_$(date +%s)
echo "${{ secrets.KUBCONFIG }}" > $KUBECONFIG
echo "KUBECONFIG=$KUBECONFIG" >> $GITHUB_ENV
- name: Release SRS 3.0 to Aliyun ACK
shell: bash
if: ${{ startsWith(github.ref, 'refs/tags/v3') }}
run: |-
kubectl set image deploy/srs3-deploy srs=registry.cn-hangzhou.aliyuncs.com/ossrs/srs:$SRS_TAG
kubectl describe deploy/srs3-deploy

47
.github/workflows/test.yml vendored Normal file
View file

@ -0,0 +1,47 @@
name: "Test"
on: [push, pull_request]
jobs:
utest:
name: actions-test-utest
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
################################################################
# Tests
- name: Build test image
run: docker build --tag srs:test -f trunk/Dockerfile.test .
# For utest
- name: Run SRS utest
run: docker run --rm srs:test bash -c 'make && ./objs/srs_utest'
coverage:
name: actions-test-coverage
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
################################################################
# Tests
- name: Build coverage image
run: docker build --tag srs:cov -f trunk/Dockerfile.cov .
# For coverage
- name: Run SRS covergae
if: ${{ startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/pull/') }}
run: |
# The hash of commit.
SRS_SHA=${{ github.sha }}
# Note that the root of SRS, must contains .git, for report fixing.
SRS_PROJECT=/srs
# The github.ref is, for example, refs/heads/3.0release
SRS_BRANCH=$(echo ${{ github.ref }}| awk -F 'refs/heads/' '{print $2}'| awk -F '/' '{print $1}')
# The github.ref is, for example, refs/pull/2536/merge
SRS_PR=$(echo ${{ github.ref }}| awk -F 'refs/pull/' '{print $2}'| awk -F '/' '{print $1}')
echo "For ref=${{ github.ref }}, sha=${{ github.sha }}, SRS_BRANCH=$SRS_BRANCH, SRS_PR=$SRS_PR, SRS_SHA=$SRS_SHA, SRS_PROJECT=$SRS_PROJECT"
docker run --rm --env SRS_BRANCH=$SRS_BRANCH --env SRS_PR=$SRS_PR --env SRS_SHA=$SRS_SHA --env SRS_PROJECT=$SRS_PROJECT \
srs:cov bash -c 'make && ./objs/srs_utest && bash auto/coverage.sh'

2
.gitignore vendored
View file

@ -15,13 +15,13 @@
# by winlin
*.pyc
*.swp
.DS_Store
/trunk/Makefile
/trunk/objs
/trunk/src/build-qt-Desktop-Debug
/trunk/research/librtmp/objs
/trunk/3rdparty/ccache/ccache-3.1.9
/trunk/3rdparty/gprof/graphviz-2.36.0
/trunk/research/api-server/static-dir/crossdomain.xml
/trunk/research/api-server/static-dir/forward
/trunk/research/api-server/static-dir/live
/trunk/research/api-server/static-dir/players

View file

@ -1,30 +1,57 @@
There are three types of people that have contributed to the SRS project:
1. AUTHORS: Contribute important features. Names of all PRIMARY response in NetConnection.connect and metadata.
2. CONTRIBUTORS: Submit patches, report bugs, add translations, help answer newbie questions, and generally make SRS that much better.
AUTHORS ordered by first contribution.
* winlin<winlin@vip.126.com> "Plan, arch, implement SRS1.0 and SRS2.0"
* wenjie.zhao<740936897@qq.com> "The bandwidth test module, HDS and bug fixed."
CONTRIBUTORS ordered by first contribution.
* xiangcheng.liu<liuxc0116@foxmail.com> "Bug fixed"
* naijia.liu<youngcow@youngcow.net> "Performance benchmark"
* alcoholyi<alcoholyi@qq.com> "Bug fixed"
* byteman<wangchen2011@gmail.com> "Bug fixed"
* chad.wang<chad.wang.cn@gmail.com> "Bug fixed"
* suhetao<suhetao@gmail.com> "Bug fixed"
* Johnny<fengjihu@163.com> "Create domain ossrs.net"
* karthikeyan<keyanmca@gmail.com> "Bug fixed"
* StevenLiu<lq@chinaffmpeg.org> "Build SRS on Darwin OSX"
* zhengfl<zhengfl_1989@126.com> "Bug fixed"
* tufang14<breadbean1449@gmail.com> "Bug fixed"
* allspace<allspace@gmail.com> "The srs-librtmp windows support"
* niesongsong<nie950@gmail.com> "Configure support relative path"
* rudeb0t<nimrod@themanxgroup.tw> "Bug fixed"
* CallMeNP<np.liamg@gmail.com> "Bug fixed"
* synote<synote@qq.com> "Bug fixed"
* lovecat<littlefawn@163.com> "Bug fixed"
* panda1986<542638787@qq.com> "Bug fixed"
* YueHonghui<hongf.yue@hotmail.com> "Bug fixed"
* JuntaoLiu<juntliu@gmail.com> "Bug fixed"
* winlin<winlin@vip.126.com>
* wenjie.zhao<740936897@qq.com>
* xiangcheng.liu<liuxc0116@foxmail.com>
* naijia.liu<youngcow@youngcow.net>
* alcoholyi<alcoholyi@qq.com>
* byteman<wangchen2011@gmail.com>
* chad.wang<chad.wang.cn@gmail.com>
* suhetao<suhetao@gmail.com>
* Johnny<fengjihu@163.com>
* karthikeyan<keyanmca@gmail.com>
* StevenLiu<lq@chinaffmpeg.org>
* zhengfl<zhengfl_1989@126.com>
* tufang14<breadbean1449@gmail.com>
* allspace<allspace@gmail.com>
* niesongsong<nie950@gmail.com>
* rudeb0t<nimrod@themanxgroup.tw>
* CallMeNP<np.liamg@gmail.com>
* synote<synote@qq.com>
* lovecat<littlefawn@163.com>
* panda1986<542638787@qq.com>
* YueHonghui<hongf.yue@hotmail.com>
* ThomasDreibholz<dreibh@simula.no>
* JuntaoLiu<juntliu@gmail.com>
* RocFang<fangpeng1986@gmail.com>
* MakarovYaroslav<yaroslav.makarov.97@mail.ru>
* MirkoVelic<mvelic@inoxx.net>
* HuiZhang(huzhang2)<huzhang2@cisco.com>
* OtterWa<simpleotter23@gmail.com>
* walkermi<172192667@qq.com>
* haofz<fuzhuang.hao@vhall.com>
* ME_Kun_Han<hanvskun@hotmail.com>
* ljx0305<ljx0305@gmail.com>
* cenxinwei<censhanhe@163.com>
* StarBrilliant<m13253@hotmail.com>
* xubin<xubin@chnvideo.com>
* intliang<yintiliang@gmail.com>
* flowerwrong<sysuyangkang@gmail.com>
* YLX<568414379@qq.com>
* J<guotaojiang@qq.com>
* Harlan<hailiang@gvrcraft.com>
* hankun<hankun@bravovcloud.com>
* JonathanBarratt<jonathan.barratt@gmail.com>
* KeeganH<keeganwharris@gmail.com>
* StevenLiu<lingjiujianke@gmail.com>
* liuxc0116<liuxc0116@gmail.com>
* ChengdongZhang<lmajzcd@sina.com>
* lovacat<lovecat@china.sina.com>
* qiang.li<qiang.li@verycdn.com.cn>
* HungMingWu<u9089000@gmail.com>
* Himer<xishizhaohua@qq.com>
* xialixin<xlx0625@163.com>
* alphonsetai<tyh_123@163.com>
* Michael.Ma<wnpllr@gmail.com>
* lam2003<linmin3@yy.com>
* l<22312935+lam2003@users.noreply.github.com>
* xfalcon<x-falcon@users.noreply.github.com>

View file

@ -1,46 +0,0 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at winlin@vip.126.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

View file

@ -1,3 +0,0 @@
First of all, thank you for considering contributing to SRS. It's people like you that make SRS a great live streaming cluster.
Pelease read https://github.com/activeadmin/activeadmin/blob/master/CONTRIBUTING.md

View file

@ -1,62 +0,0 @@
Donations ordered by first donation.
===========================================================
2015
RMB 10000+
* [2015-03-03 13:25] 郭强
RMB 1000-9999
* [2015-05-07 11:28] 冯彬
* [2015-04-29 09:20] 王光辉
* [2015-04-04 16:19] 蔡汉城
RMB 500-999
* [2015-04-11 12:48] 丁一
RMB 100-499
* [2015-05-07 23:56] 余世兵
* [2015-05-07 11:34] 王隆萼
* [2015-05-06 22:04] 姜庆东
* [2015-04-10 19:52] 阳成飞
* [2015-03-30 13:34] 扶凯
* [2015-03-29 11-07] 姚伟斌
* [2015-03-14 20:21] 万伟
* [2015-03-11 09:44] 叶发养
* [2015-02-08 21:10] 韩友洪
* [2015-01-09 16:08] 李理
RMB 50-99
* [2015-03-03 17:30] flybird
RMB 0.01-49
* [2015-05-07 11:34] 周鹤
===========================================================
2014
RMB 1000+
* [2014-04-25 13:21] 刘连响
* [2014-04-25 13:31] 郭强
* [2014-07-30 11:29] 周凯
* [2014-08-15 10:55] 雷健
RMB 500-999
* [2014-07-24 08:52] 黄英才
RMB 100-499
* [2014-04-25 13:25] 张瑞圣
* [2014-05-12 10:22] 陈晨
* [2014-08-07 22:56] 陈亮
* [2014-08-19 20:00] Matthew
* [2014-09-05 16:13] 于冰
* [2014-11-19 22:38] 夏江龙
RMB 50-99
* [2014-06-17 17:57] 陈江兵
* [2014-08-04 10:47] 宋志
* [2014-08-15 13:31] ZACH
RMB 0.01-49
* [2014-08-20 20:13] 林瑞潮

View file

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2013-2015 SRS(ossrs)
Copyright (c) 2013-2020 Winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in

1317
README.md

File diff suppressed because it is too large Load diff

31
trunk/.gitignore vendored
View file

@ -1,14 +1,19 @@
.idea/
/*.conf
/doc/frozen*
/doc/kungfupanda*
/doc/time*
/*.txt
/*.flv
/*.mp4
/doc/frozen*.flv
/doc/kungfupanda*.flv
/doc/time*.flv
/doc/source*.mp4
/html
/ide/srs_xcode/srs_xcode.xcodeproj/project.xcworkspace/xcshareddata/
/ide/srs_xcode/srs_xcode.xcodeproj/project.xcworkspace/xcuserdata/
/ide/srs_xcode/srs_xcode.xcodeproj/xcuserdata/
/research/aac/
/research/api-server/.idea/
/research/api-server/static-dir/mse
/research/api-server/static-dir/crossdomain.xml
/research/bat/
/research/big/
/research/bitch/
@ -16,17 +21,25 @@
/research/cgo/
/research/dns/
/research/empty/
/research/golang/
/research/librtmp/*.mp4
/research/golang/golang
/research/golang/temp.flv
/research/librtmp/720p.h264.raw
/research/librtmp/test.h264
/research/licenser/
/research/players/.idea/
/research/players/fls_player/
/research/players/mic/
/research/players/srs_player/.idea/
/research/proxy/
/research/redis-ocluster/
/research/rtmfp/
/research/snap/
/research/speex/
/test/
.DS_Store
srs
*.dSYM/
*.gcov
*.ts
*.h264
*.264
3rdparty/ffmpeg-4.2-fit
bug

Binary file not shown.

Binary file not shown.

View file

@ -1,17 +0,0 @@
#!/bin/bash
# check exists.
if [[ -d graphviz-2.18 ]]; then
echo "graphviz is ok";
exit 0;
fi
# check sudoer.
sudo echo "ok" > /dev/null 2>&1;
ret=$?; if [[ 0 -ne ${ret} ]]; then echo "you must be sudoer"; exit 1; fi
unzip -q graphviz-2.36.0.zip
cd graphviz-2.36.0 && ./configure && make && sudo make install
ret=$?; if [[ $ret -ne 0 ]]; then echo "build gprof2dot failed."; exit $ret; fi
echo "we test in Centos6.0, it's ok"

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -1,36 +1,4 @@
gprof图形化输出工具: gprof2dot.py graphviz-2.18.tar.gz build_gprof2dot.sh
dot:
http://www.graphviz.org/
http://www.graphviz.org/Download_source.php
graphviz-2.18.tar.gz 绘图工具
build_gprof2dot.sh 编译graphviz命令为dot。
要求是sudoer需要sudo make install。
gprof2dot.py:
将gprof的日志绘图。
使用方法:
0. 若需要图形化编译dot
cd 3rdparty/gprof && bash build_gprof2dot.sh
1. srs配置时:
./configure --with-gprof
脚本会加入编译参数"-pg -lc_p"gcc -g -pg -lc_p -c xxx -o xxx.o即在configure中打开 Performance="-pg -lc_p"
链接时,加入链接选项"-pg"否则无法工作gcc -pg -o srs xxxx.o即在configure中打开 PerformanceLink="-pg"
2. 编译和启动程序make && ./objs/srs -c conf/srs.conf
退出程序按CTRL+C可以看到生成了gmon.out这个就是性能的统计数据。
3. gprof生成报表
gprof -b ./objs/srs gmon.out > gprof.srs.log
4. 将报表生成图片:
./3rdparty/gprof/gprof2dot.py gprof.srs.log | dot -Tpng -o ~/winlin.png
为了压缩仓库尺寸gprof的文件不在新版本提供可以切换到2.0分支安装:
https://github.com/ossrs/srs/tree/2.0release/trunk/3rdparty/gprof
缩写语句:
# 生成 ~/winlin.log ~/winlin.png
rm -f gmon.out; ./objs/srs -c conf/srs.conf
# 用户按CTRL+C
file="winlin";gprof -b ./objs/srs gmon.out > ~/${file}.log; ./3rdparty/gprof/gprof2dot.py ~/${file}.log | dot -Tpng -o ~/${file}.png
备注:
其实gprof生成的日志就可以看不一定要图形化。
也就是dot和gprof2dot都不用执行。
参考http://www.cs.utah.edu/dept/old/texinfo/as/gprof.html

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
trunk/3rdparty/openssl-1.1.0e.zip vendored Normal file

Binary file not shown.

View file

@ -1,19 +0,0 @@
*** md.h Fri Oct 2 02:46:43 2009
--- ../st-1.9-patch/md.h Mon Mar 16 15:11:49 2015
***************
*** 422,428 ****
#define MD_STACK_GROWS_DOWN
#if defined(__GLIBC__) && __GLIBC__ >= 2
! #define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[20]
#else
#error "ARM/Linux pre-glibc2 not supported yet"
#endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */
--- 422,428 ----
#define MD_STACK_GROWS_DOWN
#if defined(__GLIBC__) && __GLIBC__ >= 2
! #define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[8]
#else
#error "ARM/Linux pre-glibc2 not supported yet"
#endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */

View file

@ -1,16 +0,0 @@
*** Makefile Wed Mar 27 06:35:20 2013
--- ../http-parser-2.1-patch/Makefile Mon Mar 16 15:25:59 2015
***************
*** 12,17 ****
--- 12,22 ----
CFLAGS_FAST = $(CFLAGS) -O3 $(CFLAGS_FAST_EXTRA)
CFLAGS_LIB = $(CFLAGS_FAST) -fPIC
+ # patch by winlin
+ CPPFLAGS_FAST = $(CPPFLAGS_DEBUG)
+ CFLAGS_FAST = $(CFLAGS_DEBUG)
+ CFLAGS_LIB = $(CFLAGS_FAST) -fPIC
+
test: test_g test_fast
./test_g
./test_fast

View file

@ -1,19 +0,0 @@
*** io.c Fri Oct 2 06:49:07 2009
--- ../st-1.9-patch/io.c Mon Mar 16 15:06:28 2015
***************
*** 89,94 ****
--- 89,102 ----
if (fdlim > 0 && rlim.rlim_max > (rlim_t) fdlim) {
rlim.rlim_max = fdlim;
}
+
+ /* when rlimit max is negative, for example, osx, use cur directly. */
+ /* @see https://github.com/winlinvip/simple-rtmp-server/issues/336 */
+ if ((int)rlim.rlim_max < 0) {
+ _st_osfd_limit = (int)(fdlim > 0? fdlim : rlim.rlim_cur);
+ return 0;
+ }
+
rlim.rlim_cur = rlim.rlim_max;
if (setrlimit(RLIMIT_NOFILE, &rlim) < 0)
return -1;

View file

@ -1,15 +0,0 @@
*** Makefile Fri Oct 2 06:55:03 2009
--- ../st-1.9-patch/Makefile Mon Mar 16 15:30:35 2015
***************
*** 310,315 ****
--- 310,319 ----
EXAMPLES =
endif
+ # disable examples for ubuntu crossbuild failed.
+ # @see https://github.com/winlinvip/simple-rtmp-server/issues/308
+ EXAMPLES =
+
ifeq ($(OS), DARWIN)
LINKNAME = libst.$(DSO_SUFFIX)
SONAME = libst.$(MAJOR).$(DSO_SUFFIX)

View file

@ -1,19 +0,0 @@
*** configure Sat Nov 30 05:45:08 2013
--- ../x264-snapshot-20131129-2245-stable-patch/configure Tue Mar 17 21:42:24 2015
***************
*** 466,472 ****
;;
darwin*)
SYS="MACOSX"
! CFLAGS="$CFLAGS -falign-loops=16"
libm="-lm"
if [ "$pic" = "no" ]; then
cc_check "" -mdynamic-no-pic && CFLAGS="$CFLAGS -mdynamic-no-pic"
--- 466,472 ----
;;
darwin*)
SYS="MACOSX"
! CFLAGS="$CFLAGS"
libm="-lm"
if [ "$pic" = "no" ]; then
cc_check "" -mdynamic-no-pic && CFLAGS="$CFLAGS -mdynamic-no-pic"

View file

@ -1,13 +0,0 @@
--- Makefile 2018-10-28 13:49:27.000000000 +0800
+++ ../st-1.9-patch/Makefile 2018-10-28 13:50:07.000000000 +0800
@@ -139,8 +139,8 @@ CFLAGS += -arch ppc
LDFLAGS += -arch ppc
endif
ifeq ($(INTEL), yes)
-CFLAGS += -arch i386 -arch x86_64
-LDFLAGS += -arch i386 -arch x86_64
+CFLAGS += -arch x86_64
+LDFLAGS += -arch x86_64
endif
LDFLAGS += -dynamiclib -install_name /sw/lib/libst.$(MAJOR).$(DSO_SUFFIX) -compatibility_version $(MAJOR) -current_version $(VERSION)
OTHER_FLAGS = -Wall

View file

@ -1,12 +0,0 @@
--- Makefile 2019-04-05 19:43:32.000000000 +0800
+++ ../http-parser-2.1-patch/Makefile 2019-04-05 19:50:26.000000000 +0800
@@ -7,7 +7,8 @@ CPPFLAGS_DEBUG += $(CPPFLAGS_DEBUG_EXTRA
CPPFLAGS_FAST = $(CPPFLAGS) -DHTTP_PARSER_STRICT=0
CPPFLAGS_FAST += $(CPPFLAGS_FAST_EXTRA)
-CFLAGS += -Wall -Wextra -Werror
+# patch by winlin
+CFLAGS += -Wall -Wextra
CFLAGS_DEBUG = $(CFLAGS) -O0 -g $(CFLAGS_DEBUG_EXTRA)
CFLAGS_FAST = $(CFLAGS) -O3 $(CFLAGS_FAST_EXTRA)
CFLAGS_LIB = $(CFLAGS_FAST) -fPIC

View file

@ -7,13 +7,13 @@ nginx-1.5.7.zip
st-1.9.zip
basic framework for srs.
openssl-1.0.1f.zip
openssl-1.1.0e.zip
openssl for SRS(with-ssl) RTMP complex handshake to delivery h264+aac stream.
CherryPy-3.2.4.zip
sample api server for srs.
ffmpeg-2.1.1.tar.gz
ffmpeg-3.2.4.tar.gz
yasm-1.2.0.tar.gz
lame-3.99.5.tar.gz
speex-1.2rc1.zip
@ -27,15 +27,14 @@ fdk-aac-0.1.3.zip
tools/ccache-3.1.9.zip
to fast build.
1.st.arm.Makefile.patch
st编译脚本补丁允许用户指定cc编译器。
gtest-1.6.0.zip
google单元测试框架。
google test framework.
gperftools-2.1.zip
google性能分析和测试工具。
编译和使用参考压缩文件中的README和doc目录。
gperf tools for performance benchmark.
state-threads-1.9.1.tar.gz:
patched st from https://github.com/ossrs/state-threads/releases/tag/v1.9.1
links:
nginx:
@ -46,7 +45,7 @@ links:
http://sourceforge.net/projects/state-threads
ffmpeg:
http://ffmpeg.org/
http://ffmpeg.org/releases/ffmpeg-2.1.1.tar.gz
http://ffmpeg.org/releases/ffmpeg-3.2.4.tar.gz
x264:
http://www.videolan.org/
ftp://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20131129-2245-stable.tar.bz2
@ -61,7 +60,7 @@ links:
https://pypi.python.org/pypi/CherryPy/3.2.4
openssl:
http://www.openssl.org/
http://www.openssl.org/source/openssl-1.0.1f.tar.gz
http://www.openssl.org/source/openssl-1.1.0e.tar.gz
gtest:
https://code.google.com/p/googletest
https://code.google.com/p/googletest/downloads/list

Binary file not shown.

Binary file not shown.

4
trunk/3rdparty/st-srs/.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
DARWIN_*_DBG
LINUX_*_DBG
obj
st.pc

480
trunk/3rdparty/st-srs/Makefile vendored Normal file
View file

@ -0,0 +1,480 @@
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Netscape Portable Runtime library.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1994-2000 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Silicon Graphics, Inc.
#
# Portions created by SGI are Copyright (C) 2000-2001 Silicon
# Graphics, Inc. All Rights Reserved.
#
# Alternatively, the contents of this file may be used under the
# terms of the GNU General Public License Version 2 or later (the
# "GPL"), in which case the provisions of the GPL are applicable
# instead of those above. If you wish to allow use of your
# version of this file only under the terms of the GPL and not to
# allow others to use your version of this file under the MPL,
# indicate your decision by deleting the provisions above and
# replace them with the notice and other provisions required by
# the GPL. If you do not delete the provisions above, a recipient
# may use your version of this file under either the MPL or the
# GPL.
# This is the full version of the libst library - modify carefully
VERSION = 1.9
##########################
# Supported OSes:
#
#OS = AIX
#OS = CYGWIN
#OS = DARWIN
#OS = FREEBSD
#OS = HPUX
#OS = HPUX_64
#OS = IRIX
#OS = IRIX_64
#OS = LINUX
#OS = NETBSD
#OS = OPENBSD
#OS = OSF1
#OS = SOLARIS
#OS = SOLARIS_64
# Please see the "Other possible defines" section below for
# possible compilation options.
##########################
CC = cc
AR = ar
LD = ld
RANLIB = ranlib
LN = ln
SHELL = /bin/sh
ECHO = /bin/echo
BUILD = DBG
TARGETDIR = $(OS)_$(shell uname -r)_$(BUILD)
DEFINES = -D$(OS)
CFLAGS =
SFLAGS =
ARFLAGS = -rv
LNFLAGS = -s
DSO_SUFFIX = so
MAJOR = $(shell echo $(VERSION) | sed 's/^\([^\.]*\).*/\1/')
DESC = st.pc
##########################
# Platform section.
# Possible targets:
TARGETS = aix-debug aix-optimized \
cygwin-debug cygwin-optimized \
darwin-debug darwin-optimized \
freebsd-debug freebsd-optimized \
hpux-debug hpux-optimized \
hpux-64-debug hpux-64-optimized \
irix-n32-debug irix-n32-optimized \
irix-64-debug irix-64-optimized \
linux-debug linux-optimized \
netbsd-debug netbsd-optimized \
openbsd-debug openbsd-optimized \
osf1-debug osf1-optimized \
solaris-debug solaris-optimized \
solaris-64-debug solaris-64-optimized
#
# Platform specifics
#
ifeq ($(OS), AIX)
AIX_VERSION = $(shell uname -v).$(shell uname -r)
TARGETDIR = $(OS)_$(AIX_VERSION)_$(BUILD)
CC = xlC
STATIC_ONLY = yes
ifeq ($(BUILD), OPT)
OTHER_FLAGS = -w
endif
ifneq ($(filter-out 4.1 4.2, $(AIX_VERSION)),)
DEFINES += -DMD_HAVE_SOCKLEN_T
endif
endif
ifeq ($(OS), CYGWIN)
TARGETDIR = $(OS)_$(BUILD)
CC = gcc
LD = gcc
DSO_SUFFIX = dll
SLIBRARY = $(TARGETDIR)/libst.dll.a
DLIBRARY = $(TARGETDIR)/libst.dll
DEF_FILE = $(TARGETDIR)/libst.def
LDFLAGS = libst.def -shared --enable-auto-image-base -Wl,--output-def,$(DEF_FILE),--out-implib,$(SLIBRARY)
OTHER_FLAGS = -Wall
endif
ifeq ($(OS), DARWIN)
EXTRA_OBJS = $(TARGETDIR)/md_darwin.o
LD = cc
SFLAGS = -fPIC -fno-common
DSO_SUFFIX = dylib
RELEASE = $(shell uname -r | cut -d. -f1)
PPC = $(shell test $(RELEASE) -le 9 && echo yes)
INTEL = $(shell test $(RELEASE) -ge 9 && echo yes)
ifeq ($(PPC), yes)
CFLAGS += -arch ppc
LDFLAGS += -arch ppc
endif
ifeq ($(INTEL), yes)
CFLAGS += -arch x86_64
LDFLAGS += -arch x86_64
endif
LDFLAGS += -dynamiclib -install_name /sw/lib/libst.$(MAJOR).$(DSO_SUFFIX) -compatibility_version $(MAJOR) -current_version $(VERSION)
OTHER_FLAGS = -Wall
endif
ifeq ($(OS), FREEBSD)
SFLAGS = -fPIC
LDFLAGS = -shared -soname=$(SONAME) -lc
OTHER_FLAGS = -Wall
ifeq ($(shell test -f /usr/include/sys/event.h && echo yes), yes)
DEFINES += -DMD_HAVE_KQUEUE
endif
endif
ifeq (HPUX, $(findstring HPUX, $(OS)))
ifeq ($(OS), HPUX_64)
DEFINES = -DHPUX
CFLAGS = -Ae +DD64 +Z
else
CFLAGS = -Ae +DAportable +Z
endif
RANLIB = true
LDFLAGS = -b
DSO_SUFFIX = sl
endif
ifeq (IRIX, $(findstring IRIX, $(OS)))
ifeq ($(OS), IRIX_64)
DEFINES = -DIRIX
ABIFLAG = -64
else
ABIFLAG = -n32
endif
RANLIB = true
CFLAGS = $(ABIFLAG) -mips3
LDFLAGS = $(ABIFLAG) -shared
OTHER_FLAGS = -fullwarn
endif
ifeq ($(OS), LINUX)
EXTRA_OBJS = $(TARGETDIR)/md.o
SFLAGS = -fPIC
LDFLAGS = -shared -soname=$(SONAME) -lc
OTHER_FLAGS = -Wall
ifeq ($(shell test -f /usr/include/sys/epoll.h && echo yes), yes)
DEFINES += -DMD_HAVE_EPOLL
endif
endif
ifeq ($(OS), NETBSD)
SFLAGS = -fPIC
LDFLAGS = -shared -soname=$(SONAME) -lc
OTHER_FLAGS = -Wall
endif
ifeq ($(OS), OPENBSD)
SFLAGS = -fPIC
LDFLAGS = -shared -soname=$(SONAME) -lc
OTHER_FLAGS = -Wall
ifeq ($(shell test -f /usr/include/sys/event.h && echo yes), yes)
DEFINES += -DMD_HAVE_KQUEUE
endif
endif
ifeq ($(OS), OSF1)
RANLIB = true
LDFLAGS = -shared -all -expect_unresolved "*"
endif
ifeq (SOLARIS, $(findstring SOLARIS, $(OS)))
TARGETDIR = $(OS)_$(shell uname -r | sed 's/^5/2/')_$(BUILD)
CC = gcc
LD = gcc
RANLIB = true
LDFLAGS = -G
OTHER_FLAGS = -Wall
ifeq ($(OS), SOLARIS_64)
DEFINES = -DSOLARIS
CFLAGS += -m64
LDFLAGS += -m64
endif
endif
#
# End of platform section.
##########################
ifeq ($(BUILD), OPT)
OTHER_FLAGS += -O
else
OTHER_FLAGS += -g
DEFINES += -DDEBUG
endif
##########################
# Other possible defines:
# To use poll(2) instead of select(2) for events checking:
# DEFINES += -DUSE_POLL
# You may prefer to use select for applications that have many threads
# using one file descriptor, and poll for applications that have many
# different file descriptors. With USE_POLL poll() is called with at
# least one pollfd per I/O-blocked thread, so 1000 threads sharing one
# descriptor will poll 1000 identical pollfds and select would be more
# efficient. But if the threads all use different descriptors poll()
# may be better depending on your operating system's implementation of
# poll and select. Really, it's up to you. Oh, and on some platforms
# poll() fails with more than a few dozen descriptors.
#
# Some platforms allow to define FD_SETSIZE (if select() is used), e.g.:
# DEFINES += -DFD_SETSIZE=4096
#
# To use malloc(3) instead of mmap(2) for stack allocation:
# DEFINES += -DMALLOC_STACK
#
# To provision more than the default 16 thread-specific-data keys
# (but not too many!):
# DEFINES += -DST_KEYS_MAX=<n>
#
# To start with more than the default 64 initial pollfd slots
# (but the table grows dynamically anyway):
# DEFINES += -DST_MIN_POLLFDS_SIZE=<n>
#
# Note that you can also add these defines by specifying them as
# make/gmake arguments (without editing this Makefile). For example:
#
# make EXTRA_CFLAGS=-DUSE_POLL <target>
#
# (replace make with gmake if needed).
#
# You can also modify the default selection of an alternative event
# notification mechanism. E.g., to enable kqueue(2) support (if it's not
# enabled by default):
#
# gmake EXTRA_CFLAGS=-DMD_HAVE_KQUEUE <target>
#
# or to disable default epoll(4) support:
#
# make EXTRA_CFLAGS=-UMD_HAVE_EPOLL <target>
#
##########################
CFLAGS += $(DEFINES) $(OTHER_FLAGS) $(EXTRA_CFLAGS)
OBJS = $(TARGETDIR)/sched.o \
$(TARGETDIR)/stk.o \
$(TARGETDIR)/sync.o \
$(TARGETDIR)/key.o \
$(TARGETDIR)/io.o \
$(TARGETDIR)/event.o
OBJS += $(EXTRA_OBJS)
HEADER = $(TARGETDIR)/st.h
SLIBRARY = $(TARGETDIR)/libst.a
DLIBRARY = $(TARGETDIR)/libst.$(DSO_SUFFIX).$(VERSION)
EXAMPLES = examples
LINKNAME = libst.$(DSO_SUFFIX)
SONAME = libst.$(DSO_SUFFIX).$(MAJOR)
FULLNAME = libst.$(DSO_SUFFIX).$(VERSION)
ifeq ($(OS), CYGWIN)
SONAME = cygst.$(DSO_SUFFIX)
SLIBRARY = $(TARGETDIR)/libst.dll.a
DLIBRARY = $(TARGETDIR)/$(SONAME)
LINKNAME =
# examples directory does not compile under cygwin
EXAMPLES =
endif
# for SRS
# disable examples for ubuntu crossbuild failed.
# @see https://github.com/winlinvip/simple-rtmp-server/issues/308
ifeq ($(OS), LINUX)
EXAMPLES =
endif
ifeq ($(OS), DARWIN)
LINKNAME = libst.$(DSO_SUFFIX)
SONAME = libst.$(MAJOR).$(DSO_SUFFIX)
FULLNAME = libst.$(VERSION).$(DSO_SUFFIX)
endif
ifeq ($(STATIC_ONLY), yes)
LIBRARIES = $(SLIBRARY)
else
LIBRARIES = $(SLIBRARY) $(DLIBRARY)
endif
ifeq ($(OS),)
ST_ALL = unknown
else
ST_ALL = $(TARGETDIR) $(LIBRARIES) $(HEADER) $(EXAMPLES) $(DESC)
endif
all: $(ST_ALL)
unknown:
@echo
@echo "Please specify one of the following targets:"
@echo
@for target in $(TARGETS); do echo $$target; done
@echo
st.pc: st.pc.in
sed "s/@VERSION@/${VERSION}/g" < $< > $@
$(TARGETDIR):
if [ ! -d $(TARGETDIR) ]; then mkdir $(TARGETDIR); fi
$(SLIBRARY): $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
$(RANLIB) $@
rm -f obj; $(LN) $(LNFLAGS) $(TARGETDIR) obj
$(DLIBRARY): $(OBJS:%.o=%-pic.o)
$(LD) $(LDFLAGS) $^ -o $@
if test "$(LINKNAME)"; then \
cd $(TARGETDIR); \
rm -f $(SONAME) $(LINKNAME); \
$(LN) $(LNFLAGS) $(FULLNAME) $(SONAME); \
$(LN) $(LNFLAGS) $(FULLNAME) $(LINKNAME); \
fi
$(HEADER): public.h
rm -f $@
cp public.h $@
$(TARGETDIR)/md.o: md.S
$(CC) $(CFLAGS) -c $< -o $@
$(TARGETDIR)/md_darwin.o: md_darwin.S
$(CC) $(CFLAGS) -c $< -o $@
$(TARGETDIR)/%.o: %.c common.h md.h
$(CC) $(CFLAGS) -c $< -o $@
examples: $(SLIBRARY)
@echo Making $@
@cd $@; $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" OS="$(OS)" TARGETDIR="$(TARGETDIR)"
clean:
rm -rf *_OPT *_DBG obj st.pc
##########################
# Pattern rules:
ifneq ($(SFLAGS),)
# Compile with shared library options if it's a C file
$(TARGETDIR)/%-pic.o: %.c common.h md.h
$(CC) $(CFLAGS) $(SFLAGS) -c $< -o $@
endif
# Compile assembly as normal or C as normal if no SFLAGS
%-pic.o: %.o
rm -f $@; $(LN) $(LNFLAGS) $(<F) $@
##########################
# Target rules:
default-debug:
. ./osguess.sh; $(MAKE) OS="$$OS" BUILD="DBG"
default default-optimized:
. ./osguess.sh; $(MAKE) OS="$$OS" BUILD="OPT"
aix-debug:
$(MAKE) OS="AIX" BUILD="DBG"
aix-optimized:
$(MAKE) OS="AIX" BUILD="OPT"
cygwin-debug:
$(MAKE) OS="CYGWIN" BUILD="DBG"
cygwin-optimized:
$(MAKE) OS="CYGWIN" BUILD="OPT"
darwin-debug:
$(MAKE) OS="DARWIN" BUILD="DBG"
darwin-optimized:
$(MAKE) OS="DARWIN" BUILD="OPT"
freebsd-debug:
$(MAKE) OS="FREEBSD" BUILD="DBG"
freebsd-optimized:
$(MAKE) OS="FREEBSD" BUILD="OPT"
hpux-debug:
$(MAKE) OS="HPUX" BUILD="DBG"
hpux-optimized:
$(MAKE) OS="HPUX" BUILD="OPT"
hpux-64-debug:
$(MAKE) OS="HPUX_64" BUILD="DBG"
hpux-64-optimized:
$(MAKE) OS="HPUX_64" BUILD="OPT"
irix-n32-debug:
$(MAKE) OS="IRIX" BUILD="DBG"
irix-n32-optimized:
$(MAKE) OS="IRIX" BUILD="OPT"
irix-64-debug:
$(MAKE) OS="IRIX_64" BUILD="DBG"
irix-64-optimized:
$(MAKE) OS="IRIX_64" BUILD="OPT"
linux-debug:
$(MAKE) OS="LINUX" BUILD="DBG"
linux-optimized:
$(MAKE) OS="LINUX" BUILD="OPT"
# compatibility
linux-ia64-debug: linux-debug
linux-ia64-optimized: linux-optimized
netbsd-debug:
$(MAKE) OS="NETBSD" BUILD="DBG"
netbsd-optimized:
$(MAKE) OS="NETBSD" BUILD="OPT"
openbsd-debug:
$(MAKE) OS="OPENBSD" BUILD="DBG"
openbsd-optimized:
$(MAKE) OS="OPENBSD" BUILD="OPT"
osf1-debug:
$(MAKE) OS="OSF1" BUILD="DBG"
osf1-optimized:
$(MAKE) OS="OSF1" BUILD="OPT"
solaris-debug:
$(MAKE) OS="SOLARIS" BUILD="DBG"
solaris-optimized:
$(MAKE) OS="SOLARIS" BUILD="OPT"
solaris-64-debug:
$(MAKE) OS="SOLARIS_64" BUILD="DBG"
solaris-64-optimized:
$(MAKE) OS="SOLARIS_64" BUILD="OPT"
##########################

394
trunk/3rdparty/st-srs/README vendored Normal file
View file

@ -0,0 +1,394 @@
WELCOME!
The State Threads Library is a small application library which provides
a foundation for writing fast and highly scalable Internet applications
(such as web servers, proxy servers, mail transfer agents, and so on,
really any network-data-driven application) on UNIX-like platforms. It
combines the simplicity of the multithreaded programming paradigm, in
which one thread supports each simultaneous connection, with the
performance and scalability of an event-driven state machine
architecture. In other words, this library offers a threading API for
structuring an Internet application as a state machine. For more
details, please see the library documentation in the "docs" directory or
on-line at
http://state-threads.sourceforge.net/docs/
The State Threads Project is an open source project for maintaining and
enhancing the State Threads Library. For more information about this
project, please see
http://state-threads.sourceforge.net/
BUILDING
To build the library by hand, use the GNU make utility. Run the make
command (e.g., `gmake') with no arguments to display all supported
targets.
To build more or less automatically, first set the CONFIG_GUESS_PATH
variable in either osguess.sh or your environment then run "make
default" which guesses your OS and builds. Requires the "config.guess"
utility from GNU autoconf (not included with ST). You can use one from
a larger "main" software project or just use any config.guess available
on your system. You can also get it directly from GNU:
ftp://ftp.gnu.org/gnu/autoconf/
To build rpms (RedHat Linux 6.2 or later, Linux/Mandrake, Solaris with
gnome, etc.):
download the latest st-x.y.tar.gz
# rpm -ta st-x.y.tar.gz
The .rpms will land in /usr/src/RPMS/<arch>. Install them with:
# rpm -i libst*.rpm
Requires GNU automake and rpm 3.0.3 or later.
Debian users:
If you run potato, please upgrade to woody.
If you run woody, "apt-get install libst-dev" will get you v1.3.
If you run testing/unstable, you will get the newest available version.
If you *must* have the newest libst in woody, you may follow these
not-recommended instructions:
1. Add "deb-src <your-favourite-debian-mirror> unstable main" to your
/etc/apt/sources.list
2. apt-get update
3. apt-get source st
4. cd st-1.4 (or whatever version you got)
5. debuild
6. dpkg -i ../*.deb
If your application uses autoconf to search for dependencies and you
want to search for a given version of libst, you can simply add
PKG_CHECK_MODULES(MYAPP, st >= 1.3 mumble >= 0.2.23)
to your configure.ac/in. This will define @MYAPP_LIBS@ and
@MYAPP_CFLAGS@ which you may then use in your Makefile.am/in files to
link against mumble and st.
LICENSE
The State Threads library is a derivative of the Netscape Portable
Runtime library (NSPR). All source code in this directory is
distributed under the terms of the Mozilla Public License (MPL) version
1.1 or the GNU General Public License (GPL) version 2 or later. For
more information about these licenses please see
http://www.mozilla.org/MPL/ and http://www.gnu.org/copyleft/.
All source code in the "examples" directory is distributed under the BSD
style license.
PLATFORMS
Please see the "docs/notes.html" file for the list of currently
supported platforms.
DEBUGGER SUPPORT
It's almost impossible to print SP and PC in a portable way. The only
way to see thread's stack platform-independently is to actually jump to
the saved context. That's what the _st_iterate_threads() function does.
Do the following to iterate over all threads:
- set the _st_iterate_threads_flag to 1 in debugger
- set breakpoint at the _st_show_thread_stack() function
(which does nothing)
- call the _st_iterate_threads() function which jumps to the
next thread
- at each break you can explore thread's stack
- continue
- when iteration is complete, you return to the original
point (you can see thread id and a message as arguments of
the _st_show_thread_stack() function).
You can call _st_iterate_threads() in three ways:
- Insert it into your source code at the point you want to
go over threads.
- Just run application and this function will be called at
the first context switch.
- Call it directly from the debugger at any point.
This works with gdb and dbx.
Example using gdb:
(gdb) set _st_iterate_threads_flag = 1
(gdb) b _st_show_thread_stack
...
(gdb) call _st_iterate_threads()
...
(gdb) bt
...
(gdb) c
...
(gdb) bt
...
(gdb) c
...
and so on...
_st_iterate_threads_flag will be set to 0 automatically
after iteration is over or you can set it to 0 at any time
to stop iteration.
Sometimes gdb complains about SIGSEGV when you call a function
directly at gdb command-line. It can be ignored -- just call the
same function right away again, it works just fine. For example:
(gdb) set _st_iterate_threads_flag = 1
(gdb) b _st_show_thread_stack
Breakpoint 1 at 0x809bbbb: file sched.c, line 856.
(gdb) call _st_iterate_threads()
Program received signal SIGSEGV, Segmentation fault.
....
(gdb) # just call the function again:
(gdb) call _st_iterate_threads()
Breakpoint 1, _st_show_thread_stack (thread=0x4017aee4, messg=0x80ae7a2
"Iteration started") at sched.c:856
856 }
....
You can use simple gdb command-line scripting to display
all threads and their stack traces at once:
(gdb) while _st_iterate_threads_flag
>bt
>c
>end
....
Another script to stop at the thread with the specific thread id
(e.g., 0x40252ee4):
(gdb) # set the flag again:
(gdb) set _st_iterate_threads_flag = 1
(gdb) call _st_iterate_threads()
Breakpoint 1, _st_show_thread_stack (thread=0x4017aee4, messg=0x80ae7a2
"Iteration started") at sched.c:856
856 }
....
(gdb) while thread != 0x40252ee4
>c
>end
....
....
Breakpoint 1, _st_show_thread_stack (thread=0x40252ee4, messg=0x0) at
sched.c:856
856 }
(gdb) bt
....
(gdb) # don't want to continue iteration, unset the flag:
(gdb) set _st_iterate_threads_flag = 0
(gdb) c
Continuing.
Breakpoint 1, _st_show_thread_stack (thread=0x0, messg=0x80ae78e "Iteration
completed")
at sched.c:856
856 }
(gdb) c
Continuing.
(gdb) return
Make selected stack frame return now? (y or n) y
#0 0x4011254e in __select ()
from /lib/libc.so.6
(gdb) detach
CHANGE LOG
Changes from 1.8 to 1.9.
------------------------
o Support 32-bit and 64-bit Intel Macs.
o Added ST_VERSION string, and ST_VERSION_MAJOR and ST_VERSION_MINOR
[bug 1796801].
o Fixed some compiler warnings, based on a patch from Brian Wellington
[bug 1932741].
Changes from 1.7 to 1.8.
--------------------------
o Added support for kqueue and epoll on platforms that support them.
Added ability to choose the event notification system at program
startup.
o Long-overdue public definitions of ST_UTIME_NO_TIMEOUT (-1ULL) and
ST_UTIME_NO_WAIT (0) [bug 1514436].
o Documentation patch for st_utime() [bug 1514484].
o Documentation patch for st_timecache_set() [bug 1514486].
o Documentation patch for st_netfd_serialize_accept() [bug 1514494].
o Added st_writev_resid() [rfe 1538344].
o Added st_readv_resid() [rfe 1538768] and, for symmetry, st_readv().
Changes from 1.6 to 1.7.
------------------------
o Support glibc 2.4, which breaks programs that manipulate jump buffers.
Replaced Linux IA64 special cases with new md.S that covers all
Linux.
Changes from 1.5.2 to 1.6.
--------------------------
none
Changes from 1.5.1 to 1.5.2.
----------------------------
o Alfred Perlstein's context switch callback feature.
o Claus Assmann's st_recvmsg/st_sendmsg wrappers.
o Extra stack padding for platforms that need it.
o Ron Arts's timeout clarifications in the reference manual.
o Raymond Bero and Anton Berezin's AMD64 FreeBSD port.
o Claus Assmann's AMD64 SunOS 5.10 port.
o Claus Assmann's AMD64 OpenBSD port.
o Michael Abd-El-Malek's Mac OS X port.
o Michael Abd-El-Malek's stack printing patch.
Changes from 1.5.0 to 1.5.1.
----------------------------
o Andreas Gustafsson's USE_POLL fix.
o Gene's st_set_utime_function() enhancement.
Changes from 1.4 to 1.5.0.
--------------------------
o Andreas Gustafsson's performance patch.
o New extensions: Improved DNS resolver, generic LRU cache, in-process
DNS cache, and a program to test the resolver and cache.
o Support for AMD Opteron 64-bit CPUs under Linux.
o Support for SPARC-64 under Solaris.
o Andreas Gustafsson's support for VAX under NetBSD.
o Changed unportable #warning directives in md.h to #error.
Changes from 1.3 to 1.4.
------------------------
o Andreas Gustafsson's NetBSD port.
o Wesley W. Terpstra's Darwin (MacOS X) port.
o Support for many CPU architectures under Linux and *BSD.
o Renamed private typedefs so they don't conflict with public ones any
more.
o common.h now includes public.h for strict prototyping.
o Joshua Levy's recommendation to make st_connect() and st_sendto()
accept const struct sockaddr pointers, as the originals do.
o Clarified the documentation regarding blocking vs. non-blocking I/O.
o Cygwin support.
o Created the extensions directory.
o Fixed warnings from ia64asm.S.
Changes from 1.2 to 1.3.
------------------------
o Added st_read_resid() and st_write_resid() to allow the caller to know
how much data was transferred before an error occurred. Updated
documentation.
o Updated project link, copyrights, and documentation regarding
timeouts. Added comment to st_connect().
o Optimized the _st_add_sleep_q() function in sched.c. Now we walk the
sleep queue *backward* when inserting a thread into it. When you
have lots (hundreds) of threads and several timeout values, it takes
a while to insert a thread at the appropriate point in the sleep
queue. The idea is that often this appropriate point is closer to
the end of the queue rather than the beginning. Measurements show
performance improves with this change. In any case this change
should do no harm.
o Added a hint of when to define USE_POLL and when not to, to the
Makefile.
o Added debugging support (files common.h and sched.c). See above.
o Decreased the number of reallocations of _ST_POLLFDS in sched.c.
Inspired by Lev Walkin.
o Fixed st_usleep(-1) and st_sleep(-1), and added a warning to the
documentation about too-large timeouts.
o Linux/*BSD Alpha port.
o Wesley W. Terpstra modernized the build process:
- properly build relocatable libraries under bsd and linux
- use library versioning
- added rpm spec file
- added debian/ files
See above for build instructions.
Changes from 1.1 to 1.2.
------------------------
o Added st_randomize_stacks().
o Added a patch contributed by Sascha Schumann.
Changes from 1.0 to 1.1.
------------------------
o Relicensed under dual MPL-GPL.
o OpenBSD port.
o Compile-time option to use poll() instead of select() for
event polling (see Makefile).
This is useful if you want to support a large number of open
file descriptors (larger than FD_SETSIZE) within a single
process.
o Linux IA-64 port.
Two issues make IA-64 different from other platforms:
- Besides the traditional call stack in memory, IA-64 uses the
general register stack. Thus each thread needs a backing store
for the register stack in addition to the memory stack.
- Current implementation of setjmp()/longjmp() can not be used
for thread context-switching since it assumes that only one
register stack exists. Using special assembly functions for
context-switching is unavoidable.
o Thread stack capping on IRIX.
This allows some profiling tools (such as SpeedShop) to know when
to stop unwinding the stack. Without this libexc, used by SpeedShop,
traces right off the stack and crashes.
o Miscellaneous documentation additions.
COPYRIGHTS
Portions created by SGI are Copyright (C) 2000 Silicon Graphics, Inc.
All Rights Reserved.

88
trunk/3rdparty/st-srs/README.md vendored Normal file
View file

@ -0,0 +1,88 @@
# state-threads
![](http://ossrs.net:8000/gif/v1/sls.gif?site=github.com&path=/srs/srsst)
[![](https://cloud.githubusercontent.com/assets/2777660/22814959/c51cbe72-ef92-11e6-81cc-32b657b285d5.png)](https://github.com/ossrs/srs/wiki/v1_CN_Contact#wechat)
Fork from http://sourceforge.net/projects/state-threads, patched for [SRS](https://github.com/ossrs/srs/tree/2.0release).
> See: https://github.com/ossrs/state-threads/blob/srs/README
For original ST without any changes, checkout the [ST master branch](https://github.com/ossrs/state-threads/tree/master).
## Branch SRS
The branch [srs](https://github.com/ossrs/state-threads/tree/srs) will be patched the following patches:
- [x] Patch [st.arm.patch](https://github.com/ossrs/srs/blob/2.0release/trunk/3rdparty/patches/1.st.arm.patch), for ARM.
- [x] Patch [st.osx.kqueue.patch](https://github.com/ossrs/srs/blob/2.0release/trunk/3rdparty/patches/3.st.osx.kqueue.patch), for osx.
- [x] Patch [st.disable.examples.patch](https://github.com/ossrs/srs/blob/2.0release/trunk/3rdparty/patches/4.st.disable.examples.patch), for ubuntu.
- [x] [Refine TAB of code](https://github.com/ossrs/state-threads/compare/c2001d30ca58f55d72a6cc6b9b6c70391eaf14db...d2101b26988b0e0db0aabc53ddf452068c1e2cbc).
- [x] Merge from [michaeltalyansky](https://github.com/michaeltalyansky/state-threads) and [xzh3836598](https://github.com/ossrs/state-threads/commit/9a17dec8f9c2814d93761665df7c5575a4d2d8a3), support [ARM](https://github.com/ossrs/state-threads/issues/1).
- [x] Merge from [toffaletti](https://github.com/toffaletti/state-threads), support [valgrind](https://github.com/ossrs/state-threads/issues/2) for ST.
- [x] Patch [st.osx10.14.build.patch](https://github.com/ossrs/srs/blob/2.0release/trunk/3rdparty/patches/6.st.osx10.14.build.patch), for osx 10.14 build.
- [x] Support macro `MD_ST_NO_ASM` to disable ASM, [#8](https://github.com/ossrs/state-threads/issues/8).
- [x] Merge patch [srs#1282](https://github.com/ossrs/srs/issues/1282#issuecomment-445539513) to support aarch64, [#9](https://github.com/ossrs/state-threads/issues/9).
## Docs
* Introduction: http://ossrs.github.io/state-threads/docs/st.html
* API reference: http://ossrs.github.io/state-threads/docs/reference.html
* Programming notes: http://ossrs.github.io/state-threads/docs/notes.html
## Usage
Get code:
```
git clone https://github.com/ossrs/state-threads.git st-1.9 &&
git checkout -b srs origin/srs
```
For Linux:
```
make linux-debug EXTRA_CFLAGS="-DMD_HAVE_EPOLL"
```
For OSX:
```
make darwin-debug EXTRA_CFLAGS="-DMD_HAVE_KQUEUE"
```
Linux with valgrind:
```
make linux-debug EXTRA_CFLAGS="-DMD_VALGRIND"
```
> Remark: User must install valgrind, for instance, in centos6 `sudo yum install -y valgrind valgrind-devel`.
Linux with valgrind and epoll:
```
make linux-debug EXTRA_CFLAGS="-DMD_HAVE_EPOLL -DMD_VALGRIND"
```
For OSX, user must specifies the valgrind header files:
```
make darwin-debug EXTRA_CFLAGS="-DMD_HAVE_KQUEUE -DMD_VALGRIND -I/usr/local/include"
```
> Remark: Latest OSX does not support ST, please use docker to run ST.
## Valgrind
How to debug with gdb under valgrind, read [valgrind manual](http://valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.gdbserver-simple).
About startup parameters, read [valgrind cli](http://valgrind.org/docs/manual/mc-manual.html#mc-manual.options).
Important cli options:
1. `--undef-value-errors=<yes|no> [default: yes]`, Controls whether Memcheck reports uses of undefined value errors. Set this to no if you don't want to see undefined value errors. It also has the side effect of speeding up Memcheck somewhat.
1. `--leak-check=<no|summary|yes|full> [default: summary]`, When enabled, search for memory leaks when the client program finishes. If set to summary, it says how many leaks occurred. If set to full or yes, each individual leak will be shown in detail and/or counted as an error, as specified by the options `--show-leak-kinds` and `--errors-for-leak-kinds`.
1. `--track-origins=<yes|no> [default: no]`, Controls whether Memcheck tracks the origin of uninitialised values. By default, it does not, which means that although it can tell you that an uninitialised value is being used in a dangerous way, it cannot tell you where the uninitialised value came from. This often makes it difficult to track down the root problem.
1. `--show-reachable=<yes|no> , --show-possibly-lost=<yes|no>`, to show the using memory.
Winlin 2016

479
trunk/3rdparty/st-srs/common.h vendored Normal file
View file

@ -0,0 +1,479 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Netscape Portable Runtime library.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1994-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s): Silicon Graphics, Inc.
*
* Portions created by SGI are Copyright (C) 2000-2001 Silicon
* Graphics, Inc. All Rights Reserved.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 or later (the
* "GPL"), in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your
* version of this file only under the terms of the GPL and not to
* allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
/*
* This file is derived directly from Netscape Communications Corporation,
* and consists of extensive modifications made during the year(s) 1999-2000.
*/
#ifndef __ST_COMMON_H__
#define __ST_COMMON_H__
#include <stddef.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
#include <setjmp.h>
/* Enable assertions only if DEBUG is defined */
#ifndef DEBUG
#define NDEBUG
#endif
#include <assert.h>
#define ST_ASSERT(expr) assert(expr)
#define ST_BEGIN_MACRO {
#define ST_END_MACRO }
#ifdef DEBUG
#define ST_HIDDEN /*nothing*/
#else
#define ST_HIDDEN static
#endif
#include "public.h"
#include "md.h"
/* merge from https://github.com/toffaletti/state-threads/commit/7f57fc9acc05e657bca1223f1e5b9b1a45ed929b */
#ifndef MD_VALGRIND
#ifndef NVALGRIND
#define NVALGRIND
#endif
#else
#undef NVALGRIND
#endif
/*****************************************
* Circular linked list definitions
*/
typedef struct _st_clist {
struct _st_clist *next;
struct _st_clist *prev;
} _st_clist_t;
/* Insert element "_e" into the list, before "_l" */
#define ST_INSERT_BEFORE(_e,_l) \
ST_BEGIN_MACRO \
(_e)->next = (_l); \
(_e)->prev = (_l)->prev; \
(_l)->prev->next = (_e); \
(_l)->prev = (_e); \
ST_END_MACRO
/* Insert element "_e" into the list, after "_l" */
#define ST_INSERT_AFTER(_e,_l) \
ST_BEGIN_MACRO \
(_e)->next = (_l)->next; \
(_e)->prev = (_l); \
(_l)->next->prev = (_e); \
(_l)->next = (_e); \
ST_END_MACRO
/* Return the element following element "_e" */
#define ST_NEXT_LINK(_e) ((_e)->next)
/* Append an element "_e" to the end of the list "_l" */
#define ST_APPEND_LINK(_e,_l) ST_INSERT_BEFORE(_e,_l)
/* Insert an element "_e" at the head of the list "_l" */
#define ST_INSERT_LINK(_e,_l) ST_INSERT_AFTER(_e,_l)
/* Return the head/tail of the list */
#define ST_LIST_HEAD(_l) (_l)->next
#define ST_LIST_TAIL(_l) (_l)->prev
/* Remove the element "_e" from it's circular list */
#define ST_REMOVE_LINK(_e) \
ST_BEGIN_MACRO \
(_e)->prev->next = (_e)->next; \
(_e)->next->prev = (_e)->prev; \
ST_END_MACRO
/* Return non-zero if the given circular list "_l" is empty, */
/* zero if the circular list is not empty */
#define ST_CLIST_IS_EMPTY(_l) \
((_l)->next == (_l))
/* Initialize a circular list */
#define ST_INIT_CLIST(_l) \
ST_BEGIN_MACRO \
(_l)->next = (_l); \
(_l)->prev = (_l); \
ST_END_MACRO
#define ST_INIT_STATIC_CLIST(_l) \
{(_l), (_l)}
/*****************************************
* Basic types definitions
*/
typedef void (*_st_destructor_t)(void *);
typedef struct _st_stack {
_st_clist_t links;
char *vaddr; /* Base of stack's allocated memory */
int vaddr_size; /* Size of stack's allocated memory */
int stk_size; /* Size of usable portion of the stack */
char *stk_bottom; /* Lowest address of stack's usable portion */
char *stk_top; /* Highest address of stack's usable portion */
void *sp; /* Stack pointer from C's point of view */
#ifdef __ia64__
void *bsp; /* Register stack backing store pointer */
#endif
/* merge from https://github.com/toffaletti/state-threads/commit/7f57fc9acc05e657bca1223f1e5b9b1a45ed929b */
#ifndef NVALGRIND
/* id returned by VALGRIND_STACK_REGISTER */
/* http://valgrind.org/docs/manual/manual-core-adv.html */
unsigned long valgrind_stack_id;
#endif
} _st_stack_t;
typedef struct _st_cond {
_st_clist_t wait_q; /* Condition variable wait queue */
} _st_cond_t;
typedef struct _st_thread _st_thread_t;
struct _st_thread {
int state; /* Thread's state */
int flags; /* Thread's flags */
void *(*start)(void *arg); /* The start function of the thread */
void *arg; /* Argument of the start function */
void *retval; /* Return value of the start function */
_st_stack_t *stack; /* Info about thread's stack */
_st_clist_t links; /* For putting on run/sleep/zombie queue */
_st_clist_t wait_links; /* For putting on mutex/condvar wait queue */
#ifdef DEBUG
_st_clist_t tlink; /* For putting on thread queue */
#endif
st_utime_t due; /* Wakeup time when thread is sleeping */
_st_thread_t *left; /* For putting in timeout heap */
_st_thread_t *right; /* -- see docs/timeout_heap.txt for details */
int heap_index;
void **private_data; /* Per thread private data */
_st_cond_t *term; /* Termination condition variable for join */
jmp_buf context; /* Thread's context */
};
typedef struct _st_mutex {
_st_thread_t *owner; /* Current mutex owner */
_st_clist_t wait_q; /* Mutex wait queue */
} _st_mutex_t;
typedef struct _st_pollq {
_st_clist_t links; /* For putting on io queue */
_st_thread_t *thread; /* Polling thread */
struct pollfd *pds; /* Array of poll descriptors */
int npds; /* Length of the array */
int on_ioq; /* Is it on ioq? */
} _st_pollq_t;
typedef struct _st_eventsys_ops {
const char *name; /* Name of this event system */
int val; /* Type of this event system */
int (*init)(void); /* Initialization */
void (*dispatch)(void); /* Dispatch function */
int (*pollset_add)(struct pollfd *, int); /* Add descriptor set */
void (*pollset_del)(struct pollfd *, int); /* Delete descriptor set */
int (*fd_new)(int); /* New descriptor allocated */
int (*fd_close)(int); /* Descriptor closed */
int (*fd_getlimit)(void); /* Descriptor hard limit */
} _st_eventsys_t;
typedef struct _st_vp {
_st_thread_t *idle_thread; /* Idle thread for this vp */
st_utime_t last_clock; /* The last time we went into vp_check_clock() */
_st_clist_t run_q; /* run queue for this vp */
_st_clist_t io_q; /* io queue for this vp */
_st_clist_t zombie_q; /* zombie queue for this vp */
#ifdef DEBUG
_st_clist_t thread_q; /* all threads of this vp */
#endif
int pagesize;
_st_thread_t *sleep_q; /* sleep queue for this vp */
int sleepq_size; /* number of threads on sleep queue */
#ifdef ST_SWITCH_CB
st_switch_cb_t switch_out_cb; /* called when a thread is switched out */
st_switch_cb_t switch_in_cb; /* called when a thread is switched in */
#endif
} _st_vp_t;
typedef struct _st_netfd {
int osfd; /* Underlying OS file descriptor */
int inuse; /* In-use flag */
void *private_data; /* Per descriptor private data */
_st_destructor_t destructor; /* Private data destructor function */
void *aux_data; /* Auxiliary data for internal use */
struct _st_netfd *next; /* For putting on the free list */
} _st_netfd_t;
/*****************************************
* Current vp, thread, and event system
*/
extern _st_vp_t _st_this_vp;
extern _st_thread_t *_st_this_thread;
extern _st_eventsys_t *_st_eventsys;
#define _ST_CURRENT_THREAD() (_st_this_thread)
#define _ST_SET_CURRENT_THREAD(_thread) (_st_this_thread = (_thread))
#define _ST_LAST_CLOCK (_st_this_vp.last_clock)
#define _ST_RUNQ (_st_this_vp.run_q)
#define _ST_IOQ (_st_this_vp.io_q)
#define _ST_ZOMBIEQ (_st_this_vp.zombie_q)
#ifdef DEBUG
#define _ST_THREADQ (_st_this_vp.thread_q)
#endif
#define _ST_PAGE_SIZE (_st_this_vp.pagesize)
#define _ST_SLEEPQ (_st_this_vp.sleep_q)
#define _ST_SLEEPQ_SIZE (_st_this_vp.sleepq_size)
#define _ST_VP_IDLE() (*_st_eventsys->dispatch)()
/*****************************************
* vp queues operations
*/
#define _ST_ADD_IOQ(_pq) ST_APPEND_LINK(&_pq.links, &_ST_IOQ)
#define _ST_DEL_IOQ(_pq) ST_REMOVE_LINK(&_pq.links)
#define _ST_ADD_RUNQ(_thr) ST_APPEND_LINK(&(_thr)->links, &_ST_RUNQ)
#define _ST_DEL_RUNQ(_thr) ST_REMOVE_LINK(&(_thr)->links)
#define _ST_ADD_SLEEPQ(_thr, _timeout) _st_add_sleep_q(_thr, _timeout)
#define _ST_DEL_SLEEPQ(_thr) _st_del_sleep_q(_thr)
#define _ST_ADD_ZOMBIEQ(_thr) ST_APPEND_LINK(&(_thr)->links, &_ST_ZOMBIEQ)
#define _ST_DEL_ZOMBIEQ(_thr) ST_REMOVE_LINK(&(_thr)->links)
#ifdef DEBUG
#define _ST_ADD_THREADQ(_thr) ST_APPEND_LINK(&(_thr)->tlink, &_ST_THREADQ)
#define _ST_DEL_THREADQ(_thr) ST_REMOVE_LINK(&(_thr)->tlink)
#endif
/*****************************************
* Thread states and flags
*/
#define _ST_ST_RUNNING 0
#define _ST_ST_RUNNABLE 1
#define _ST_ST_IO_WAIT 2
#define _ST_ST_LOCK_WAIT 3
#define _ST_ST_COND_WAIT 4
#define _ST_ST_SLEEPING 5
#define _ST_ST_ZOMBIE 6
#define _ST_ST_SUSPENDED 7
#define _ST_FL_PRIMORDIAL 0x01
#define _ST_FL_IDLE_THREAD 0x02
#define _ST_FL_ON_SLEEPQ 0x04
#define _ST_FL_INTERRUPT 0x08
#define _ST_FL_TIMEDOUT 0x10
/*****************************************
* Pointer conversion
*/
#ifndef offsetof
#define offsetof(type, identifier) ((size_t)&(((type *)0)->identifier))
#endif
#define _ST_THREAD_PTR(_qp) \
((_st_thread_t *)((char *)(_qp) - offsetof(_st_thread_t, links)))
#define _ST_THREAD_WAITQ_PTR(_qp) \
((_st_thread_t *)((char *)(_qp) - offsetof(_st_thread_t, wait_links)))
#define _ST_THREAD_STACK_PTR(_qp) \
((_st_stack_t *)((char*)(_qp) - offsetof(_st_stack_t, links)))
#define _ST_POLLQUEUE_PTR(_qp) \
((_st_pollq_t *)((char *)(_qp) - offsetof(_st_pollq_t, links)))
#ifdef DEBUG
#define _ST_THREAD_THREADQ_PTR(_qp) \
((_st_thread_t *)((char *)(_qp) - offsetof(_st_thread_t, tlink)))
#endif
/*****************************************
* Constants
*/
#ifndef ST_UTIME_NO_TIMEOUT
#define ST_UTIME_NO_TIMEOUT ((st_utime_t) -1LL)
#endif
#ifndef __ia64__
#define ST_DEFAULT_STACK_SIZE (64*1024)
#else
#define ST_DEFAULT_STACK_SIZE (128*1024) /* Includes register stack size */
#endif
#ifndef ST_KEYS_MAX
#define ST_KEYS_MAX 16
#endif
#ifndef ST_MIN_POLLFDS_SIZE
#define ST_MIN_POLLFDS_SIZE 64
#endif
/*****************************************
* Threads context switching
*/
#ifdef DEBUG
void _st_iterate_threads(void);
#define ST_DEBUG_ITERATE_THREADS() _st_iterate_threads()
#else
#define ST_DEBUG_ITERATE_THREADS()
#endif
#ifdef ST_SWITCH_CB
#define ST_SWITCH_OUT_CB(_thread) \
if (_st_this_vp.switch_out_cb != NULL && \
_thread != _st_this_vp.idle_thread && \
_thread->state != _ST_ST_ZOMBIE) { \
_st_this_vp.switch_out_cb(); \
}
#define ST_SWITCH_IN_CB(_thread) \
if (_st_this_vp.switch_in_cb != NULL && \
_thread != _st_this_vp.idle_thread && \
_thread->state != _ST_ST_ZOMBIE) { \
_st_this_vp.switch_in_cb(); \
}
#else
#define ST_SWITCH_OUT_CB(_thread)
#define ST_SWITCH_IN_CB(_thread)
#endif
/*
* Switch away from the current thread context by saving its state and
* calling the thread scheduler
*/
#define _ST_SWITCH_CONTEXT(_thread) \
ST_BEGIN_MACRO \
ST_SWITCH_OUT_CB(_thread); \
if (!MD_SETJMP((_thread)->context)) { \
_st_vp_schedule(); \
} \
ST_DEBUG_ITERATE_THREADS(); \
ST_SWITCH_IN_CB(_thread); \
ST_END_MACRO
/*
* Restore a thread context that was saved by _ST_SWITCH_CONTEXT or
* initialized by _ST_INIT_CONTEXT
*/
#define _ST_RESTORE_CONTEXT(_thread) \
ST_BEGIN_MACRO \
_ST_SET_CURRENT_THREAD(_thread); \
MD_LONGJMP((_thread)->context, 1); \
ST_END_MACRO
/*
* Initialize the thread context preparing it to execute _main
*/
#ifdef MD_INIT_CONTEXT
#define _ST_INIT_CONTEXT MD_INIT_CONTEXT
#else
#error Unknown OS
#endif
/*
* Number of bytes reserved under the stack "bottom"
*/
#define _ST_STACK_PAD_SIZE MD_STACK_PAD_SIZE
/*****************************************
* Forward declarations
*/
void _st_vp_schedule(void);
void _st_vp_check_clock(void);
void *_st_idle_thread_start(void *arg);
void _st_thread_main(void);
void _st_thread_cleanup(_st_thread_t *thread);
void _st_add_sleep_q(_st_thread_t *thread, st_utime_t timeout);
void _st_del_sleep_q(_st_thread_t *thread);
_st_stack_t *_st_stack_new(int stack_size);
void _st_stack_free(_st_stack_t *ts);
int _st_io_init(void);
st_utime_t st_utime(void);
_st_cond_t *st_cond_new(void);
int st_cond_destroy(_st_cond_t *cvar);
int st_cond_timedwait(_st_cond_t *cvar, st_utime_t timeout);
int st_cond_signal(_st_cond_t *cvar);
ssize_t st_read(_st_netfd_t *fd, void *buf, size_t nbyte, st_utime_t timeout);
ssize_t st_write(_st_netfd_t *fd, const void *buf, size_t nbyte, st_utime_t timeout);
int st_poll(struct pollfd *pds, int npds, st_utime_t timeout);
_st_thread_t *st_thread_create(void *(*start)(void *arg), void *arg, int joinable, int stk_size);
#endif /* !__ST_COMMON_H__ */

BIN
trunk/3rdparty/st-srs/docs/fig.gif vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

434
trunk/3rdparty/st-srs/docs/notes.html vendored Normal file
View file

@ -0,0 +1,434 @@
<HTML>
<HEAD>
<TITLE>State Threads Library Programming Notes</TITLE>
</HEAD>
<BODY BGCOLOR=#FFFFFF>
<H2>Programming Notes</H2>
<P>
<B>
<UL>
<LI><A HREF=#porting>Porting</A></LI>
<LI><A HREF=#signals>Signals</A></LI>
<LI><A HREF=#intra>Intra-Process Synchronization</A></LI>
<LI><A HREF=#inter>Inter-Process Synchronization</A></LI>
<LI><A HREF=#nonnet>Non-Network I/O</A></LI>
<LI><A HREF=#timeouts>Timeouts</A></LI>
</UL>
</B>
<P>
<HR>
<P>
<A NAME="porting">
<H3>Porting</H3>
The State Threads library uses OS concepts that are available in some
form on most UNIX platforms, making the library very portable across
many flavors of UNIX. However, there are several parts of the library
that rely on platform-specific features. Here is the list of such parts:
<P>
<UL>
<LI><I>Thread context initialization</I>: Two ingredients of the
<TT>jmp_buf</TT>
data structure (the program counter and the stack pointer) have to be
manually set in the thread creation routine. The <TT>jmp_buf</TT> data
structure is defined in the <TT>setjmp.h</TT> header file and differs from
platform to platform. Usually the program counter is a structure member
with <TT>PC</TT> in the name and the stack pointer is a structure member
with <TT>SP</TT> in the name. One can also look in the
<A HREF="http://www.mozilla.org/source.html">Netscape's NSPR library source</A>
which already has this code for many UNIX-like platforms
(<TT>mozilla/nsprpub/pr/include/md/*.h</TT> files).
<P>
Note that on some BSD-derived platforms <TT>_setjmp(3)/_longjmp(3)</TT>
calls should be used instead of <TT>setjmp(3)/longjmp(3)</TT> (that is
the calls that manipulate only the stack and registers and do <I>not</I>
save and restore the process's signal mask).</LI>
<P>
Starting with glibc 2.4 on Linux the opacity of the <TT>jmp_buf</TT> data
structure is enforced by <TT>setjmp(3)/longjmp(3)</TT> so the
<TT>jmp_buf</TT> ingredients cannot be accessed directly anymore (unless
special environmental variable LD_POINTER_GUARD is set before application
execution). To avoid dependency on custom environment, the State Threads
library provides <TT>setjmp/longjmp</TT> replacement functions for
all Intel CPU architectures. Other CPU architectures can also be easily
supported (the <TT>setjmp/longjmp</TT> source code is widely available for
many CPU architectures).
<P>
<LI><I>High resolution time function</I>: Some platforms (IRIX, Solaris)
provide a high resolution time function based on the free running hardware
counter. This function returns the time counted since some arbitrary
moment in the past (usually machine power up time). It is not correlated in
any way to the time of day, and thus is not subject to resetting,
drifting, etc. This type of time is ideal for tasks where cheap, accurate
interval timing is required. If such a function is not available on a
particular platform, the <TT>gettimeofday(3)</TT> function can be used
(though on some platforms it involves a system call).
<P>
<LI><I>The stack growth direction</I>: The library needs to know whether the
stack grows toward lower (down) or higher (up) memory addresses.
One can write a simple test program that detects the stack growth direction
on a particular platform.</LI>
<P>
<LI><I>Non-blocking attribute inheritance</I>: On some platforms (e.g. IRIX)
the socket created as a result of the <TT>accept(2)</TT> call inherits the
non-blocking attribute of the listening socket. One needs to consult the manual
pages or write a simple test program to see if this applies to a specific
platform.</LI>
<P>
<LI><I>Anonymous memory mapping</I>: The library allocates memory segments
for thread stacks by doing anonymous memory mapping (<TT>mmap(2)</TT>). This
mapping is somewhat different on SVR4 and BSD4.3 derived platforms.
<P>
The memory mapping can be avoided altogether by using <TT>malloc(3)</TT> for
stack allocation. In this case the <TT>MALLOC_STACK</TT> macro should be
defined.</LI>
</UL>
<P>
All machine-dependent feature test macros should be defined in the
<TT>md.h</TT> header file. The assembly code for <TT>setjmp/longjmp</TT>
replacement functions for all CPU architectures should be placed in
the <TT>md.S</TT> file.
<P>
The current version of the library is ported to:
<UL>
<LI>IRIX 6.x (both 32 and 64 bit)</LI>
<LI>Linux (kernel 2.x and glibc 2.x) on x86, Alpha, MIPS and MIPSEL,
SPARC, ARM, PowerPC, 68k, HPPA, S390, IA-64, and Opteron (AMD-64)</LI>
<LI>Solaris 2.x (SunOS 5.x) on x86, AMD64, SPARC, and SPARC-64</LI>
<LI>AIX 4.x</LI>
<LI>HP-UX 11 (both 32 and 64 bit)</LI>
<LI>Tru64/OSF1</LI>
<LI>FreeBSD on x86, AMD64, and Alpha</LI>
<LI>OpenBSD on x86, AMD64, Alpha, and SPARC</LI>
<LI>NetBSD on x86, Alpha, SPARC, and VAX</LI>
<LI>MacOS X (Darwin) on PowerPC (32 bit) and Intel (both 32 and 64 bit) [universal]</LI>
<LI>Cygwin</LI>
</UL>
<P>
<A NAME="signals">
<H3>Signals</H3>
Signal handling in an application using State Threads should be treated the
same way as in a classical UNIX process application. There is no such
thing as per-thread signal mask, all threads share the same signal handlers,
and only asynchronous-safe functions can be used in signal handlers.
However, there is a way to process signals synchronously by converting a
signal event to an I/O event: a signal catching function does a write to
a pipe which will be processed synchronously by a dedicated signal handling
thread. The following code demonstrates this technique (error handling is
omitted for clarity):
<PRE>
/* Per-process pipe which is used as a signal queue. */
/* Up to PIPE_BUF/sizeof(int) signals can be queued up. */
int sig_pipe[2];
/* Signal catching function. */
/* Converts signal event to I/O event. */
void sig_catcher(int signo)
{
int err;
/* Save errno to restore it after the write() */
err = errno;
/* write() is reentrant/async-safe */
write(sig_pipe[1], &signo, sizeof(int));
errno = err;
}
/* Signal processing function. */
/* This is the "main" function of the signal processing thread. */
void *sig_process(void *arg)
{
st_netfd_t nfd;
int signo;
nfd = st_netfd_open(sig_pipe[0]);
for ( ; ; ) {
/* Read the next signal from the pipe */
st_read(nfd, &signo, sizeof(int), ST_UTIME_NO_TIMEOUT);
/* Process signal synchronously */
switch (signo) {
case SIGHUP:
/* do something here - reread config files, etc. */
break;
case SIGTERM:
/* do something here - cleanup, etc. */
break;
/* .
.
Other signals
.
.
*/
}
}
return NULL;
}
int main(int argc, char *argv[])
{
struct sigaction sa;
.
.
.
/* Create signal pipe */
pipe(sig_pipe);
/* Create signal processing thread */
st_thread_create(sig_process, NULL, 0, 0);
/* Install sig_catcher() as a signal handler */
sa.sa_handler = sig_catcher;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sigaction(SIGHUP, &sa, NULL);
sa.sa_handler = sig_catcher;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sigaction(SIGTERM, &sa, NULL);
.
.
.
}
</PRE>
<P>
Note that if multiple processes are used (see below), the signal pipe should
be initialized after the <TT>fork(2)</TT> call so that each process has its
own private pipe.
<P>
<A NAME="intra">
<H3>Intra-Process Synchronization</H3>
Due to the event-driven nature of the library scheduler, the thread context
switch (process state change) can only happen in a well-known set of
library functions. This set includes functions in which a thread may
"block":<TT> </TT>I/O functions (<TT>st_read(), st_write(), </TT>etc.),
sleep functions (<TT>st_sleep(), </TT>etc.), and thread synchronization
functions (<TT>st_thread_join(), st_cond_wait(), </TT>etc.). As a result,
process-specific global data need not to be protected by locks since a thread
cannot be rescheduled while in a critical section (and only one thread at a
time can access the same memory location). By the same token,
non thread-safe functions (in a traditional sense) can be safely used with
the State Threads. The library's mutex facilities are practically useless
for a correctly written application (no blocking functions in critical
section) and are provided mostly for completeness. This absence of locking
greatly simplifies an application design and provides a foundation for
scalability.
<P>
<A NAME="inter">
<H3>Inter-Process Synchronization</H3>
The State Threads library makes it possible to multiplex a large number
of simultaneous connections onto a much smaller number of separate
processes, where each process uses a many-to-one user-level threading
implementation (<B>N</B> of <B>M:1</B> mappings rather than one <B>M:N</B>
mapping used in native threading libraries on some platforms). This design
is key to the application's scalability. One can think about it as if a
set of all threads is partitioned into separate groups (processes) where
each group has a separate pool of resources (virtual address space, file
descriptors, etc.). An application designer has full control of how many
groups (processes) an application creates and what resources, if any,
are shared among different groups via standard UNIX inter-process
communication (IPC) facilities.<P>
There are several reasons for creating multiple processes:
<P>
<UL>
<LI>To take advantage of multiple hardware entities (CPUs, disks, etc.)
available in the system (hardware parallelism).</LI>
<P>
<LI>To reduce risk of losing a large number of user connections when one of
the processes crashes. For example, if <B>C</B> user connections (threads)
are multiplexed onto <B>P</B> processes and one of the processes crashes,
only a fraction (<B>C/P</B>) of all connections will be lost.</LI>
<P>
<LI>To overcome per-process resource limitations imposed by the OS. For
example, if <TT>select(2)</TT> is used for event polling, the number of
simultaneous connections (threads) per process is
limited by the <TT>FD_SETSIZE</TT> parameter (see <TT>select(2)</TT>).
If <TT>FD_SETSIZE</TT> is equal to 1024 and each connection needs one file
descriptor, then an application should create 10 processes to support 10,000
simultaneous connections.</LI>
</UL>
<P>
Ideally all user sessions are completely independent, so there is no need for
inter-process communication. It is always better to have several separate
smaller process-specific resources (e.g., data caches) than to have one large
resource shared (and modified) by all processes. Sometimes, however, there
is a need to share a common resource among different processes. In that case,
standard UNIX IPC facilities can be used. In addition to that, there is a way
to synchronize different processes so that only the thread accessing the
shared resource will be suspended (but not the entire process) if that resource
is unavailable. In the following code fragment a pipe is used as a counting
semaphore for inter-process synchronization:
<PRE>
#ifndef PIPE_BUF
#define PIPE_BUF 512 /* POSIX */
#endif
/* Semaphore data structure */
typedef struct ipc_sem {
st_netfd_t rdfd; /* read descriptor */
st_netfd_t wrfd; /* write descriptor */
} ipc_sem_t;
/* Create and initialize the semaphore. Should be called before fork(2). */
/* 'value' must be less than PIPE_BUF. */
/* If 'value' is 1, the semaphore works as mutex. */
ipc_sem_t *ipc_sem_create(int value)
{
ipc_sem_t *sem;
int p[2];
char b[PIPE_BUF];
/* Error checking is omitted for clarity */
sem = malloc(sizeof(ipc_sem_t));
/* Create the pipe */
pipe(p);
sem->rdfd = st_netfd_open(p[0]);
sem->wrfd = st_netfd_open(p[1]);
/* Initialize the semaphore: put 'value' bytes into the pipe */
write(p[1], b, value);
return sem;
}
/* Try to decrement the "value" of the semaphore. */
/* If "value" is 0, the calling thread blocks on the semaphore. */
int ipc_sem_wait(ipc_sem_t *sem)
{
char c;
/* Read one byte from the pipe */
if (st_read(sem->rdfd, &c, 1, ST_UTIME_NO_TIMEOUT) != 1)
return -1;
return 0;
}
/* Increment the "value" of the semaphore. */
int ipc_sem_post(ipc_sem_t *sem)
{
char c;
if (st_write(sem->wrfd, &c, 1, ST_UTIME_NO_TIMEOUT) != 1)
return -1;
return 0;
}
</PRE>
<P>
Generally, the following steps should be followed when writing an application
using the State Threads library:
<P>
<OL>
<LI>Initialize the library (<TT>st_init()</TT>).</LI>
<P>
<LI>Create resources that will be shared among different processes:
create and bind listening sockets, create shared memory segments, IPC
channels, synchronization primitives, etc.</LI>
<P>
<LI>Create several processes (<TT>fork(2)</TT>). The parent process should
either exit or become a "watchdog" (e.g., it starts a new process when
an existing one crashes, does a cleanup upon application termination,
etc.).</LI>
<P>
<LI>In each child process create a pool of threads
(<TT>st_thread_create()</TT>) to handle user connections.</LI>
</OL>
<P>
<A NAME="nonnet">
<H3>Non-Network I/O</H3>
The State Threads architecture uses non-blocking I/O on
<TT>st_netfd_t</TT> objects for concurrent processing of multiple user
connections. This architecture has a drawback: the entire process and
all its threads may block for the duration of a <I>disk</I> or other
non-network I/O operation, whether through State Threads I/O functions,
direct system calls, or standard I/O functions. (This is applicable
mostly to disk <I>reads</I>; disk <I>writes</I> are usually performed
asynchronously -- data goes to the buffer cache to be written to disk
later.) Fortunately, disk I/O (unlike network I/O) usually takes a
finite and predictable amount of time, but this may not be true for
special devices or user input devices (including stdin). Nevertheless,
such I/O reduces throughput of the system and increases response times.
There are several ways to design an application to overcome this
drawback:
<P>
<UL>
<LI>Create several identical main processes as described above (symmetric
architecture). This will improve CPU utilization and thus improve the
overall throughput of the system.</LI>
<P>
<LI>Create multiple "helper" processes in addition to the main process that
will handle blocking I/O operations (asymmetric architecture).
This approach was suggested for Web servers in a
<A HREF="http://www.cs.rice.edu/~vivek/flash99/">paper</A> by Peter
Druschel et al. In this architecture the main process communicates with
a helper process via an IPC channel (<TT>pipe(2), socketpair(2)</TT>).
The main process instructs a helper to perform the potentially blocking
operation. Once the operation completes, the helper returns a
notification via IPC.
</UL>
<P>
<A NAME="timeouts">
<H3>Timeouts</H3>
The <TT>timeout</TT> parameter to <TT>st_cond_timedwait()</TT> and the
I/O functions, and the arguments to <TT>st_sleep()</TT> and
<TT>st_usleep()</TT> specify a maximum time to wait <I>since the last
context switch</I> not since the beginning of the function call.
<P>The State Threads' time resolution is actually the time interval
between context switches. That time interval may be large in some
situations, for example, when a single thread does a lot of work
continuously. Note that a steady, uninterrupted stream of network I/O
qualifies for this description; a context switch occurs only when a
thread blocks.
<P>If a specified I/O timeout is less than the time interval between
context switches the function may return with a timeout error before
that amount of time has elapsed since the beginning of the function
call. For example, if eight milliseconds have passed since the last
context switch and an I/O function with a timeout of 10 milliseconds
blocks, causing a switch, the call may return with a timeout error as
little as two milliseconds after it was called. (On Linux,
<TT>select()</TT>'s timeout is an <I>upper</I> bound on the amount of
time elapsed before select returns.) Similarly, if 12 ms have passed
already, the function may return immediately.
<P>In almost all cases I/O timeouts should be used only for detecting a
broken network connection or for preventing a peer from holding an idle
connection for too long. Therefore for most applications realistic I/O
timeouts should be on the order of seconds. Furthermore, there's
probably no point in retrying operations that time out. Rather than
retrying simply use a larger timeout in the first place.
<P>The largest valid timeout value is platform-dependent and may be
significantly less than <TT>INT_MAX</TT> seconds for <TT>select()</TT>
or <TT>INT_MAX</TT> milliseconds for <TT>poll()</TT>. Generally, you
should not use timeouts exceeding several hours. Use
<tt>ST_UTIME_NO_TIMEOUT</tt> (<tt>-1</tt>) as a special value to
indicate infinite timeout or indefinite sleep. Use
<tt>ST_UTIME_NO_WAIT</tt> (<tt>0</tt>) to indicate no waiting at all.
<P>
<HR>
<P>
</BODY>
</HTML>

3120
trunk/3rdparty/st-srs/docs/reference.html vendored Normal file

File diff suppressed because it is too large Load diff

504
trunk/3rdparty/st-srs/docs/st.html vendored Normal file
View file

@ -0,0 +1,504 @@
<HTML>
<HEAD>
<TITLE>State Threads for Internet Applications</TITLE>
</HEAD>
<BODY BGCOLOR=#FFFFFF>
<H2>State Threads for Internet Applications</H2>
<H3>Introduction</H3>
<P>
State Threads is an application library which provides a
foundation for writing fast and highly scalable Internet Applications
on UNIX-like platforms. It combines the simplicity of the multithreaded
programming paradigm, in which one thread supports each simultaneous
connection, with the performance and scalability of an event-driven
state machine architecture.</P>
<H3>1. Definitions</H3>
<P>
<A NAME="IA">
<H4>1.1 Internet Applications</H4>
</A>
<P>
An <I>Internet Application</I> (IA) is either a server or client network
application that accepts connections from clients and may or may not
connect to servers. In an IA the arrival or departure of network data
often controls processing (that is, IA is a <I>data-driven</I> application).
For each connection, an IA does some finite amount of work
involving data exchange with its peer, where its peer may be either
a client or a server.
The typical transaction steps of an IA are to accept a connection,
read a request, do some finite and predictable amount of work to
process the request, then write a response to the peer that sent the
request. One example of an IA is a Web server;
the most general example of an IA is a proxy server, because it both
accepts connections from clients and connects to other servers.</P>
<P>
We assume that the performance of an IA is constrained by available CPU
cycles rather than network bandwidth or disk I/O (that is, CPU
is a bottleneck resource).
<P>
<A NAME="PS">
<H4>1.2 Performance and Scalability</H4>
</A>
<P>
The <I>performance</I> of an IA is usually evaluated as its
throughput measured in transactions per second or bytes per second (one
can be converted to the other, given the average transaction size). There are
several benchmarks that can be used to measure throughput of Web serving
applications for specific workloads (such as
<A HREF="http://www.spec.org/osg/web96/">SPECweb96</A>,
<A HREF="http://www.mindcraft.com/webstone/">WebStone</A>,
<A HREF="http://www.zdnet.com/zdbop/webbench/">WebBench</A>).
Although there is no common definition for <I>scalability</I>, in general it
expresses the ability of an application to sustain its performance when some
external condition changes. For IAs this external condition is either the
number of clients (also known as "users," "simultaneous connections," or "load
generators") or the underlying hardware system size (number of CPUs, memory
size, and so on). Thus there are two types of scalability: <I>load
scalability</I> and <I>system scalability</I>, respectively.
<P>
The figure below shows how the throughput of an idealized IA changes with
the increasing number of clients (solid blue line). Initially the throughput
grows linearly (the slope represents the maximal throughput that one client
can provide). Within this initial range, the IA is underutilized and CPUs are
partially idle. Further increase in the number of clients leads to a system
saturation, and the throughput gradually stops growing as all CPUs become fully
utilized. After that point, the throughput stays flat because there are no
more CPU cycles available.
In the real world, however, each simultaneous connection
consumes some computational and memory resources, even when idle, and this
overhead grows with the number of clients. Therefore, the throughput of the
real world IA starts dropping after some point (dashed blue line in the figure
below). The rate at which the throughput drops depends, among other things, on
application design.
<P>
We say that an application has a good <I>load scalability</I> if it can
sustain its throughput over a wide range of loads.
Interestingly, the <A HREF="http://www.spec.org/osg/web99/">SPECweb99</A>
benchmark somewhat reflects the Web server's load scalability because it
measures the number of clients (load generators) given a mandatory minimal
throughput per client (that is, it measures the server's <I>capacity</I>).
This is unlike <A HREF="http://www.spec.org/osg/web96/">SPECweb96</A> and
other benchmarks that use the throughput as their main metric (see the figure
below).
<P>
<CENTER><IMG SRC="fig.gif" ALT="Figure: Throughput vs. Number of clients">
</CENTER>
<P>
<I>System scalability</I> is the ability of an application to sustain its
performance per hardware unit (such as a CPU) with the increasing number of
these units. In other words, good system scalability means that doubling the
number of processors will roughly double the application's throughput (dashed
green line). We assume here that the underlying operating system also scales
well. Good system scalability allows you to initially run an application on
the smallest system possible, while retaining the ability to move that
application to a larger system if necessary, without excessive effort or
expense. That is, an application need not be rewritten or even undergo a
major porting effort when changing system size.
<P>
Although scalability and performance are more important in the case of server
IAs, they should also be considered for some client applications (such as
benchmark load generators).
<P>
<A NAME="CONC">
<H4>1.3 Concurrency</H4>
</A>
<P>
Concurrency reflects the parallelism in a system. The two unrelated types
are <I>virtual</I> concurrency and <I>real</I> concurrency.
<UL>
<LI>Virtual (or apparent) concurrency is the number of simultaneous
connections that a system supports.
<BR><BR>
<LI>Real concurrency is the number of hardware devices, including
CPUs, network cards, and disks, that actually allow a system to perform
tasks in parallel.
</UL>
<P>
An IA must provide virtual concurrency in order to serve many users
simultaneously.
To achieve maximum performance and scalability in doing so, the number of
programming entities than an IA creates to be scheduled by the OS kernel
should be
kept close to (within an order of magnitude of) the real concurrency found on
the system. These programming entities scheduled by the kernel are known as
<I>kernel execution vehicles</I>. Examples of kernel execution vehicles
include Solaris lightweight processes and IRIX kernel threads.
In other words, the number of kernel execution vehicles should be dictated by
the system size and not by the number of simultaneous connections.
<P>
<H3>2. Existing Architectures</H3>
<P>
There are a few different architectures that are commonly used by IAs.
These include the <I>Multi-Process</I>,
<I>Multi-Threaded</I>, and <I>Event-Driven State Machine</I>
architectures.
<P>
<A NAME="MP">
<H4>2.1 Multi-Process Architecture</H4>
</A>
<P>
In the Multi-Process (MP) architecture, an individual process is
dedicated to each simultaneous connection.
A process performs all of a transaction's initialization steps
and services a connection completely before moving on to service
a new connection.
<P>
User sessions in IAs are relatively independent; therefore, no
synchronization between processes handling different connections is
necessary. Because each process has its own private address space,
this architecture is very robust. If a process serving one of the connections
crashes, the other sessions will not be affected. However, to serve many
concurrent connections, an equal number of processes must be employed.
Because processes are kernel entities (and are in fact the heaviest ones),
the number of kernel entities will be at least as large as the number of
concurrent sessions. On most systems, good performance will not be achieved
when more than a few hundred processes are created because of the high
context-switching overhead. In other words, MP applications have poor load
scalability.
<P>
On the other hand, MP applications have very good system scalability, because
no resources are shared among different processes and there is no
synchronization overhead.
<P>
The Apache Web Server 1.x (<A HREF=#refs1>[Reference 1]</A>) uses the MP
architecture on UNIX systems.
<P>
<A NAME="MT">
<H4>2.2 Multi-Threaded Architecture</H4>
</A>
<P>
In the Multi-Threaded (MT) architecture, multiple independent threads
of control are employed within a single shared address space. Like a
process in the MP architecture, each thread performs all of a
transaction's initialization steps and services a connection completely
before moving on to service a new connection.
<P>
Many modern UNIX operating systems implement a <I>many-to-few</I> model when
mapping user-level threads to kernel entities. In this model, an
arbitrarily large number of user-level threads is multiplexed onto a
lesser number of kernel execution vehicles. Kernel execution
vehicles are also known as <I>virtual processors</I>. Whenever a user-level
thread makes a blocking system call, the kernel execution vehicle it is using
will become blocked in the kernel. If there are no other non-blocked kernel
execution vehicles and there are other runnable user-level threads, a new
kernel execution vehicle will be created automatically. This prevents the
application from blocking when it can continue to make useful forward
progress.
<P>
Because IAs are by nature network I/O driven, all concurrent sessions block on
network I/O at various points. As a result, the number of virtual processors
created in the kernel grows close to the number of user-level threads
(or simultaneous connections). When this occurs, the many-to-few model
effectively degenerates to a <I>one-to-one</I> model. Again, like in
the MP architecture, the number of kernel execution vehicles is dictated by
the number of simultaneous connections rather than by number of CPUs. This
reduces an application's load scalability. However, because kernel threads
(lightweight processes) use fewer resources and are more light-weight than
traditional UNIX processes, an MT application should scale better with load
than an MP application.
<P>
Unexpectedly, the small number of virtual processors sharing the same address
space in the MT architecture destroys an application's system scalability
because of contention among the threads on various locks. Even if an
application itself is carefully
optimized to avoid lock contention around its own global data (a non-trivial
task), there are still standard library functions and system calls
that use common resources hidden from the application. For example,
on many platforms thread safety of memory allocation routines
(<TT>malloc(3)</TT>, <TT>free(3)</TT>, and so on) is achieved by using a single
global lock. Another example is a per-process file descriptor table.
This common resource table is shared by all kernel execution vehicles within
the same process and must be protected when one modifies it via
certain system calls (such as <TT>open(2)</TT>, <TT>close(2)</TT>, and so on).
In addition to that, maintaining the caches coherent
among CPUs on multiprocessor systems hurts performance when different threads
running on different CPUs modify data items on the same cache line.
<P>
In order to improve load scalability, some applications employ a different
type of MT architecture: they create one or more thread(s) <I>per task</I>
rather than one thread <I>per connection</I>. For example, one small group
of threads may be responsible for accepting client connections, another
for request processing, and yet another for serving responses. The main
advantage of this architecture is that it eliminates the tight coupling
between the number of threads and number of simultaneous connections. However,
in this architecture, different task-specific thread groups must share common
work queues that must be protected by mutual exclusion locks (a typical
producer-consumer problem). This adds synchronization overhead that causes an
application to perform badly on multiprocessor systems. In other words, in
this architecture, the application's system scalability is sacrificed for the
sake of load scalability.
<P>
Of course, the usual nightmares of threaded programming, including data
corruption, deadlocks, and race conditions, also make MT architecture (in any
form) non-simplistic to use.
<P>
<A NAME="EDSM">
<H4>2.3 Event-Driven State Machine Architecture</H4>
</A>
<P>
In the Event-Driven State Machine (EDSM) architecture, a single process
is employed to concurrently process multiple connections. The basics of this
architecture are described in Comer and Stevens
<A HREF=#refs2>[Reference 2]</A>.
The EDSM architecture performs one basic data-driven step associated with
a particular connection at a time, thus multiplexing many concurrent
connections. The process operates as a state machine that receives an event
and then reacts to it.
<P>
In the idle state the EDSM calls <TT>select(2)</TT> or <TT>poll(2)</TT> to
wait for network I/O events. When a particular file descriptor is ready for
I/O, the EDSM completes the corresponding basic step (usually by invoking a
handler function) and starts the next one. This architecture uses
non-blocking system calls to perform asynchronous network I/O operations.
For more details on non-blocking I/O see Stevens
<A HREF=#refs3>[Reference 3]</A>.
<P>
To take advantage of hardware parallelism (real concurrency), multiple
identical processes may be created. This is called Symmetric Multi-Process
EDSM and is used, for example, in the Zeus Web Server
(<A HREF=#refs4>[Reference 4]</A>). To more efficiently multiplex disk I/O,
special "helper" processes may be created. This is called Asymmetric
Multi-Process EDSM and was proposed for Web servers by Druschel
and others <A HREF=#refs5>[Reference 5]</A>.
<P>
EDSM is probably the most scalable architecture for IAs.
Because the number of simultaneous connections (virtual concurrency) is
completely decoupled from the number of kernel execution vehicles (processes),
this architecture has very good load scalability. It requires only minimal
user-level resources to create and maintain additional connection.
<P>
Like MP applications, Multi-Process EDSM has very good system scalability
because no resources are shared among different processes and there is no
synchronization overhead.
<P>
Unfortunately, the EDSM architecture is monolithic rather than based on the
concept of threads, so new applications generally need to be implemented from
the ground up. In effect, the EDSM architecture simulates threads and their
stacks the hard way.
<P>
<A NAME="ST">
<H3>3. State Threads Library</H3>
</A>
<P>
The State Threads library combines the advantages of all of the above
architectures. The interface preserves the programming simplicity of thread
abstraction, allowing each simultaneous connection to be treated as a separate
thread of execution within a single process. The underlying implementation is
close to the EDSM architecture as the state of each particular concurrent
session is saved in a separate memory segment.
<P>
<H4>3.1 State Changes and Scheduling</H4>
<P>
The state of each concurrent session includes its stack environment
(stack pointer, program counter, CPU registers) and its stack. Conceptually,
a thread context switch can be viewed as a process changing its state. There
are no kernel entities involved other than processes.
Unlike other general-purpose threading libraries, the State Threads library
is fully deterministic. The thread context switch (process state change) can
only happen in a well-known set of functions (at I/O points or at explicit
synchronization points). As a result, process-specific global data does not
have to be protected by mutual exclusion locks in most cases. The entire
application is free to use all the static variables and non-reentrant library
functions it wants, greatly simplifying programming and debugging while
increasing performance. This is somewhat similar to a <I>co-routine</I> model
(co-operatively multitasked threads), except that no explicit yield is needed
--
sooner or later, a thread performs a blocking I/O operation and thus surrenders
control. All threads of execution (simultaneous connections) have the
same priority, so scheduling is non-preemptive, like in the EDSM architecture.
Because IAs are data-driven (processing is limited by the size of network
buffers and data arrival rates), scheduling is non-time-slicing.
<P>
Only two types of external events are handled by the library's
scheduler, because only these events can be detected by
<TT>select(2)</TT> or <TT>poll(2)</TT>: I/O events (a file descriptor is ready
for I/O) and time events
(some timeout has expired). However, other types of events (such as
a signal sent to a process) can also be handled by converting them to I/O
events. For example, a signal handling function can perform a write to a pipe
(<TT>write(2)</TT> is reentrant/asynchronous-safe), thus converting a signal
event to an I/O event.
<P>
To take advantage of hardware parallelism, as in the EDSM architecture,
multiple processes can be created in either a symmetric or asymmetric manner.
Process management is not in the library's scope but instead is left up to the
application.
<P>
There are several general-purpose threading libraries that implement a
<I>many-to-one</I> model (many user-level threads to one kernel execution
vehicle), using the same basic techniques as the State Threads library
(non-blocking I/O, event-driven scheduler, and so on). For an example, see GNU
Portable Threads (<A HREF=#refs6>[Reference 6]</A>). Because they are
general-purpose, these libraries have different objectives than the State
Threads library. The State Threads library is <I>not</I> a general-purpose
threading library,
but rather an application library that targets only certain types of
applications (IAs) in order to achieve the highest possible performance and
scalability for those applications.
<P>
<H4>3.2 Scalability</H4>
<P>
State threads are very lightweight user-level entities, and therefore creating
and maintaining user connections requires minimal resources. An application
using the State Threads library scales very well with the increasing number
of connections.
<P>
On multiprocessor systems an application should create multiple processes
to take advantage of hardware parallelism. Using multiple separate processes
is the <I>only</I> way to achieve the highest possible system scalability.
This is because duplicating per-process resources is the only way to avoid
significant synchronization overhead on multiprocessor systems. Creating
separate UNIX processes naturally offers resource duplication. Again,
as in the EDSM architecture, there is no connection between the number of
simultaneous connections (which may be very large and changes within a wide
range) and the number of kernel entities (which is usually small and constant).
In other words, the State Threads library makes it possible to multiplex a
large number of simultaneous connections onto a much smaller number of
separate processes, thus allowing an application to scale well with both
the load and system size.
<P>
<H4>3.3 Performance</H4>
<P>
Performance is one of the library's main objectives. The State Threads
library is implemented to minimize the number of system calls and
to make thread creation and context switching as fast as possible.
For example, per-thread signal mask does not exist (unlike
POSIX threads), so there is no need to save and restore a process's
signal mask on every thread context switch. This eliminates two system
calls per context switch. Signal events can be handled much more
efficiently by converting them to I/O events (see above).
<P>
<H4>3.4 Portability</H4>
<P>
The library uses the same general, underlying concepts as the EDSM
architecture, including non-blocking I/O, file descriptors, and
I/O multiplexing. These concepts are available in some form on most
UNIX platforms, making the library very portable across many
flavors of UNIX. There are only a few platform-dependent sections in the
source.
<P>
<H4>3.5 State Threads and NSPR</H4>
<P>
The State Threads library is a derivative of the Netscape Portable
Runtime library (NSPR) <A HREF=#refs7>[Reference 7]</A>. The primary goal of
NSPR is to provide a platform-independent layer for system facilities,
where system facilities include threads, thread synchronization, and I/O.
Performance and scalability are not the main concern of NSPR. The
State Threads library addresses performance and scalability while
remaining much smaller than NSPR. It is contained in 8 source files
as opposed to more than 400, but provides all the functionality that
is needed to write efficient IAs on UNIX-like platforms.
<P>
<TABLE CELLPADDING=3>
<TR>
<TD></TD>
<TH>NSPR</TH>
<TH>State Threads</TH>
</TR>
<TR>
<TD><B>Lines of code</B></TD>
<TD ALIGN=RIGHT>~150,000</TD>
<TD ALIGN=RIGHT>~3000</TD>
</TR>
<TR>
<TD><B>Dynamic library size&nbsp;&nbsp;<BR>(debug version)</B></TD>
<TD></TD>
<TD></TD>
</TR>
<TR>
<TD>IRIX</TD>
<TD ALIGN=RIGHT>~700 KB</TD>
<TD ALIGN=RIGHT>~60 KB</TD>
</TR>
<TR>
<TD>Linux</TD>
<TD ALIGN=RIGHT>~900 KB</TD>
<TD ALIGN=RIGHT>~70 KB</TD>
</TR>
</TABLE>
<P>
<H3>Conclusion</H3>
<P>
State Threads is an application library which provides a foundation for
writing <A HREF=#IA>Internet Applications</A>. To summarize, it has the
following <I>advantages</I>:
<P>
<UL>
<LI>It allows the design of fast and highly scalable applications. An
application will scale well with both load and number of CPUs.
<P>
<LI>It greatly simplifies application programming and debugging because, as a
rule, no mutual exclusion locking is necessary and the entire application is
free to use static variables and non-reentrant library functions.
</UL>
<P>
The library's main <I>limitation</I>:
<P>
<UL>
<LI>All I/O operations on sockets must use the State Thread library's I/O
functions because only those functions perform thread scheduling and prevent
the application's processes from blocking.
</UL>
<P>
<H3>References</H3>
<OL>
<A NAME="refs1">
<LI> Apache Software Foundation,
<A HREF="http://www.apache.org">http://www.apache.org</A>.
<A NAME="refs2">
<LI> Douglas E. Comer, David L. Stevens, <I>Internetworking With TCP/IP,
Vol. III: Client-Server Programming And Applications</I>, Second Edition,
Ch. 8, 12.
<A NAME="refs3">
<LI> W. Richard Stevens, <I>UNIX Network Programming</I>, Second Edition,
Vol. 1, Ch. 15.
<A NAME="refs4">
<LI> Zeus Technology Limited,
<A HREF="http://www.zeus.co.uk/">http://www.zeus.co.uk</A>.
<A NAME="refs5">
<LI> Peter Druschel, Vivek S. Pai, Willy Zwaenepoel,
<A HREF="http://www.cs.rice.edu/~druschel/usenix99flash.ps.gz">
Flash: An Efficient and Portable Web Server</A>. In <I>Proceedings of the
USENIX 1999 Annual Technical Conference</I>, Monterey, CA, June 1999.
<A NAME="refs6">
<LI> GNU Portable Threads,
<A HREF="http://www.gnu.org/software/pth/">http://www.gnu.org/software/pth/</A>.
<A NAME="refs7">
<LI> Netscape Portable Runtime,
<A HREF="http://www.mozilla.org/docs/refList/refNSPR/">http://www.mozilla.org/docs/refList/refNSPR/</A>.
</OL>
<H3>Other resources covering various architectural issues in IAs</H3>
<OL START=8>
<LI> Dan Kegel, <I>The C10K problem</I>,
<A HREF="http://www.kegel.com/c10k.html">http://www.kegel.com/c10k.html</A>.
</LI>
<LI> James C. Hu, Douglas C. Schmidt, Irfan Pyarali, <I>JAWS: Understanding
High Performance Web Systems</I>,
<A HREF="http://www.cs.wustl.edu/~jxh/research/research.html">http://www.cs.wustl.edu/~jxh/research/research.html</A>.</LI>
</OL>
<P>
<HR>
<P>
<CENTER><FONT SIZE=-1>Portions created by SGI are Copyright &copy; 2000
Silicon Graphics, Inc. All rights reserved.</FONT></CENTER>
<P>
</BODY>
</HTML>

View file

@ -0,0 +1,60 @@
How the timeout heap works
As of version 1.5, the State Threads Library represents the queue of
sleeping threads using a heap data structure rather than a sorted
linked list. This improves performance when there is a large number
of sleeping threads, since insertion into a heap takes O(log N) time
while insertion into a sorted list takes O(N) time. For example, in
one test 1000 threads were created, each thread called st_usleep()
with a random time interval, and then all the threads where
immediately interrupted and joined before the sleeps had a chance to
finish. The whole process was repeated 1000 times, for a total of a
million sleep queue insertions and removals. With the old list-based
sleep queue, this test took 100 seconds; now it takes only 12 seconds.
Heap data structures are typically based on dynamically resized
arrays. However, since the existing ST code base was very nicely
structured around linking the thread objects into pointer-based lists
without the need for any auxiliary data structures, implementing the
heap using a similar nodes-and-pointers based approach seemed more
appropriate for ST than introducing a separate array.
Thus, the new ST timeout heap works by organizing the existing
_st_thread_t objects in a balanced binary tree, just as they were
previously organized into a doubly-linked, sorted list. The global
_ST_SLEEPQ variable, formerly a linked list head, is now simply a
pointer to the root of this tree, and the root node of the tree is the
thread with the earliest timeout. Each thread object has two child
pointers, "left" and "right", pointing to threads with later timeouts.
Each node in the tree is numbered with an integer index, corresponding
to the array index in an array-based heap, and the tree is kept fully
balanced and left-adjusted at all times. In other words, the tree
consists of any number of fully populated top levels, followed by a
single bottom level which may be partially populated, such that any
existing nodes form a contiguous block to the left and the spaces for
missing nodes form a contiguous block to the right. For example, if
there are nine threads waiting for a timeout, they are numbered and
arranged in a tree exactly as follows:
1
/ \
2 3
/ \ / \
4 5 6 7
/ \
8 9
Each node has either no children, only a left child, or both a left
and a right child. Children always time out later than their parents
(this is called the "heap invariant"), but when a node has two
children, their mutual order is unspecified - the left child may time
out before or after the right child. If a node is numbered N, its
left child is numbered 2N, and its right child is numbered 2N+1.
There is no pointer from a child to its parent; all pointers point
downward. Additions and deletions both work by starting at the root
and traversing the tree towards the leaves, going left or right
according to the binary digits forming the index of the destination
node. As nodes are added or deleted, existing nodes are rearranged to
maintain the heap invariant.

1413
trunk/3rdparty/st-srs/event.c vendored Normal file

File diff suppressed because it is too large Load diff

115
trunk/3rdparty/st-srs/examples/Makefile vendored Normal file
View file

@ -0,0 +1,115 @@
#
# Portions created by SGI are Copyright (C) 2000 Silicon Graphics, Inc.
# All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of Silicon Graphics, Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##########################
# Supported OSes:
#
# AIX
# FREEBSD
# HPUX
# HPUX_64
# IRIX
# IRIX_64
# LINUX
# LINUX_IA64
# NETBSD
# OPENBSD
# OSF1
# SOLARIS
# SOLARIS_64
##########################
CC = cc
SHELL = /bin/sh
ECHO = /bin/echo
DEPTH = ..
BUILD =
TARGETDIR =
DEFINES =
CFLAGS =
OTHER_FLAGS =
OBJDIR = $(DEPTH)/$(TARGETDIR)
INCDIR = $(DEPTH)/$(TARGETDIR)
LIBST = $(OBJDIR)/libst.a
HEADER = $(INCDIR)/st.h
LIBRESOLV =
EXTRALIBS =
ifeq ($(OS),)
EXAMPLES = unknown
else
EXAMPLES = $(OBJDIR)/lookupdns $(OBJDIR)/proxy $(OBJDIR)/server
endif
##########################
# Platform section.
#
ifeq (DARWIN, $(findstring DARWIN, $(OS)))
LIBRESOLV = -lresolv
endif
ifeq (LINUX, $(findstring LINUX, $(OS)))
LIBRESOLV = -lresolv
endif
ifeq (SOLARIS, $(findstring SOLARIS, $(OS)))
LIBRESOLV = -lresolv
EXTRALIBS = -lsocket -lnsl
endif
#
# End of platform section.
##########################
all: $(EXAMPLES)
$(OBJDIR)/lookupdns: lookupdns.c $(OBJDIR)/res.o $(LIBST) $(HEADER)
$(CC) $(CFLAGS) -I$(INCDIR) lookupdns.c $(OBJDIR)/res.o $(LIBST) $(LIBRESOLV) $(EXTRALIBS) -o $@
$(OBJDIR)/proxy: proxy.c $(LIBST) $(HEADER)
$(CC) $(CFLAGS) -I$(INCDIR) proxy.c $(LIBST) $(EXTRALIBS) -o $@
$(OBJDIR)/server: server.c $(OBJDIR)/error.o $(LIBST) $(HEADER)
$(CC) $(CFLAGS) -I$(INCDIR) server.c $(OBJDIR)/error.o $(LIBST) $(EXTRALIBS) -o $@
$(OBJDIR)/%.o: %.c
$(CC) $(CFLAGS) -I$(INCDIR) -c $< -o $@
.DEFAULT:
@cd $(DEPTH); $(MAKE) $@

98
trunk/3rdparty/st-srs/examples/README vendored Normal file
View file

@ -0,0 +1,98 @@
Portions created by SGI are Copyright (C) 2000 Silicon Graphics, Inc.
All Rights Reserved.
This directory contains three example programs.
---------------------------------------------------------------------------
PROGRAM
lookupdns
FILES
lookupdns.c
res.c
USAGE
lookupdns <hostname1> [<hostname2>] ...
DESCRIPTION
This program performs asynchronous DNS host name resolution and reports
IP address for each <hostname> specified as a command line argument.
One ST thread is created for each host name. All threads do host name
resolution concurrently.
---------------------------------------------------------------------------
PROGRAM
proxy
FILES
proxy.c
USAGE
proxy -l <local_addr> -r <remote_addr> [-p <num_processes>] [-S]
-l <local_addr> bind to local address specified as [<host>]:<port>
-r <remote_addr> connect to remote address specified as <host>:<port>
-p <num_processes> create specified number of processes
-S serialize accept() calls from different processes
on the same listening socket (if needed).
DESCRIPTION
This program acts as a generic gateway. It listens for connections to a
local address. Upon accepting a client connection, it connects to the
specified remote address and then just pumps the data through without any
modification.
---------------------------------------------------------------------------
PROGRAM
server
FILES
server.c
error.c
USAGE
server -l <log_directory> [<options>]
-l <log_directory> open all log files in specified directory.
Possible options:
-b <host>:<port> bind to specified address (multiple addresses
are permitted)
-p <num_processes> create specified number of processes
-t <min_thr>:<max_thr> specify thread limits per listening socket
across all processes
-u <user> change server's user id to specified value
-q <backlog> set max length of pending connections queue
-a enable access logging
-i run in interactive mode (useful for debugging)
-S serialize accept() calls from different processes
on the same listening socket (if needed).
DESCRIPTION
This program is a general server example. It accepts a client connection
and outputs a short HTML page. It can be easily adapted to provide
other services.
---------------------------------------------------------------------------

168
trunk/3rdparty/st-srs/examples/error.c vendored Normal file
View file

@ -0,0 +1,168 @@
/*
* Portions created by SGI are Copyright (C) 2000 Silicon Graphics, Inc.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Silicon Graphics, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include "st.h"
/*
* Simple error reporting functions.
* Suggested in W. Richard Stevens' "Advanced Programming in UNIX
* Environment".
*/
#define MAXLINE 4096 /* max line length */
static void err_doit(int, int, const char *, va_list);
/*
* Nonfatal error related to a system call.
* Print a message and return.
*/
void err_sys_report(int fd, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_doit(fd, 1, fmt, ap);
va_end(ap);
}
/*
* Fatal error related to a system call.
* Print a message and terminate.
*/
void err_sys_quit(int fd, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_doit(fd, 1, fmt, ap);
va_end(ap);
exit(1);
}
/*
* Fatal error related to a system call.
* Print a message, dump core, and terminate.
*/
void err_sys_dump(int fd, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_doit(fd, 1, fmt, ap);
va_end(ap);
abort(); /* dump core and terminate */
exit(1); /* shouldn't get here */
}
/*
* Nonfatal error unrelated to a system call.
* Print a message and return.
*/
void err_report(int fd, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_doit(fd, 0, fmt, ap);
va_end(ap);
}
/*
* Fatal error unrelated to a system call.
* Print a message and terminate.
*/
void err_quit(int fd, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_doit(fd, 0, fmt, ap);
va_end(ap);
exit(1);
}
/*
* Return a pointer to a string containing current time.
*/
char *err_tstamp(void)
{
static char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
static char str[32];
static time_t lastt = 0;
struct tm *tmp;
time_t currt = st_time();
if (currt == lastt)
return str;
tmp = localtime(&currt);
sprintf(str, "[%02d/%s/%d:%02d:%02d:%02d] ", tmp->tm_mday,
months[tmp->tm_mon], 1900 + tmp->tm_year, tmp->tm_hour,
tmp->tm_min, tmp->tm_sec);
lastt = currt;
return str;
}
/*
* Print a message and return to caller.
* Caller specifies "errnoflag".
*/
static void err_doit(int fd, int errnoflag, const char *fmt, va_list ap)
{
int errno_save;
char buf[MAXLINE];
errno_save = errno; /* value caller might want printed */
strcpy(buf, err_tstamp()); /* prepend a message with time stamp */
vsprintf(buf + strlen(buf), fmt, ap);
if (errnoflag)
sprintf(buf + strlen(buf), ": %s\n", strerror(errno_save));
else
strcat(buf, "\n");
write(fd, buf, strlen(buf));
errno = errno_save;
}

View file

@ -0,0 +1,103 @@
/*
* Portions created by SGI are Copyright (C) 2000 Silicon Graphics, Inc.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Silicon Graphics, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include "st.h"
#if !defined(NETDB_INTERNAL) && defined(h_NETDB_INTERNAL)
#define NETDB_INTERNAL h_NETDB_INTERNAL
#endif
/* Resolution timeout (in microseconds) */
#define TIMEOUT (2*1000000LL)
/* External function defined in the res.c file */
int dns_getaddr(const char *host, struct in_addr *addr, st_utime_t timeout);
void *do_resolve(void *host)
{
struct in_addr addr;
/* Use dns_getaddr() instead of gethostbyname(3) to get IP address */
if (dns_getaddr(host, &addr, TIMEOUT) < 0) {
fprintf(stderr, "dns_getaddr: can't resolve %s: ", (char *)host);
if (h_errno == NETDB_INTERNAL)
perror("");
else
herror("");
} else
printf("%-40s %s\n", (char *)host, inet_ntoa(addr));
return NULL;
}
/*
* Asynchronous DNS host name resolution. This program creates one
* ST thread for each host name (specified as command line arguments).
* All threads do host name resolution concurrently.
*/
int main(int argc, char *argv[])
{
int i;
if (argc < 2) {
fprintf(stderr, "Usage: %s <hostname1> [<hostname2>] ...\n", argv[0]);
exit(1);
}
if (st_init() < 0) {
perror("st_init");
exit(1);
}
for (i = 1; i < argc; i++) {
/* Create a separate thread for each host name */
if (st_thread_create(do_resolve, argv[i], 0, 0) == NULL) {
perror("st_thread_create");
exit(1);
}
}
st_thread_exit(NULL);
/* NOTREACHED */
return 1;
}

541
trunk/3rdparty/st-srs/examples/proxy.c vendored Normal file
View file

@ -0,0 +1,541 @@
/*
* Portions created by SGI are Copyright (C) 2000 Silicon Graphics, Inc.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Silicon Graphics, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include "st.h"
#define IOBUFSIZE (16*1024)
#define IOV_LEN 256
#define IOV_COUNT (IOBUFSIZE / IOV_LEN)
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff
#endif
static char *prog; /* Program name */
static struct sockaddr_in rmt_addr; /* Remote address */
static unsigned long testing;
#define TESTING_VERBOSE 0x1
#define TESTING_READV 0x2
#define TESTING_READ_RESID 0x4
#define TESTING_WRITEV 0x8
#define TESTING_WRITE_RESID 0x10
static void read_address(const char *str, struct sockaddr_in *sin);
static void start_daemon(void);
static int cpu_count(void);
static void set_concurrency(int nproc);
static void *handle_request(void *arg);
static void print_sys_error(const char *msg);
/*
* This program acts as a generic gateway. It listens for connections
* to a local address ('-l' option). Upon accepting a client connection,
* it connects to the specified remote address ('-r' option) and then
* just pumps the data through without any modification.
*/
int main(int argc, char *argv[])
{
extern char *optarg;
int opt, sock, n;
int laddr, raddr, num_procs, alt_ev, one_process;
int serialize_accept = 0;
struct sockaddr_in lcl_addr, cli_addr;
st_netfd_t cli_nfd, srv_nfd;
prog = argv[0];
num_procs = laddr = raddr = alt_ev = one_process = 0;
/* Parse arguments */
while((opt = getopt(argc, argv, "l:r:p:Saht:X")) != EOF) {
switch (opt) {
case 'a':
alt_ev = 1;
break;
case 'l':
read_address(optarg, &lcl_addr);
laddr = 1;
break;
case 'r':
read_address(optarg, &rmt_addr);
if (rmt_addr.sin_addr.s_addr == INADDR_ANY) {
fprintf(stderr, "%s: invalid remote address: %s\n", prog, optarg);
exit(1);
}
raddr = 1;
break;
case 'p':
num_procs = atoi(optarg);
if (num_procs < 1) {
fprintf(stderr, "%s: invalid number of processes: %s\n", prog, optarg);
exit(1);
}
break;
case 'S':
/*
* Serialization decision is tricky on some platforms. For example,
* Solaris 2.6 and above has kernel sockets implementation, so supposedly
* there is no need for serialization. The ST library may be compiled
* on one OS version, but used on another, so the need for serialization
* should be determined at run time by the application. Since it's just
* an example, the serialization decision is left up to user.
* Only on platforms where the serialization is never needed on any OS
* version st_netfd_serialize_accept() is a no-op.
*/
serialize_accept = 1;
break;
case 't':
testing = strtoul(optarg, NULL, 0);
break;
case 'X':
one_process = 1;
break;
case 'h':
case '?':
fprintf(stderr, "Usage: %s [options] -l <[host]:port> -r <host:port>\n",
prog);
fprintf(stderr, "options are:\n");
fprintf(stderr, " -p <num_processes> number of parallel processes\n");
fprintf(stderr, " -S serialize accepts\n");
fprintf(stderr, " -a use alternate event system\n");
#ifdef DEBUG
fprintf(stderr, " -t mask testing/debugging mode\n");
fprintf(stderr, " -X one process, don't daemonize\n");
#endif
exit(1);
}
}
if (!laddr) {
fprintf(stderr, "%s: local address required\n", prog);
exit(1);
}
if (!raddr) {
fprintf(stderr, "%s: remote address required\n", prog);
exit(1);
}
if (num_procs == 0)
num_procs = cpu_count();
fprintf(stderr, "%s: starting proxy daemon on %s:%d\n", prog,
inet_ntoa(lcl_addr.sin_addr), ntohs(lcl_addr.sin_port));
/* Start the daemon */
if (one_process)
num_procs = 1;
else
start_daemon();
if (alt_ev)
st_set_eventsys(ST_EVENTSYS_ALT);
/* Initialize the ST library */
if (st_init() < 0) {
print_sys_error("st_init");
exit(1);
}
/* Create and bind listening socket */
if ((sock = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
print_sys_error("socket");
exit(1);
}
n = 1;
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&n, sizeof(n)) < 0) {
print_sys_error("setsockopt");
exit(1);
}
if (bind(sock, (struct sockaddr *)&lcl_addr, sizeof(lcl_addr)) < 0) {
print_sys_error("bind");
exit(1);
}
listen(sock, 128);
if ((srv_nfd = st_netfd_open_socket(sock)) == NULL) {
print_sys_error("st_netfd_open");
exit(1);
}
/* See the comment regarding serialization decision above */
if (num_procs > 1 && serialize_accept && st_netfd_serialize_accept(srv_nfd)
< 0) {
print_sys_error("st_netfd_serialize_accept");
exit(1);
}
/* Start server processes */
if (!one_process)
set_concurrency(num_procs);
for ( ; ; ) {
n = sizeof(cli_addr);
cli_nfd = st_accept(srv_nfd, (struct sockaddr *)&cli_addr, &n,
ST_UTIME_NO_TIMEOUT);
if (cli_nfd == NULL) {
print_sys_error("st_accept");
exit(1);
}
if (st_thread_create(handle_request, cli_nfd, 0, 0) == NULL) {
print_sys_error("st_thread_create");
exit(1);
}
}
/* NOTREACHED */
return 1;
}
static void read_address(const char *str, struct sockaddr_in *sin)
{
char host[128], *p;
struct hostent *hp;
unsigned short port;
strcpy(host, str);
if ((p = strchr(host, ':')) == NULL) {
fprintf(stderr, "%s: invalid address: %s\n", prog, host);
exit(1);
}
*p++ = '\0';
port = (unsigned short) atoi(p);
if (port < 1) {
fprintf(stderr, "%s: invalid port: %s\n", prog, p);
exit(1);
}
memset(sin, 0, sizeof(struct sockaddr_in));
sin->sin_family = AF_INET;
sin->sin_port = htons(port);
if (host[0] == '\0') {
sin->sin_addr.s_addr = INADDR_ANY;
return;
}
sin->sin_addr.s_addr = inet_addr(host);
if (sin->sin_addr.s_addr == INADDR_NONE) {
/* not dotted-decimal */
if ((hp = gethostbyname(host)) == NULL) {
fprintf(stderr, "%s: can't resolve address: %s\n", prog, host);
exit(1);
}
memcpy(&sin->sin_addr, hp->h_addr, hp->h_length);
}
}
#ifdef DEBUG
static void show_iov(const struct iovec *iov, int niov)
{
int i;
size_t total;
printf("iov %p has %d entries:\n", iov, niov);
total = 0;
for (i = 0; i < niov; i++) {
printf("iov[%3d] iov_base=%p iov_len=0x%lx(%lu)\n",
i, iov[i].iov_base, (unsigned long) iov[i].iov_len,
(unsigned long) iov[i].iov_len);
total += iov[i].iov_len;
}
printf("total 0x%lx(%ld)\n", (unsigned long) total, (unsigned long) total);
}
/*
* This version is tricked out to test all the
* st_(read|write)v?(_resid)? variants. Use the non-DEBUG version for
* anything serious. st_(read|write) are all this function really
* needs.
*/
static int pass(st_netfd_t in, st_netfd_t out)
{
char buf[IOBUFSIZE];
struct iovec iov[IOV_COUNT];
int ioviter, nw, nr;
if (testing & TESTING_READV) {
for (ioviter = 0; ioviter < IOV_COUNT; ioviter++) {
iov[ioviter].iov_base = &buf[ioviter * IOV_LEN];
iov[ioviter].iov_len = IOV_LEN;
}
if (testing & TESTING_VERBOSE) {
printf("readv(%p)...\n", in);
show_iov(iov, IOV_COUNT);
}
if (testing & TESTING_READ_RESID) {
struct iovec *riov = iov;
int riov_cnt = IOV_COUNT;
if (st_readv_resid(in, &riov, &riov_cnt, ST_UTIME_NO_TIMEOUT) == 0) {
if (testing & TESTING_VERBOSE) {
printf("resid\n");
show_iov(riov, riov_cnt);
printf("full\n");
show_iov(iov, IOV_COUNT);
}
nr = 0;
for (ioviter = 0; ioviter < IOV_COUNT; ioviter++)
nr += iov[ioviter].iov_len;
nr = IOBUFSIZE - nr;
} else
nr = -1;
} else
nr = (int) st_readv(in, iov, IOV_COUNT, ST_UTIME_NO_TIMEOUT);
} else {
if (testing & TESTING_READ_RESID) {
size_t resid = IOBUFSIZE;
if (st_read_resid(in, buf, &resid, ST_UTIME_NO_TIMEOUT) == 0)
nr = IOBUFSIZE - resid;
else
nr = -1;
} else
nr = (int) st_read(in, buf, IOBUFSIZE, ST_UTIME_NO_TIMEOUT);
}
if (testing & TESTING_VERBOSE)
printf("got 0x%x(%d) E=%d\n", nr, nr, errno);
if (nr <= 0)
return 0;
if (testing & TESTING_WRITEV) {
for (nw = 0, ioviter = 0; nw < nr;
nw += iov[ioviter].iov_len, ioviter++) {
iov[ioviter].iov_base = &buf[nw];
iov[ioviter].iov_len = nr - nw;
if (iov[ioviter].iov_len > IOV_LEN)
iov[ioviter].iov_len = IOV_LEN;
}
if (testing & TESTING_VERBOSE) {
printf("writev(%p)...\n", out);
show_iov(iov, ioviter);
}
if (testing & TESTING_WRITE_RESID) {
struct iovec *riov = iov;
int riov_cnt = ioviter;
if (st_writev_resid(out, &riov, &riov_cnt, ST_UTIME_NO_TIMEOUT) == 0) {
if (testing & TESTING_VERBOSE) {
printf("resid\n");
show_iov(riov, riov_cnt);
printf("full\n");
show_iov(iov, ioviter);
}
nw = 0;
while (--ioviter >= 0)
nw += iov[ioviter].iov_len;
nw = nr - nw;
} else
nw = -1;
} else
nw = st_writev(out, iov, ioviter, ST_UTIME_NO_TIMEOUT);
} else {
if (testing & TESTING_WRITE_RESID) {
size_t resid = nr;
if (st_write_resid(out, buf, &resid, ST_UTIME_NO_TIMEOUT) == 0)
nw = nr - resid;
else
nw = -1;
} else
nw = st_write(out, buf, nr, ST_UTIME_NO_TIMEOUT);
}
if (testing & TESTING_VERBOSE)
printf("put 0x%x(%d) E=%d\n", nw, nw, errno);
if (nw != nr)
return 0;
return 1;
}
#else /* DEBUG */
/*
* This version is the simple one suitable for serious use.
*/
static int pass(st_netfd_t in, st_netfd_t out)
{
char buf[IOBUFSIZE];
int nw, nr;
nr = (int) st_read(in, buf, IOBUFSIZE, ST_UTIME_NO_TIMEOUT);
if (nr <= 0)
return 0;
nw = st_write(out, buf, nr, ST_UTIME_NO_TIMEOUT);
if (nw != nr)
return 0;
return 1;
}
#endif
static void *handle_request(void *arg)
{
struct pollfd pds[2];
st_netfd_t cli_nfd, rmt_nfd;
int sock;
cli_nfd = (st_netfd_t) arg;
pds[0].fd = st_netfd_fileno(cli_nfd);
pds[0].events = POLLIN;
/* Connect to remote host */
if ((sock = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
print_sys_error("socket");
goto done;
}
if ((rmt_nfd = st_netfd_open_socket(sock)) == NULL) {
print_sys_error("st_netfd_open_socket");
close(sock);
goto done;
}
if (st_connect(rmt_nfd, (struct sockaddr *)&rmt_addr,
sizeof(rmt_addr), ST_UTIME_NO_TIMEOUT) < 0) {
print_sys_error("st_connect");
st_netfd_close(rmt_nfd);
goto done;
}
pds[1].fd = sock;
pds[1].events = POLLIN;
/*
* Now just pump the data through.
* XXX This should use one thread for each direction for true full-duplex.
*/
for ( ; ; ) {
pds[0].revents = 0;
pds[1].revents = 0;
if (st_poll(pds, 2, ST_UTIME_NO_TIMEOUT) <= 0) {
print_sys_error("st_poll");
break;
}
if (pds[0].revents & POLLIN) {
if (!pass(cli_nfd, rmt_nfd))
break;
}
if (pds[1].revents & POLLIN) {
if (!pass(rmt_nfd, cli_nfd))
break;
}
}
st_netfd_close(rmt_nfd);
done:
st_netfd_close(cli_nfd);
return NULL;
}
static void start_daemon(void)
{
pid_t pid;
/* Start forking */
if ((pid = fork()) < 0) {
print_sys_error("fork");
exit(1);
}
if (pid > 0)
exit(0); /* parent */
/* First child process */
setsid(); /* become session leader */
if ((pid = fork()) < 0) {
print_sys_error("fork");
exit(1);
}
if (pid > 0) /* first child */
exit(0);
chdir("/");
umask(022);
}
/*
* Create separate processes ("virtual processors"). Since it's just an
* example, there is no watchdog - the parent just exits leaving children
* on their own.
*/
static void set_concurrency(int nproc)
{
pid_t pid;
int i;
if (nproc < 1)
nproc = 1;
for (i = 0; i < nproc; i++) {
if ((pid = fork()) < 0) {
print_sys_error("fork");
exit(1);
}
/* Child returns */
if (pid == 0)
return;
}
/* Parent just exits */
exit(0);
}
static int cpu_count(void)
{
int n;
#if defined (_SC_NPROCESSORS_ONLN)
n = (int) sysconf(_SC_NPROCESSORS_ONLN);
#elif defined (_SC_NPROC_ONLN)
n = (int) sysconf(_SC_NPROC_ONLN);
#elif defined (HPUX)
#include <sys/mpctl.h>
n = mpctl(MPC_GETNUMSPUS, 0, 0);
#else
n = -1;
errno = ENOSYS;
#endif
return n;
}
static void print_sys_error(const char *msg)
{
fprintf(stderr, "%s: %s: %s\n", prog, msg, strerror(errno));
}

305
trunk/3rdparty/st-srs/examples/res.c vendored Normal file
View file

@ -0,0 +1,305 @@
/*
* Copyright (c) 1985, 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Portions created by SGI are Copyright (C) 2000 Silicon Graphics, Inc.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Silicon Graphics, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined (DARWIN)
#define BIND_8_COMPAT
#endif
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <netdb.h>
#include <errno.h>
#include "st.h"
#define MAXPACKET 1024
#if !defined(NETDB_INTERNAL) && defined(h_NETDB_INTERNAL)
#define NETDB_INTERNAL h_NETDB_INTERNAL
#endif
/* New in Solaris 7 */
#if !defined(_getshort) && defined(ns_get16)
#define _getshort(cp) ns_get16(cp)
#endif
typedef union {
HEADER hdr;
u_char buf[MAXPACKET];
} querybuf_t;
static int parse_answer(querybuf_t *ans, int len, struct in_addr *addr)
{
char buf[MAXPACKET];
HEADER *ahp;
u_char *cp, *eoa;
int type, n;
ahp = &ans->hdr;
eoa = ans->buf + len;
cp = ans->buf + sizeof(HEADER);
while (ahp->qdcount > 0) {
ahp->qdcount--;
cp += dn_skipname(cp, eoa) + QFIXEDSZ;
}
while (ahp->ancount > 0 && cp < eoa) {
ahp->ancount--;
if ((n = dn_expand(ans->buf, eoa, cp, buf, sizeof(buf))) < 0)
break;
cp += n;
type = _getshort(cp);
cp += 8;
n = _getshort(cp);
cp += 2;
if (type == T_CNAME) {
cp += n;
continue;
}
memcpy(addr, cp, n);
return 0;
}
h_errno = TRY_AGAIN;
return -1;
}
static int query_domain(st_netfd_t nfd, const char *name, struct in_addr *addr,
st_utime_t timeout)
{
querybuf_t qbuf;
u_char *buf = qbuf.buf;
HEADER *hp = &qbuf.hdr;
int blen = sizeof(qbuf);
int i, len, id;
for (i = 0; i < _res.nscount; i++) {
len = res_mkquery(QUERY, name, C_IN, T_A, NULL, 0, NULL, buf, blen);
if (len <= 0) {
h_errno = NO_RECOVERY;
return -1;
}
id = hp->id;
if (st_sendto(nfd, buf, len, (struct sockaddr *)&(_res.nsaddr_list[i]),
sizeof(struct sockaddr), timeout) != len) {
h_errno = NETDB_INTERNAL;
/* EINTR means interrupt by other thread, NOT by a caught signal */
if (errno == EINTR)
return -1;
continue;
}
/* Wait for reply */
do {
len = st_recvfrom(nfd, buf, blen, NULL, NULL, timeout);
if (len <= 0)
break;
} while (id != hp->id);
if (len < HFIXEDSZ) {
h_errno = NETDB_INTERNAL;
if (len >= 0)
errno = EMSGSIZE;
else if (errno == EINTR) /* see the comment above */
return -1;
continue;
}
hp->ancount = ntohs(hp->ancount);
hp->qdcount = ntohs(hp->qdcount);
if ((hp->rcode != NOERROR) || (hp->ancount == 0)) {
switch (hp->rcode) {
case NXDOMAIN:
h_errno = HOST_NOT_FOUND;
break;
case SERVFAIL:
h_errno = TRY_AGAIN;
break;
case NOERROR:
h_errno = NO_DATA;
break;
case FORMERR:
case NOTIMP:
case REFUSED:
default:
h_errno = NO_RECOVERY;
}
continue;
}
if (parse_answer(&qbuf, len, addr) == 0)
return 0;
}
return -1;
}
#define CLOSE_AND_RETURN(ret) \
{ \
n = errno; \
st_netfd_close(nfd); \
errno = n; \
return (ret); \
}
int dns_getaddr(const char *host, struct in_addr *addr, st_utime_t timeout)
{
char name[MAXDNAME], **domain;
const char *cp;
int s, n, maxlen, dots;
int trailing_dot, tried_as_is;
st_netfd_t nfd;
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
h_errno = NETDB_INTERNAL;
return -1;
}
if (_res.options & RES_USEVC) {
h_errno = NETDB_INTERNAL;
errno = ENOSYS;
return -1;
}
if (!host || *host == '\0') {
h_errno = HOST_NOT_FOUND;
return -1;
}
/* Create UDP socket */
if ((s = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
h_errno = NETDB_INTERNAL;
return -1;
}
if ((nfd = st_netfd_open_socket(s)) == NULL) {
h_errno = NETDB_INTERNAL;
n = errno;
close(s);
errno = n;
return -1;
}
maxlen = sizeof(name) - 1;
n = 0;
dots = 0;
trailing_dot = 0;
tried_as_is = 0;
for (cp = host; *cp && n < maxlen; cp++) {
dots += (*cp == '.');
name[n++] = *cp;
}
if (name[n - 1] == '.')
trailing_dot = 1;
/*
* If there are dots in the name already, let's just give it a try
* 'as is'. The threshold can be set with the "ndots" option.
*/
if (dots >= _res.ndots) {
if (query_domain(nfd, host, addr, timeout) == 0)
CLOSE_AND_RETURN(0);
if (h_errno == NETDB_INTERNAL && errno == EINTR)
CLOSE_AND_RETURN(-1);
tried_as_is = 1;
}
/*
* We do at least one level of search if
* - there is no dot and RES_DEFNAME is set, or
* - there is at least one dot, there is no trailing dot,
* and RES_DNSRCH is set.
*/
if ((!dots && (_res.options & RES_DEFNAMES)) ||
(dots && !trailing_dot && (_res.options & RES_DNSRCH))) {
name[n++] = '.';
for (domain = _res.dnsrch; *domain; domain++) {
strncpy(name + n, *domain, maxlen - n);
if (query_domain(nfd, name, addr, timeout) == 0)
CLOSE_AND_RETURN(0);
if (h_errno == NETDB_INTERNAL && errno == EINTR)
CLOSE_AND_RETURN(-1);
if (!(_res.options & RES_DNSRCH))
break;
}
}
/*
* If we have not already tried the name "as is", do that now.
* note that we do this regardless of how many dots were in the
* name or whether it ends with a dot.
*/
if (!tried_as_is) {
if (query_domain(nfd, host, addr, timeout) == 0)
CLOSE_AND_RETURN(0);
}
CLOSE_AND_RETURN(-1);
}

1025
trunk/3rdparty/st-srs/examples/server.c vendored Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,91 @@
#
# Portions created by SGI are Copyright (C) 2000 Silicon Graphics, Inc.
# All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of Silicon Graphics, Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
CC = cc
SHELL = /bin/sh
ECHO = /bin/echo
DEPTH = ..
BUILD =
TARGETDIR = obj
DEFINES =
OTHER_FLAGS =
CFLAGS =
OBJDIR = $(DEPTH)/$(TARGETDIR)
INCDIR = $(DEPTH)/$(TARGETDIR)
LIBRESOLV =
EXTRALIBS =
SLIBRARY = $(OBJDIR)/libstx.a
OBJS = $(OBJDIR)/dnscache.o $(OBJDIR)/dnsres.o $(OBJDIR)/lrucache.o
CFLAGS += -Wall -I$(INCDIR)
AR = ar
ARFLAGS = rv
RANLIB = ranlib
##########################
# Platform section.
#
ifeq (LINUX, $(findstring LINUX, $(OS)))
LIBRESOLV = -lresolv
endif
ifeq ($(OS), SOLARIS)
LIBRESOLV = -lresolv
EXTRALIBS = -lsocket -lnsl
endif
#
# End of platform section.
##########################
all: $(SLIBRARY)
$(SLIBRARY): $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
$(RANLIB) $@
$(OBJDIR)/%.o: %.c stx.h common.h
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -rf $(OBJS) $(SLIBRARY)
#.DEFAULT:
# @cd $(DEPTH); $(MAKE) $@

42
trunk/3rdparty/st-srs/extensions/README vendored Normal file
View file

@ -0,0 +1,42 @@
This directory contains extensions to the core State Threads Library
that were contributed by users. All files hereunder are not part of the
State Threads Library itself. They are provided as-is, without warranty
or support, and under whatever license terms their authors provided. To
contribute your own extensions, just mail them to the project
administrators or to one of the project's mailing lists; see
state-threads.sourceforge.net. Please indicate the license terms under
which the project may distribute your contribution.
========================================================================
stx_fileio
----------
Contributed by Jeff <jlb-st@houseofdistraction.com>, 4 Nov 2002.
Provides non-blocking random access file reading capability for
programs using the State Threads library. There is one public function:
ssize_t stx_file_read(st_netfd_t fd, off_t offset,
void *buf, size_t nbytes, st_utime_t timeout);
The implementation is not optimal in that the data is copied at least once
more than should be necessary. Its usefulness is limited to cases where
random access to a file is required and where starvation of other threads
is unacceptable.
The particular application which motivated this implementation was a UDP
file transfer protocol. Because the OS does very little buffering of UDP
traffic it is important that UDP transmission threads are not starved for
periods of time which are long relative to the interval required to
maintain a steady send rate.
Licensed under the same dual MPL/GPL as core State Threads.
========================================================================
stx_dns
-------
Documentation coming.
========================================================================

View file

@ -0,0 +1,77 @@
#ifndef _STX_COMMON_H_
#define _STX_COMMON_H_
#include <stddef.h>
#include <stdlib.h>
#define STX_BEGIN_MACRO {
#define STX_END_MACRO }
/*****************************************
* Circular linked list definitions
*/
typedef struct _stx_clist {
struct _stx_clist *next;
struct _stx_clist *prev;
} stx_clist_t;
/* Insert element "_e" into the list, before "_l" */
#define STX_CLIST_INSERT_BEFORE(_e,_l) \
STX_BEGIN_MACRO \
(_e)->next = (_l); \
(_e)->prev = (_l)->prev; \
(_l)->prev->next = (_e); \
(_l)->prev = (_e); \
STX_END_MACRO
/* Insert element "_e" into the list, after "_l" */
#define STX_CLIST_INSERT_AFTER(_e,_l) \
STX_BEGIN_MACRO \
(_e)->next = (_l)->next; \
(_e)->prev = (_l); \
(_l)->next->prev = (_e); \
(_l)->next = (_e); \
STX_END_MACRO
/* Append an element "_e" to the end of the list "_l" */
#define STX_CLIST_APPEND_LINK(_e,_l) STX_CLIST_INSERT_BEFORE(_e,_l)
/* Remove the element "_e" from it's circular list */
#define STX_CLIST_REMOVE_LINK(_e) \
STX_BEGIN_MACRO \
(_e)->prev->next = (_e)->next; \
(_e)->next->prev = (_e)->prev; \
STX_END_MACRO
/* Return the head/tail of the list */
#define STX_CLIST_HEAD(_l) (_l)->next
#define STX_CLIST_TAIL(_l) (_l)->prev
/* Return non-zero if the given circular list "_l" is empty, */
/* zero if the circular list is not empty */
#define STX_CLIST_IS_EMPTY(_l) \
((_l)->next == (_l))
/* Initialize a circular list */
#define STX_CLIST_INIT_CLIST(_l) \
STX_BEGIN_MACRO \
(_l)->next = (_l); \
(_l)->prev = (_l); \
STX_END_MACRO
/*****************************************
* Useful macros
*/
#ifndef offsetof
#define offsetof(type, identifier) ((size_t)&(((type *)0)->identifier))
#endif
#define STX_MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif /* !_STX_COMMON_H_ */

View file

@ -0,0 +1,190 @@
#include "stx.h"
#include "common.h"
/*****************************************
* Basic types definitions
*/
typedef struct _stx_dns_data {
struct in_addr *addrs;
int num_addrs;
int cur;
time_t expires;
} stx_dns_data_t;
#define MAX_HOST_ADDRS 1024
static struct in_addr addr_list[MAX_HOST_ADDRS];
stx_cache_t *_stx_dns_cache = NULL;
extern int _stx_dns_ttl;
extern int _stx_dns_getaddrlist(const char *hostname, struct in_addr *addrs,
int *num_addrs, st_utime_t timeout);
static unsigned long hash_hostname(const void *key)
{
const char *name = (const char *)key;
unsigned long hash = 0;
while (*name)
hash = (hash << 4) - hash + *name++; /* hash = hash * 15 + *name++ */
return hash;
}
static void cleanup_entry(void *key, void *data)
{
if (key)
free(key);
if (data) {
if (((stx_dns_data_t *)data)->addrs)
free(((stx_dns_data_t *)data)->addrs);
free(data);
}
}
static int lookup_entry(const char *host, struct in_addr *addrs,
int *num_addrs, int rotate)
{
stx_cache_entry_t *entry;
stx_dns_data_t *data;
int n;
entry = stx_cache_entry_lookup(_stx_dns_cache, host);
if (entry) {
data = (stx_dns_data_t *)stx_cache_entry_getdata(entry);
if (st_time() <= data->expires) {
if (*num_addrs == 1) {
if (rotate) {
*addrs = data->addrs[data->cur++];
if (data->cur >= data->num_addrs)
data->cur = 0;
} else {
*addrs = data->addrs[0];
}
} else {
n = STX_MIN(*num_addrs, data->num_addrs);
memcpy(addrs, data->addrs, n * sizeof(*addrs));
*num_addrs = n;
}
stx_cache_entry_release(_stx_dns_cache, entry);
return 1;
}
/*
* Cache entry expired: decrement its refcount and purge it from cache.
*/
stx_cache_entry_release(_stx_dns_cache, entry);
stx_cache_entry_delete(_stx_dns_cache, entry);
}
return 0;
}
static void insert_entry(const char *host, struct in_addr *addrs, int count)
{
stx_cache_entry_t *entry;
stx_dns_data_t *data;
char *key;
size_t n;
if (_stx_dns_ttl > 0) {
key = strdup(host);
data = (stx_dns_data_t *)malloc(sizeof(stx_dns_data_t));
n = count * sizeof(*addrs);
if (data) {
data->addrs = (struct in_addr *)malloc(n);
if (data->addrs)
memcpy(data->addrs, addrs, n);
data->num_addrs = count;
data->cur = 0;
data->expires = st_time() + _stx_dns_ttl;
}
entry = stx_cache_entry_create(key, data, strlen(host) + 1 +
sizeof(stx_dns_data_t) + n +
stx_cache_entry_sizeof());
if (key && data && data->addrs && entry &&
stx_cache_entry_insert(_stx_dns_cache, entry) == 0) {
stx_cache_entry_release(_stx_dns_cache, entry);
return;
}
if (entry)
stx_cache_entry_delete(_stx_dns_cache, entry);
else
cleanup_entry(key, data);
}
}
int _stx_dns_cache_getaddrlist(const char *hostname, struct in_addr *addrs,
int *num_addrs, st_utime_t timeout,
int rotate)
{
char host[128];
int n, count;
if (!_stx_dns_cache)
return _stx_dns_getaddrlist(hostname, addrs, num_addrs, timeout);
for (n = 0; n < sizeof(host) - 1 && hostname[n]; n++) {
host[n] = tolower(hostname[n]);
}
host[n] = '\0';
if (lookup_entry(host, addrs, num_addrs, rotate))
return 0;
count = MAX_HOST_ADDRS;
if (_stx_dns_getaddrlist(host, addr_list, &count, timeout) < 0)
return -1;
n = STX_MIN(*num_addrs, count);
memcpy(addrs, addr_list, n * sizeof(*addrs));
*num_addrs = n;
insert_entry(host, addr_list, count);
return 0;
}
int stx_dns_cache_init(size_t max_size, size_t max_bytes, size_t hash_size)
{
_stx_dns_cache = stx_cache_create(max_size, max_bytes, hash_size,
hash_hostname,
(long (*)(const void *, const void *))strcmp,
cleanup_entry);
if (!_stx_dns_cache)
return -1;
return 0;
}
void stx_dns_cache_getinfo(stx_cache_info_t *info)
{
if (_stx_dns_cache)
stx_cache_getinfo(_stx_dns_cache, info);
else
memset(info, 0, sizeof(stx_cache_info_t));
}
int stx_dns_getaddrlist(const char *hostname, struct in_addr *addrs,
int *num_addrs, st_utime_t timeout)
{
return _stx_dns_cache_getaddrlist(hostname, addrs, num_addrs, timeout, 0);
}
int stx_dns_getaddr(const char *hostname, struct in_addr *addr,
st_utime_t timeout)
{
int n = 1;
return _stx_dns_cache_getaddrlist(hostname, addr, &n, timeout, 1);
}

View file

@ -0,0 +1,305 @@
/*
* Copyright (c) 1985, 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Portions created by SGI are Copyright (C) 2000 Silicon Graphics, Inc.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Silicon Graphics, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "stx.h"
#define MAXPACKET 1024
#if !defined(NETDB_INTERNAL) && defined(h_NETDB_INTERNAL)
#define NETDB_INTERNAL h_NETDB_INTERNAL
#endif
/* New in Solaris 7 */
#if !defined(_getshort) && defined(ns_get16)
#define _getshort(cp) ns_get16(cp)
#define _getlong(cp) ns_get32(cp)
#endif
typedef union {
HEADER hdr;
u_char buf[MAXPACKET];
} querybuf_t;
int _stx_dns_ttl;
static int parse_answer(querybuf_t *ans, int len, struct in_addr *addrs,
int *num_addrs)
{
char buf[MAXPACKET];
HEADER *ahp;
u_char *cp, *eoa;
int type, n, i;
ahp = &ans->hdr;
eoa = ans->buf + len;
cp = ans->buf + sizeof(HEADER);
h_errno = TRY_AGAIN;
_stx_dns_ttl = -1;
i = 0;
while (ahp->qdcount > 0) {
ahp->qdcount--;
cp += dn_skipname(cp, eoa) + QFIXEDSZ;
}
while (ahp->ancount > 0 && cp < eoa && i < *num_addrs) {
ahp->ancount--;
if ((n = dn_expand(ans->buf, eoa, cp, buf, sizeof(buf))) < 0)
return -1;
cp += n;
if (cp + 4 + 4 + 2 >= eoa)
return -1;
type = _getshort(cp);
cp += 4;
if (type == T_A)
_stx_dns_ttl = _getlong(cp);
cp += 4;
n = _getshort(cp);
cp += 2;
if (type == T_A) {
if (n > sizeof(*addrs) || cp + n > eoa)
return -1;
memcpy(&addrs[i++], cp, n);
}
cp += n;
}
*num_addrs = i;
return 0;
}
static int query_domain(st_netfd_t nfd, const char *name,
struct in_addr *addrs, int *num_addrs,
st_utime_t timeout)
{
querybuf_t qbuf;
u_char *buf = qbuf.buf;
HEADER *hp = &qbuf.hdr;
int blen = sizeof(qbuf);
int i, len, id;
for (i = 0; i < _res.nscount; i++) {
len = res_mkquery(QUERY, name, C_IN, T_A, NULL, 0, NULL, buf, blen);
if (len <= 0) {
h_errno = NO_RECOVERY;
return -1;
}
id = hp->id;
if (st_sendto(nfd, buf, len, (struct sockaddr *)&(_res.nsaddr_list[i]),
sizeof(struct sockaddr), timeout) != len) {
h_errno = NETDB_INTERNAL;
/* EINTR means interrupt by other thread, NOT by a caught signal */
if (errno == EINTR)
return -1;
continue;
}
/* Wait for reply */
do {
len = st_recvfrom(nfd, buf, blen, NULL, NULL, timeout);
if (len <= 0)
break;
} while (id != hp->id);
if (len < HFIXEDSZ) {
h_errno = NETDB_INTERNAL;
if (len >= 0)
errno = EMSGSIZE;
else if (errno == EINTR) /* see the comment above */
return -1;
continue;
}
hp->ancount = ntohs(hp->ancount);
hp->qdcount = ntohs(hp->qdcount);
if ((hp->rcode != NOERROR) || (hp->ancount == 0)) {
switch (hp->rcode) {
case NXDOMAIN:
h_errno = HOST_NOT_FOUND;
break;
case SERVFAIL:
h_errno = TRY_AGAIN;
break;
case NOERROR:
h_errno = NO_DATA;
break;
case FORMERR:
case NOTIMP:
case REFUSED:
default:
h_errno = NO_RECOVERY;
}
continue;
}
if (parse_answer(&qbuf, len, addrs, num_addrs) == 0)
return 0;
}
return -1;
}
#define CLOSE_AND_RETURN(ret) \
{ \
n = errno; \
st_netfd_close(nfd); \
errno = n; \
return (ret); \
}
int _stx_dns_getaddrlist(const char *host, struct in_addr *addrs,
int *num_addrs, st_utime_t timeout)
{
char name[MAXDNAME], **domain;
const char *cp;
int s, n, maxlen, dots;
int trailing_dot, tried_as_is;
st_netfd_t nfd;
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
h_errno = NETDB_INTERNAL;
return -1;
}
if (_res.options & RES_USEVC) {
h_errno = NETDB_INTERNAL;
errno = ENOSYS;
return -1;
}
if (!host || *host == '\0') {
h_errno = HOST_NOT_FOUND;
return -1;
}
/* Create UDP socket */
if ((s = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
h_errno = NETDB_INTERNAL;
return -1;
}
if ((nfd = st_netfd_open_socket(s)) == NULL) {
h_errno = NETDB_INTERNAL;
n = errno;
close(s);
errno = n;
return -1;
}
maxlen = sizeof(name) - 1;
n = 0;
dots = 0;
trailing_dot = 0;
tried_as_is = 0;
for (cp = host; *cp && n < maxlen; cp++) {
dots += (*cp == '.');
name[n++] = *cp;
}
if (name[n - 1] == '.')
trailing_dot = 1;
/*
* If there are dots in the name already, let's just give it a try
* 'as is'. The threshold can be set with the "ndots" option.
*/
if (dots >= _res.ndots) {
if (query_domain(nfd, host, addrs, num_addrs, timeout) == 0)
CLOSE_AND_RETURN(0);
if (h_errno == NETDB_INTERNAL && errno == EINTR)
CLOSE_AND_RETURN(-1);
tried_as_is = 1;
}
/*
* We do at least one level of search if
* - there is no dot and RES_DEFNAME is set, or
* - there is at least one dot, there is no trailing dot,
* and RES_DNSRCH is set.
*/
if ((!dots && (_res.options & RES_DEFNAMES)) ||
(dots && !trailing_dot && (_res.options & RES_DNSRCH))) {
name[n++] = '.';
for (domain = _res.dnsrch; *domain; domain++) {
strncpy(name + n, *domain, maxlen - n);
if (query_domain(nfd, name, addrs, num_addrs, timeout) == 0)
CLOSE_AND_RETURN(0);
if (h_errno == NETDB_INTERNAL && errno == EINTR)
CLOSE_AND_RETURN(-1);
if (!(_res.options & RES_DNSRCH))
break;
}
}
/*
* If we have not already tried the name "as is", do that now.
* note that we do this regardless of how many dots were in the
* name or whether it ends with a dot.
*/
if (!tried_as_is) {
if (query_domain(nfd, host, addrs, num_addrs, timeout) == 0)
CLOSE_AND_RETURN(0);
}
CLOSE_AND_RETURN(-1);
}

View file

@ -0,0 +1,343 @@
#include "stx.h"
#include "common.h"
/*****************************************
* Basic types definitions
*/
struct _stx_centry {
void *key; /* key for doing lookups */
void *data; /* data in the cache */
size_t weight; /* "weight" of this entry */
struct _stx_centry *next; /* next entry */
struct _stx_centry **pthis;
stx_clist_t lru_link; /* for putting this entry on LRU list */
int ref_count; /* use count for this entry */
int delete_pending; /* pending delete flag */
};
struct _stx_cache {
size_t max_size; /* max size of cache */
size_t cur_size; /* current size of cache */
size_t max_weight; /* cache capacity */
size_t cur_weight; /* current total "weight" of all entries */
size_t hash_size; /* size of hash table */
stx_cache_entry_t **table; /* hash table for this cache */
stx_clist_t lru_list; /* least-recently-used list */
/* Cache stats */
unsigned long hits; /* num cache hits */
unsigned long lookups; /* num cache lookups */
unsigned long inserts; /* num inserts */
unsigned long deletes; /* num deletes */
/* Functions */
unsigned long (*key_hash_fn)(const void *);
long (*key_cmp_fn)(const void *, const void *);
void (*cleanup_fn)(void *, void *);
};
#define STX_CACHE_ENTRY_PTR(_qp) \
((stx_cache_entry_t *)((char *)(_qp) - offsetof(stx_cache_entry_t, lru_link)))
/*****************************************
* Cache methods
*/
stx_cache_t *stx_cache_create(size_t max_size, size_t max_weight,
size_t hash_size,
unsigned long (*key_hash_fn)(const void *key),
long (*key_cmp_fn)(const void *key1,
const void *key2),
void (*cleanup_fn)(void *key, void *data))
{
stx_cache_t *newcache;
newcache = (stx_cache_t *)calloc(1, sizeof(stx_cache_t));
if (newcache == NULL)
return NULL;
newcache->table = (stx_cache_entry_t **)calloc(hash_size,
sizeof(stx_cache_entry_t *));
if (newcache->table == NULL) {
free(newcache);
return NULL;
}
newcache->max_size = max_size;
newcache->max_weight = max_weight;
newcache->hash_size = hash_size;
STX_CLIST_INIT_CLIST(&(newcache->lru_list));
newcache->key_hash_fn = key_hash_fn;
newcache->key_cmp_fn = key_cmp_fn;
newcache->cleanup_fn = cleanup_fn;
return newcache;
}
void stx_cache_empty(stx_cache_t *cache)
{
size_t i;
stx_cache_entry_t *entry, *next_entry;
for (i = 0; i < cache->hash_size; i++) {
entry = cache->table[i];
while (entry) {
next_entry = entry->next;
stx_cache_entry_delete(cache, entry);
entry = next_entry;
}
}
}
void stx_cache_traverse(stx_cache_t *cache,
void (*callback)(void *key, void *data))
{
size_t i;
stx_cache_entry_t *entry;
for (i = 0; i < cache->hash_size; i++) {
for (entry = cache->table[i]; entry; entry = entry->next) {
if (!entry->delete_pending)
(*callback)(entry->key, entry->data);
}
}
}
void stx_cache_traverse_lru(stx_cache_t *cache,
void (*callback)(void *key, void *data),
unsigned int n)
{
stx_clist_t *q;
stx_cache_entry_t *entry;
for (q = STX_CLIST_HEAD(&cache->lru_list); q != &cache->lru_list && n;
q = q->next, n--) {
entry = STX_CACHE_ENTRY_PTR(q);
(*callback)(entry->key, entry->data);
}
}
void stx_cache_traverse_mru(stx_cache_t *cache,
void (*callback)(void *key, void *data),
unsigned int n)
{
stx_clist_t *q;
stx_cache_entry_t *entry;
for (q = STX_CLIST_TAIL(&cache->lru_list); q != &cache->lru_list && n;
q = q->prev, n--) {
entry = STX_CACHE_ENTRY_PTR(q);
(*callback)(entry->key, entry->data);
}
}
size_t stx_cache_getsize(stx_cache_t *cache)
{
return cache->cur_size;
}
size_t stx_cache_getweight(stx_cache_t *cache)
{
return cache->cur_weight;
}
void stx_cache_getinfo(stx_cache_t *cache, stx_cache_info_t *info)
{
info->max_size = cache->max_size;
info->max_weight = cache->max_weight;
info->hash_size = cache->hash_size;
info->cur_size = cache->cur_size;
info->cur_weight = cache->cur_weight;
info->hits = cache->hits;
info->lookups = cache->lookups;
info->inserts = cache->inserts;
info->deletes = cache->deletes;
}
/*****************************************
* Cache entry methods
*/
stx_cache_entry_t *stx_cache_entry_create(void *key, void *data,
size_t weight)
{
stx_cache_entry_t *newentry;
newentry = (stx_cache_entry_t *)calloc(1, sizeof(stx_cache_entry_t));
if (newentry == NULL)
return NULL;
newentry->key = key;
newentry->data = data;
newentry->weight = weight;
return newentry;
}
void stx_cache_entry_delete(stx_cache_t *cache, stx_cache_entry_t *entry)
{
entry->delete_pending = 1;
if (entry->ref_count > 0)
return;
if (entry->pthis) {
*entry->pthis = entry->next;
if (entry->next)
entry->next->pthis = entry->pthis;
cache->cur_size--;
cache->cur_weight -= entry->weight;
cache->deletes++;
STX_CLIST_REMOVE_LINK(&(entry->lru_link));
}
if (cache->cleanup_fn)
cache->cleanup_fn(entry->key, entry->data);
entry->pthis = NULL;
entry->key = NULL;
entry->data = NULL;
free(entry);
}
stx_cache_entry_t *stx_cache_entry_lookup(stx_cache_t *cache, const void *key)
{
unsigned long bucket;
stx_cache_entry_t *entry;
cache->lookups++;
bucket = cache->key_hash_fn(key) % cache->hash_size;
for (entry = cache->table[bucket]; entry; entry = entry->next) {
if (!entry->delete_pending && cache->key_cmp_fn(key, entry->key) == 0)
break;
}
if (entry) {
cache->hits++;
if (entry->ref_count == 0)
STX_CLIST_REMOVE_LINK(&(entry->lru_link));
entry->ref_count++;
}
return entry;
}
void stx_cache_entry_release(stx_cache_t *cache, stx_cache_entry_t *entry)
{
if (entry->ref_count == 0)
return;
entry->ref_count--;
if (entry->ref_count == 0) {
STX_CLIST_APPEND_LINK(&(entry->lru_link), &(cache->lru_list));
if (entry->delete_pending)
stx_cache_entry_delete(cache, entry);
}
}
int stx_cache_entry_insert(stx_cache_t *cache, stx_cache_entry_t *entry)
{
stx_cache_entry_t *old_entry;
unsigned long bucket;
/*
* If cache capacity is exceeded, try to remove LRU entries till there is
* enough room or LRU list is empty.
*/
while (cache->cur_weight + entry->weight > cache->max_weight) {
old_entry = stx_cache_entry_getlru(cache);
if (!old_entry) {
/* cache capacity is exceeded and all entries are in use */
return -1;
}
stx_cache_entry_delete(cache, old_entry);
}
/* If cache size is exceeded, remove LRU entry */
if (cache->cur_size >= cache->max_size) {
old_entry = stx_cache_entry_getlru(cache);
if (!old_entry) {
/* cache size is exceeded and all entries are in use */
return -1;
}
stx_cache_entry_delete(cache, old_entry);
}
/* Don't add duplicate entries in the cache */
bucket = cache->key_hash_fn(entry->key) % cache->hash_size;
for (old_entry = cache->table[bucket]; old_entry;
old_entry = old_entry->next) {
if (!old_entry->delete_pending &&
cache->key_cmp_fn(entry->key, old_entry->key) == 0)
break;
}
if (old_entry)
stx_cache_entry_delete(cache, old_entry);
/* Insert in the hash table */
entry->next = cache->table[bucket];
cache->table[bucket] = entry;
entry->pthis = &cache->table[bucket];
if (entry->next)
entry->next->pthis = &entry->next;
entry->ref_count++;
cache->inserts++;
cache->cur_size++;
cache->cur_weight += entry->weight;
return 0;
}
stx_cache_entry_t *stx_cache_entry_getlru(stx_cache_t *cache)
{
if (STX_CLIST_IS_EMPTY(&(cache->lru_list)))
return NULL;
return STX_CACHE_ENTRY_PTR(STX_CLIST_HEAD(&(cache->lru_list)));
}
int stx_cache_entry_sizeof(void)
{
return (int)sizeof(stx_cache_entry_t);
}
void *stx_cache_entry_getdata(stx_cache_entry_t *entry)
{
return entry->data;
}
void *stx_cache_entry_getkey(stx_cache_entry_t *entry)
{
return entry->key;
}
size_t stx_cache_entry_getweight(stx_cache_entry_t *entry)
{
return entry->weight;
}

View file

@ -0,0 +1,367 @@
Michael Abd-El-Malek contributed this patch. He wrote:
----------------------------------------
Hello,
This is a patch that enables programmatically dumping the stack of
every thread. This has been useful in debugging deadlocks, etc...
Our usage model is that the SIGUSR2 handler calls the new
_st_print_thread_stacks function, which dumps the stack for all
threads. A convenient feature is that for thread stacks that are the
same (which is common for application with a lot of worker threads
waiting for work), only one stack trace is printed, along with a
count of how many threads have that same stack.
I use the glibc backtrace function to get the backtrace, and then use
popen to execute addr2line and convert memory addresses to file
names, function names, and line numbers. If glibc isn't available,
_st_print_thread_stacks just prints a warning. And this feature is
only available if DEBUG is turned on.
We've found this feature extremely helpful when debugging.
The patch can be a bit more robust (it assumes addr2line exists).
But I didn't want to go through the hassle of doing this, if the
StateThreads community doesn't want to use this patch. (In our
environment, addr2line will always be there.)
Cheers,
Mike
----------------------------------------
Invoking complex functions from a signal handler is not recommended,
plus this patch changes the behavior of existing API hooks. It will
not become part of State Threads proper but you may find it useful
nonetheless. This patch applies to st-1.5.2.
diff -Nur Makefile.1.5.2 Makefile
--- Makefile.1.5.2 Wed Sep 7 14:19:50 2005
+++ Makefile Wed Sep 7 14:33:08 2005
@@ -255,7 +255,8 @@
$(TARGETDIR)/stk.o \
$(TARGETDIR)/sync.o \
$(TARGETDIR)/key.o \
- $(TARGETDIR)/io.o
+ $(TARGETDIR)/io.o \
+ $(TARGETDIR)/backtrace.o
OBJS += $(EXTRA_OBJS)
HEADER = $(TARGETDIR)/st.h
SLIBRARY = $(TARGETDIR)/libst.a
diff -Nur backtrace.c.1.5.2 backtrace.c
--- backtrace.c.1.5.2 Wed Dec 31 16:00:00 1969
+++ backtrace.c Wed Sep 7 13:40:21 2005
@@ -0,0 +1,211 @@
+/*
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Contributor(s): Michael Abd-El-Malek (mabdelmalek@cmu.edu)
+ * Carnegie Mellon University
+ *
+ * Alternatively, the contents of this file may be used under the
+ * terms of the GNU General Public License Version 2 or later (the
+ * "GPL"), in which case the provisions of the GPL are applicable
+ * instead of those above. If you wish to allow use of your
+ * version of this file only under the terms of the GPL and not to
+ * allow others to use your version of this file under the MPL,
+ * indicate your decision by deleting the provisions above and
+ * replace them with the notice and other provisions required by
+ * the GPL. If you do not delete the provisions above, a recipient
+ * may use your version of this file under either the MPL or the
+ * GPL.
+ */
+
+
+
+/*
+ * This file contains routines for printing a stack trace of all threads.
+ * Only works when DEBUG is defined and where glibc is available, since it
+ * provides the backtrace() function.
+ */
+
+#define _GNU_SOURCE /* to get program_invocation_name */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+
+#if defined(DEBUG) && defined(__GLIBC__)
+
+#include <errno.h>
+#include "common.h"
+#include <execinfo.h>
+#include <inttypes.h>
+#include <string.h>
+
+
+/* The maximum number of frames to get a stack trace for. If a thread has more
+ * frames than this, then we only show the latest X frames. */
+#define MAX_NUM_FRAMES 64
+
+
+typedef struct thread_stack_s {
+ uint32_t num_frames;
+ void* addresses[MAX_NUM_FRAMES]; /* frame pointers */
+ char* locations[MAX_NUM_FRAMES]; /* file/function/line numbers */
+ uint32_t num_matches;
+
+ struct thread_stack_s* next;
+} thread_stack_t;
+
+static thread_stack_t* stacks = NULL;
+
+
+/* Converts the function's memory addresses to function names, file names, and
+ * line numbers. Calls binutil's addr2line program. */
+static void get_symbol_names(thread_stack_t *stack)
+{
+ char program_to_run[1024], function[256], filename_lineno[256], temp[19];
+ FILE* output;
+ int num_bytes_left;
+ uint32_t i;
+
+ /* Construct the arguments to addr2line */
+ num_bytes_left = sizeof(program_to_run);
+ num_bytes_left -= snprintf(program_to_run, sizeof(program_to_run),
+ "addr2line -fCe %s", program_invocation_name);
+ for (i = 0; i < stack->num_frames && num_bytes_left > 0; ++i) {
+ num_bytes_left -= snprintf(temp, sizeof(temp), " %p", stack->addresses[i]);
+ strncat(program_to_run, temp, num_bytes_left);
+ }
+
+ /* Use popen to execute addr2line and read its ouput */
+ output = popen(program_to_run, "r");
+ for (i = 0; i < stack->num_frames; ++i) {
+ char* function_listing = (char*) malloc(512);
+ fscanf(output, "%255s\n", function);
+ fscanf(output, "%255s\n", filename_lineno);
+ snprintf(function_listing, 512, "%s at %s", function, filename_lineno);
+ stack->locations[i] = function_listing;
+ }
+ pclose(output);
+}
+
+
+static void print_stack(thread_stack_t* stack)
+{
+ int skip_offset = 0, cmp_len;
+ uint32_t i;
+
+ /* Get the function names/filenames/line numbers */
+ get_symbol_names(stack);
+
+ cmp_len = strlen("_st_iterate_threads_helper");
+
+ /* Print the backtrace */
+ for (i = 0; i < stack->num_frames; ++i) {
+ /* Skip frames we don't have location info for */
+ if (!strncmp(stack->locations[i], "??", 2)) {
+ continue;
+ }
+
+ /* Skip the frames that are used for printing the stack trace */
+ if (skip_offset) {
+ printf("\t#%2d %s %p\n", i - skip_offset, stack->locations[i],
+ stack->addresses[i]);
+ } else if (!strncmp(stack->locations[i], "_st_iterate_threads_helper",
+ cmp_len)) {
+ skip_offset = i + 1;
+ }
+ }
+}
+
+
+static void add_current_thread_stack(void)
+{
+ thread_stack_t *new_stack = malloc(sizeof(thread_stack_t));
+ thread_stack_t *search;
+
+ /* Call glibc function to get the backtrace */
+ new_stack->num_frames = backtrace(new_stack->addresses, MAX_NUM_FRAMES);
+
+ /* Check if we have another stacks that is equivalent. If so, then coaelsce
+ * two stacks into one, to minimize output to user. */
+ search = stacks;
+ while (search) {
+ if (search->num_frames == new_stack->num_frames &&
+ !memcmp(search->addresses, new_stack->addresses,
+ search->num_frames * sizeof(void*))) {
+ /* Found an existing stack that is the same as this thread's stack */
+ ++search->num_matches;
+ free(new_stack);
+ return;
+ } else {
+ search = search->next;
+ }
+ }
+
+ /* This is a new stack. Add it to the list of stacks. */
+ new_stack->num_matches = 1;
+ new_stack->next = stacks;
+ stacks = new_stack;
+}
+
+static void print_stack_frames(void)
+{
+ while (stacks) {
+ printf("\n%u thread(s) with this backtrace:\n", stacks->num_matches);
+ print_stack(stacks);
+ stacks = stacks->next;
+ }
+ printf("\n");
+}
+
+static void free_stacks(void)
+{
+ uint32_t i;
+ while (stacks) {
+ thread_stack_t *next = stacks->next;
+ for (i = 0; i < stacks->num_frames; ++i) {
+ free(stacks->locations[i]);
+ }
+ free(stacks);
+ stacks = next;
+ }
+ stacks = NULL;
+}
+
+
+static void st_print_thread_stack(_st_thread_t *thread, int start_flag,
+ int end_flag)
+{
+ if (end_flag == 0) {
+ add_current_thread_stack();
+ } else {
+ print_stack_frames();
+ }
+}
+
+
+void _st_print_thread_stacks(int ignore)
+{
+ _st_iterate_threads_flag = 1;
+ _st_iterate_threads_helper(st_print_thread_stack);
+ _st_iterate_threads_flag = 0;
+
+ /* Deallocate memory */
+ free_stacks();
+}
+
+#else /* defined(DEBUG) && defined(__GLIBC__) */
+
+void _st_print_thread_stacks(int ignore)
+{
+ printf("%s: need DEBUG mode and glibc-specific functions to read stack.\n",
+ __FUNCTION__);
+}
+#endif /* defined(DEBUG) && defined(__GLIBC__) */
diff -Nur common.h.1.5.2 common.h
--- common.h.1.5.2 Wed Sep 7 14:18:37 2005
+++ common.h Wed Sep 7 14:35:36 2005
@@ -371,8 +371,18 @@
*/
#ifdef DEBUG
-void _st_iterate_threads(void);
-#define ST_DEBUG_ITERATE_THREADS() _st_iterate_threads()
+typedef void(*_st_func_ptr_t)(_st_thread_t *thread,
+ int start_flag,
+ int end_flag);
+/* Pointer to function that will be called on thread switch */
+extern _st_func_ptr_t _st_iterate_func_ptr;
+extern int _st_iterate_threads_flag;
+/* Thread iteration function that will call an arbitrary function */
+extern void _st_iterate_threads_helper(_st_func_ptr_t func);
+#define ST_DEBUG_ITERATE_THREADS() \
+ if (_st_iterate_func_ptr) { \
+ _st_iterate_threads_helper(_st_iterate_func_ptr); \
+ }
#else
#define ST_DEBUG_ITERATE_THREADS()
#endif
diff -Nur public.h.1.5.2 public.h
--- public.h.1.5.2 Wed Sep 7 11:46:58 2005
+++ public.h Wed Sep 7 13:38:46 2005
@@ -171,8 +171,10 @@
extern st_netfd_t st_open(const char *path, int oflags, mode_t mode);
#ifdef DEBUG
-extern void _st_show_thread_stack(st_thread_t thread, const char *messg);
+extern void _st_show_thread_stack(st_thread_t thread, int start_flag,
+ int end_flag);
extern void _st_iterate_threads(void);
+extern void _st_print_thread_stacks(int ignore);
#endif
#ifdef __cplusplus
diff -Nur sched.c.1.5.2 sched.c
--- sched.c.1.5.2 Wed Sep 7 10:48:05 2005
+++ sched.c Wed Sep 7 13:38:46 2005
@@ -919,16 +919,13 @@
#ifdef DEBUG
-/* ARGSUSED */
-void _st_show_thread_stack(_st_thread_t *thread, const char *messg)
-{
-
-}
-
/* To be set from debugger */
int _st_iterate_threads_flag = 0;
+/* Thread iteration function that will call an arbitrary function */
+_st_func_ptr_t _st_iterate_func_ptr = NULL;
-void _st_iterate_threads(void)
+/* This function iterates over all threads, calling "func" for each thread. */
+void _st_iterate_threads_helper(_st_func_ptr_t func)
{
static _st_thread_t *thread = NULL;
static jmp_buf orig_jb, save_jb;
@@ -944,16 +941,20 @@
if (thread) {
memcpy(thread->context, save_jb, sizeof(jmp_buf));
- _st_show_thread_stack(thread, NULL);
+ func(thread, 0, 0);
} else {
if (MD_SETJMP(orig_jb)) {
_st_iterate_threads_flag = 0;
+ _st_iterate_func_ptr = NULL;
thread = NULL;
- _st_show_thread_stack(thread, "Iteration completed");
+ /* Last thread to iterate through */
+ func(thread, 0, 1);
return;
}
+ /* First thread to iterate through */
thread = _ST_CURRENT_THREAD();
- _st_show_thread_stack(thread, "Iteration started");
+ _st_iterate_func_ptr = func;
+ func(thread, 1, 0);
}
q = thread->tlink.next;
@@ -966,5 +967,17 @@
memcpy(save_jb, thread->context, sizeof(jmp_buf));
MD_LONGJMP(thread->context, 1);
}
+
+/* ARGSUSED */
+void _st_show_thread_stack(_st_thread_t *thread, int start_flag, int end_flag)
+{
+}
+
+/* Iterate over threads inside debugger; see st/README */
+void _st_iterate_threads(void)
+{
+ _st_iterate_threads_helper(_st_show_thread_stack);
+}
+
#endif /* DEBUG */

91
trunk/3rdparty/st-srs/extensions/stx.h vendored Normal file
View file

@ -0,0 +1,91 @@
#ifndef _STX_H_
#define _STX_H_
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <netdb.h>
#include <errno.h>
#include "st.h"
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************
* Basic types definitions
*/
typedef struct _stx_centry stx_cache_entry_t;
typedef struct _stx_cache stx_cache_t;
/* This is public type */
typedef struct _stx_cache_info {
size_t max_size;
size_t max_weight;
size_t hash_size;
size_t cur_size;
size_t cur_weight;
unsigned long hits;
unsigned long lookups;
unsigned long inserts;
unsigned long deletes;
} stx_cache_info_t;
/*****************************************
* Cache and cache entry methods
*/
stx_cache_t *stx_cache_create(size_t max_size, size_t max_weight,
size_t hash_size,
unsigned long (*key_hash_fn)(const void *key),
long (*key_cmp_fn)(const void *key1,
const void *key2),
void (*cleanup_fn)(void *key, void *data));
void stx_cache_empty(stx_cache_t *cache);
void stx_cache_traverse(stx_cache_t *cache,
void (*callback)(void *key, void *data));
void stx_cache_traverse_lru(stx_cache_t *, void (*)(void *, void *),
unsigned int);
void stx_cache_traverse_mru(stx_cache_t *, void (*)(void *, void *),
unsigned int);
void stx_cache_getinfo(stx_cache_t *cache, stx_cache_info_t *info);
size_t stx_cache_getsize(stx_cache_t *cache);
size_t stx_cache_getweight(stx_cache_t *cache);
stx_cache_entry_t *stx_cache_entry_create(void *key, void *data,
size_t weight);
void stx_cache_entry_delete(stx_cache_t *cache, stx_cache_entry_t *entry);
stx_cache_entry_t *stx_cache_entry_lookup(stx_cache_t *cache, const void *key);
void stx_cache_entry_release(stx_cache_t *, stx_cache_entry_t *);
int stx_cache_entry_insert(stx_cache_t *cache, stx_cache_entry_t *entry);
stx_cache_entry_t *stx_cache_entry_getlru(stx_cache_t *cache);
int stx_cache_entry_sizeof(void);
void *stx_cache_entry_getdata(stx_cache_entry_t *entry);
void *stx_cache_entry_getkey(stx_cache_entry_t *entry);
size_t stx_cache_entry_getweight(stx_cache_entry_t *entry);
int stx_dns_cache_init(size_t max_size, size_t max_bytes, size_t hash_size);
void stx_dns_cache_getinfo(stx_cache_info_t *info);
int stx_dns_getaddrlist(const char *hostname, struct in_addr *addrs,
int *num_addrs, st_utime_t timeout);
int stx_dns_getaddr(const char *hostname, struct in_addr *addr,
st_utime_t timeout);
#ifdef __cplusplus
}
#endif
#endif /* !_STX_H_ */

View file

@ -0,0 +1,197 @@
/*
* File I/O extension to the State Threads Library.
*/
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the file I/O extension to the State Threads Library.
*
* The Initial Developer of the Original Code is Jeff
* <jlb-st@houseofdistraction.com>. Portions created by the Initial
* Developer are Copyright (C) 2002 the Initial Developer. All Rights
* Reserved.
*
* Contributor(s): (none)
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 or later (the
* "GPL"), in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your
* version of this file only under the terms of the GPL and not to
* allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
#include <stdlib.h>
#include "stx_fileio.h"
#define STX_FILEIO_SIGNUM SIGUSR2
typedef struct {
st_netfd_t data_fd;
st_netfd_t control_fd;
pid_t pid;
} fileio_data_t;
#define FILEREADER_MAX_READ 1024
typedef struct {
off_t offset;
ssize_t nbytes;
} file_reader_cb_t;
/**
* Fork a process to read a file and return its pid. Receives
* offset/length commands from control stream and sends corresponding data
* to out stream. A zero length on the control stream signals an end.
*
* @param fd stream from which to read
* @param control_out receives the file descriptor to which control commands can be sent
* @param fd_out receives the file descriptor from which the output of the command can be read.
* @return PID of the process created to execute the command
*/
pid_t
file_reader(int fd, int *fd_control, int *fd_out)
{
pid_t pid;
int control_pipe[2], out_pipe[2];
if (pipe(control_pipe) < 0 || pipe(out_pipe) < 0)
return (pid_t)-1;
pid = fork();
if (pid == (pid_t) -1)
{
close(control_pipe[0]);
close(control_pipe[1]);
close(out_pipe[0]);
close(out_pipe[1]);
return pid;
}
else if (pid == (pid_t) 0)
{
// child
off_t pos = 0;
file_reader_cb_t cb;
char buf[FILEREADER_MAX_READ];
if (fd == -1)
_exit(EXIT_FAILURE);
while (sizeof(cb) == read(control_pipe[0], &cb, sizeof(cb))) {
ssize_t nb;
if (0 >= cb.nbytes)
goto clean_exit;
if (pos != cb.offset) {
pos = lseek(fd, cb.offset, SEEK_SET);
if (pos == (off_t)-1)
break;
}
nb = read(fd, buf, cb.nbytes);
if (nb == (ssize_t)-1)
break;
pos += nb;
write(out_pipe[1], (char *)&nb, sizeof(nb));
write(out_pipe[1], buf, nb);
}
perror("ERROR: file_reader: ");
clean_exit:
close(control_pipe[0]);
close(control_pipe[1]);
close(out_pipe[0]);
close(out_pipe[1]);
_exit(EXIT_SUCCESS);
}
// parent
close(out_pipe[1]);
close(control_pipe[0]);
*fd_out = out_pipe[0];
*fd_control = control_pipe[1];
return pid;
}
/**
* fileio_data_t destructor callback
*/
static void
fileio_data_destructor(void *dat_in)
{
if (dat_in) {
fileio_data_t *dat = (fileio_data_t *)dat_in;
file_reader_cb_t cb;
cb.offset = 0;
cb.nbytes = 0;
st_write(dat->control_fd, (char *)&cb, sizeof(cb),
ST_UTIME_NO_TIMEOUT);
waitpid(dat->pid, NULL, 0);
st_netfd_close(dat->control_fd);
st_netfd_close(dat->data_fd);
free(dat_in);
}
}
/**
* Retrieve fileio_data_t struct from an st descriptor. Create and store
* a new one if needed.
*/
static fileio_data_t *get_fileio_data(st_netfd_t fd)
{
fileio_data_t *dat = (fileio_data_t *)st_netfd_getspecific(fd);
if (!dat) {
int fd_control, fd_out;
pid_t pid = file_reader(st_netfd_fileno(fd), &fd_control, &fd_out);
if (pid != (pid_t)-1) {
dat = (fileio_data_t *)calloc(1, sizeof(fileio_data_t));
dat->control_fd = st_netfd_open(fd_control);
dat->data_fd = st_netfd_open(fd_out);
dat->pid = pid;
st_netfd_setspecific(fd, dat, fileio_data_destructor);
}
}
return dat;
}
/**
* Read data from the specified section of a file. Uses a forked
* file_reader process to do the actual reading so as to avoid causing all
* State Threads to block.
*
* @param fd must refer to a seekable file.
* @param offset absolute offset within the file
* @param buf output buffer
* @param nbytes size of the output buffer
* @param timeout
*/
ssize_t
stx_file_read(st_netfd_t fd, off_t offset, void *buf, size_t nbytes, st_utime_t timeout)
{
fileio_data_t *dat = get_fileio_data(fd);
if (dat) {
file_reader_cb_t cb;
ssize_t ret = (ssize_t)-1;
cb.offset = offset;
cb.nbytes = nbytes;
st_write(dat->control_fd, (char *)&cb, sizeof(cb), timeout);
if (sizeof(ret) == st_read(dat->data_fd, (char *)&ret, sizeof(ret), timeout) && 0 < ret && ret <= nbytes) {
return st_read(dat->data_fd, buf, ret, timeout);
} else {
return ret;
}
}
return (ssize_t)-1;
}

View file

@ -0,0 +1,52 @@
/*
* File I/O extension to the State Threads Library.
*/
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the file I/O extension to the State Threads Library.
*
* The Initial Developer of the Original Code is Jeff
* <jlb-st@houseofdistraction.com>. Portions created by the Initial
* Developer are Copyright (C) 2002 the Initial Developer. All Rights
* Reserved.
*
* Contributor(s): (none)
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 or later (the
* "GPL"), in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your
* version of this file only under the terms of the GPL and not to
* allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
#ifndef __STX_FILEIO_H__
#define __STX_FILEIO_H__
#include <st.h>
#ifdef __cplusplus
extern "C" {
#endif
extern ssize_t stx_file_read(st_netfd_t fd, off_t offset, void *buf, size_t nbytes, st_utime_t timeout);
#ifdef __cplusplus
}
#endif
#endif /* !__STX_FILEIO_H__ */

View file

@ -0,0 +1,112 @@
#include "stx.h"
#include <netinet/in.h>
#include <arpa/inet.h>
#define MAX_ADDRS 128
#define TIMEOUT (4*1000000LL)
static void do_resolve(const char *host)
{
struct in_addr addrs[MAX_ADDRS];
int i, n = MAX_ADDRS;
if (stx_dns_getaddrlist(host, addrs, &n, TIMEOUT) < 0) {
fprintf(stderr, "stx_dns_getaddrlist: can't resolve %s: ", host);
if (h_errno == NETDB_INTERNAL)
perror("");
else
herror("");
} else {
if (n > 0)
printf("%-40s %s\n", (char *)host, inet_ntoa(addrs[0]));
for (i = 1; i < n; i++)
printf("%-40s %s\n", "", inet_ntoa(addrs[i]));
}
}
static void show_info(void)
{
stx_cache_info_t info;
stx_dns_cache_getinfo(&info);
printf("DNS cache info:\n\n");
printf("max_size: %8d\n", (int)info.max_size);
printf("capacity: %8d bytes\n", (int)info.max_weight);
printf("hash_size: %8d\n", (int)info.hash_size);
printf("cur_size: %8d\n"
"cur_mem: %8d bytes\n"
"hits: %8d\n"
"lookups: %8d\n"
"inserts: %8d\n"
"deletes: %8d\n",
(int)info.cur_size, (int)info.cur_weight, (int)info.hits,
(int)info.lookups, (int)info.inserts, (int)info.deletes);
}
extern stx_cache_t *_stx_dns_cache;
static void printhost(void *host, void *data)
{
printf("%s\n", (char *)host);
}
static void show_lru(void)
{
printf("LRU hosts:\n\n");
stx_cache_traverse_lru(_stx_dns_cache, printhost, 10);
}
static void show_mru(void)
{
printf("MRU hosts:\n\n");
stx_cache_traverse_mru(_stx_dns_cache, printhost, 10);
}
static void flush_cache(void)
{
stx_cache_empty(_stx_dns_cache);
printf("DNS cache is empty\n");
}
int main()
{
char line[256];
char str[sizeof(line)];
st_init();
stx_dns_cache_init(100, 10000, 101);
for ( ; ; ) {
fputs("> ", stdout);
fflush(stdout);
if (!fgets(line, sizeof(line), stdin))
break;
if (sscanf(line, "%s", str) != 1)
continue;
if (strcmp(str, "exit") == 0 || strcmp(str, "quit") == 0)
break;
if (strcmp(str, "info") == 0) {
show_info();
continue;
}
if (strcmp(str, "lru") == 0) {
show_lru();
continue;
}
if (strcmp(str, "mru") == 0) {
show_mru();
continue;
}
if (strcmp(str, "flush") == 0) {
flush_cache();
continue;
}
do_resolve(str);
}
return 0;
}

769
trunk/3rdparty/st-srs/io.c vendored Normal file
View file

@ -0,0 +1,769 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Netscape Portable Runtime library.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1994-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s): Silicon Graphics, Inc.
*
* Portions created by SGI are Copyright (C) 2000-2001 Silicon
* Graphics, Inc. All Rights Reserved.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 or later (the
* "GPL"), in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your
* version of this file only under the terms of the GPL and not to
* allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
/*
* This file is derived directly from Netscape Communications Corporation,
* and consists of extensive modifications made during the year(s) 1999-2000.
*/
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/uio.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <fcntl.h>
#include <signal.h>
#include <errno.h>
#include "common.h"
#if EAGAIN != EWOULDBLOCK
#define _IO_NOT_READY_ERROR ((errno == EAGAIN) || (errno == EWOULDBLOCK))
#else
#define _IO_NOT_READY_ERROR (errno == EAGAIN)
#endif
#define _LOCAL_MAXIOV 16
/* File descriptor object free list */
static _st_netfd_t *_st_netfd_freelist = NULL;
/* Maximum number of file descriptors that the process can open */
static int _st_osfd_limit = -1;
static void _st_netfd_free_aux_data(_st_netfd_t *fd);
int _st_io_init(void)
{
struct sigaction sigact;
struct rlimit rlim;
int fdlim;
/* Ignore SIGPIPE */
sigact.sa_handler = SIG_IGN;
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = 0;
if (sigaction(SIGPIPE, &sigact, NULL) < 0)
return -1;
/* Set maximum number of open file descriptors */
if (getrlimit(RLIMIT_NOFILE, &rlim) < 0)
return -1;
fdlim = (*_st_eventsys->fd_getlimit)();
if (fdlim > 0 && rlim.rlim_max > (rlim_t) fdlim) {
rlim.rlim_max = fdlim;
}
/**
* by SRS, for osx.
* when rlimit max is negative, for example, osx, use cur directly.
* @see https://github.com/winlinvip/simple-rtmp-server/issues/336
*/
if ((int)rlim.rlim_max < 0) {
_st_osfd_limit = (int)(fdlim > 0? fdlim : rlim.rlim_cur);
return 0;
}
rlim.rlim_cur = rlim.rlim_max;
if (setrlimit(RLIMIT_NOFILE, &rlim) < 0)
return -1;
_st_osfd_limit = (int) rlim.rlim_max;
return 0;
}
int st_getfdlimit(void)
{
return _st_osfd_limit;
}
void st_netfd_free(_st_netfd_t *fd)
{
if (!fd->inuse)
return;
fd->inuse = 0;
if (fd->aux_data)
_st_netfd_free_aux_data(fd);
if (fd->private_data && fd->destructor)
(*(fd->destructor))(fd->private_data);
fd->private_data = NULL;
fd->destructor = NULL;
fd->next = _st_netfd_freelist;
_st_netfd_freelist = fd;
}
static _st_netfd_t *_st_netfd_new(int osfd, int nonblock, int is_socket)
{
_st_netfd_t *fd;
int flags = 1;
if ((*_st_eventsys->fd_new)(osfd) < 0)
return NULL;
if (_st_netfd_freelist) {
fd = _st_netfd_freelist;
_st_netfd_freelist = _st_netfd_freelist->next;
} else {
fd = calloc(1, sizeof(_st_netfd_t));
if (!fd)
return NULL;
}
fd->osfd = osfd;
fd->inuse = 1;
fd->next = NULL;
if (nonblock) {
/* Use just one system call */
if (is_socket && ioctl(osfd, FIONBIO, &flags) != -1)
return fd;
/* Do it the Posix way */
if ((flags = fcntl(osfd, F_GETFL, 0)) < 0 ||
fcntl(osfd, F_SETFL, flags | O_NONBLOCK) < 0) {
st_netfd_free(fd);
return NULL;
}
}
return fd;
}
_st_netfd_t *st_netfd_open(int osfd)
{
return _st_netfd_new(osfd, 1, 0);
}
_st_netfd_t *st_netfd_open_socket(int osfd)
{
return _st_netfd_new(osfd, 1, 1);
}
int st_netfd_close(_st_netfd_t *fd)
{
if ((*_st_eventsys->fd_close)(fd->osfd) < 0)
return -1;
st_netfd_free(fd);
return close(fd->osfd);
}
int st_netfd_fileno(_st_netfd_t *fd)
{
return (fd->osfd);
}
void st_netfd_setspecific(_st_netfd_t *fd, void *value, _st_destructor_t destructor)
{
if (value != fd->private_data) {
/* Free up previously set non-NULL data value */
if (fd->private_data && fd->destructor)
(*(fd->destructor))(fd->private_data);
}
fd->private_data = value;
fd->destructor = destructor;
}
void *st_netfd_getspecific(_st_netfd_t *fd)
{
return (fd->private_data);
}
/*
* Wait for I/O on a single descriptor.
*/
int st_netfd_poll(_st_netfd_t *fd, int how, st_utime_t timeout)
{
struct pollfd pd;
int n;
pd.fd = fd->osfd;
pd.events = (short) how;
pd.revents = 0;
if ((n = st_poll(&pd, 1, timeout)) < 0)
return -1;
if (n == 0) {
/* Timed out */
errno = ETIME;
return -1;
}
if (pd.revents & POLLNVAL) {
errno = EBADF;
return -1;
}
return 0;
}
#ifdef MD_ALWAYS_UNSERIALIZED_ACCEPT
/* No-op */
int st_netfd_serialize_accept(_st_netfd_t *fd)
{
fd->aux_data = NULL;
return 0;
}
/* No-op */
static void _st_netfd_free_aux_data(_st_netfd_t *fd)
{
fd->aux_data = NULL;
}
_st_netfd_t *st_accept(_st_netfd_t *fd, struct sockaddr *addr, int *addrlen, st_utime_t timeout)
{
int osfd, err;
_st_netfd_t *newfd;
while ((osfd = accept(fd->osfd, addr, (socklen_t *)addrlen)) < 0) {
if (errno == EINTR)
continue;
if (!_IO_NOT_READY_ERROR)
return NULL;
/* Wait until the socket becomes readable */
if (st_netfd_poll(fd, POLLIN, timeout) < 0)
return NULL;
}
/* On some platforms the new socket created by accept() inherits */
/* the nonblocking attribute of the listening socket */
#if defined (MD_ACCEPT_NB_INHERITED)
newfd = _st_netfd_new(osfd, 0, 1);
#elif defined (MD_ACCEPT_NB_NOT_INHERITED)
newfd = _st_netfd_new(osfd, 1, 1);
#else
#error Unknown OS
#endif
if (!newfd) {
err = errno;
close(osfd);
errno = err;
}
return newfd;
}
#else /* MD_ALWAYS_UNSERIALIZED_ACCEPT */
/*
* On some platforms accept() calls from different processes
* on the same listen socket must be serialized.
* The following code serializes accept()'s without process blocking.
* A pipe is used as an inter-process semaphore.
*/
int st_netfd_serialize_accept(_st_netfd_t *fd)
{
_st_netfd_t **p;
int osfd[2], err;
if (fd->aux_data) {
errno = EINVAL;
return -1;
}
if ((p = (_st_netfd_t **)calloc(2, sizeof(_st_netfd_t *))) == NULL)
return -1;
if (pipe(osfd) < 0) {
free(p);
return -1;
}
if ((p[0] = st_netfd_open(osfd[0])) != NULL && (p[1] = st_netfd_open(osfd[1])) != NULL && write(osfd[1], " ", 1) == 1) {
fd->aux_data = p;
return 0;
}
/* Error */
err = errno;
if (p[0])
st_netfd_free(p[0]);
if (p[1])
st_netfd_free(p[1]);
close(osfd[0]);
close(osfd[1]);
free(p);
errno = err;
return -1;
}
static void _st_netfd_free_aux_data(_st_netfd_t *fd)
{
_st_netfd_t **p = (_st_netfd_t **) fd->aux_data;
st_netfd_close(p[0]);
st_netfd_close(p[1]);
free(p);
fd->aux_data = NULL;
}
_st_netfd_t *st_accept(_st_netfd_t *fd, struct sockaddr *addr, int *addrlen, st_utime_t timeout)
{
int osfd, err;
_st_netfd_t *newfd;
_st_netfd_t **p = (_st_netfd_t **) fd->aux_data;
ssize_t n;
char c;
for ( ; ; ) {
if (p == NULL) {
osfd = accept(fd->osfd, addr, (socklen_t *)addrlen);
} else {
/* Get the lock */
n = st_read(p[0], &c, 1, timeout);
if (n < 0)
return NULL;
ST_ASSERT(n == 1);
/* Got the lock */
osfd = accept(fd->osfd, addr, (socklen_t *)addrlen);
/* Unlock */
err = errno;
n = st_write(p[1], &c, 1, timeout);
ST_ASSERT(n == 1);
errno = err;
}
if (osfd >= 0)
break;
if (errno == EINTR)
continue;
if (!_IO_NOT_READY_ERROR)
return NULL;
/* Wait until the socket becomes readable */
if (st_netfd_poll(fd, POLLIN, timeout) < 0)
return NULL;
}
/* On some platforms the new socket created by accept() inherits */
/* the nonblocking attribute of the listening socket */
#if defined (MD_ACCEPT_NB_INHERITED)
newfd = _st_netfd_new(osfd, 0, 1);
#elif defined (MD_ACCEPT_NB_NOT_INHERITED)
newfd = _st_netfd_new(osfd, 1, 1);
#else
#error Unknown OS
#endif
if (!newfd) {
err = errno;
close(osfd);
errno = err;
}
return newfd;
}
#endif /* MD_ALWAYS_UNSERIALIZED_ACCEPT */
int st_connect(_st_netfd_t *fd, const struct sockaddr *addr, int addrlen, st_utime_t timeout)
{
int n, err = 0;
while (connect(fd->osfd, addr, addrlen) < 0) {
if (errno != EINTR) {
/*
* On some platforms, if connect() is interrupted (errno == EINTR)
* after the kernel binds the socket, a subsequent connect()
* attempt will fail with errno == EADDRINUSE. Ignore EADDRINUSE
* iff connect() was previously interrupted. See Rich Stevens'
* "UNIX Network Programming," Vol. 1, 2nd edition, p. 413
* ("Interrupted connect").
*/
if (errno != EINPROGRESS && (errno != EADDRINUSE || err == 0))
return -1;
/* Wait until the socket becomes writable */
if (st_netfd_poll(fd, POLLOUT, timeout) < 0)
return -1;
/* Try to find out whether the connection setup succeeded or failed */
n = sizeof(int);
if (getsockopt(fd->osfd, SOL_SOCKET, SO_ERROR, (char *)&err, (socklen_t *)&n) < 0)
return -1;
if (err) {
errno = err;
return -1;
}
break;
}
err = 1;
}
return 0;
}
ssize_t st_read(_st_netfd_t *fd, void *buf, size_t nbyte, st_utime_t timeout)
{
ssize_t n;
while ((n = read(fd->osfd, buf, nbyte)) < 0) {
if (errno == EINTR)
continue;
if (!_IO_NOT_READY_ERROR)
return -1;
/* Wait until the socket becomes readable */
if (st_netfd_poll(fd, POLLIN, timeout) < 0)
return -1;
}
return n;
}
int st_read_resid(_st_netfd_t *fd, void *buf, size_t *resid, st_utime_t timeout)
{
struct iovec iov, *riov;
int riov_size, rv;
iov.iov_base = buf;
iov.iov_len = *resid;
riov = &iov;
riov_size = 1;
rv = st_readv_resid(fd, &riov, &riov_size, timeout);
*resid = iov.iov_len;
return rv;
}
ssize_t st_readv(_st_netfd_t *fd, const struct iovec *iov, int iov_size, st_utime_t timeout)
{
ssize_t n;
while ((n = readv(fd->osfd, iov, iov_size)) < 0) {
if (errno == EINTR)
continue;
if (!_IO_NOT_READY_ERROR)
return -1;
/* Wait until the socket becomes readable */
if (st_netfd_poll(fd, POLLIN, timeout) < 0)
return -1;
}
return n;
}
int st_readv_resid(_st_netfd_t *fd, struct iovec **iov, int *iov_size, st_utime_t timeout)
{
ssize_t n;
while (*iov_size > 0) {
if (*iov_size == 1)
n = read(fd->osfd, (*iov)->iov_base, (*iov)->iov_len);
else
n = readv(fd->osfd, *iov, *iov_size);
if (n < 0) {
if (errno == EINTR)
continue;
if (!_IO_NOT_READY_ERROR)
return -1;
} else if (n == 0)
break;
else {
while ((size_t) n >= (*iov)->iov_len) {
n -= (*iov)->iov_len;
(*iov)->iov_base = (char *) (*iov)->iov_base + (*iov)->iov_len;
(*iov)->iov_len = 0;
(*iov)++;
(*iov_size)--;
if (n == 0)
break;
}
if (*iov_size == 0)
break;
(*iov)->iov_base = (char *) (*iov)->iov_base + n;
(*iov)->iov_len -= n;
}
/* Wait until the socket becomes readable */
if (st_netfd_poll(fd, POLLIN, timeout) < 0)
return -1;
}
return 0;
}
ssize_t st_read_fully(_st_netfd_t *fd, void *buf, size_t nbyte, st_utime_t timeout)
{
size_t resid = nbyte;
return st_read_resid(fd, buf, &resid, timeout) == 0 ?
(ssize_t) (nbyte - resid) : -1;
}
int st_write_resid(_st_netfd_t *fd, const void *buf, size_t *resid, st_utime_t timeout)
{
struct iovec iov, *riov;
int riov_size, rv;
iov.iov_base = (void *) buf; /* we promise not to modify buf */
iov.iov_len = *resid;
riov = &iov;
riov_size = 1;
rv = st_writev_resid(fd, &riov, &riov_size, timeout);
*resid = iov.iov_len;
return rv;
}
ssize_t st_write(_st_netfd_t *fd, const void *buf, size_t nbyte, st_utime_t timeout)
{
size_t resid = nbyte;
return st_write_resid(fd, buf, &resid, timeout) == 0 ?
(ssize_t) (nbyte - resid) : -1;
}
ssize_t st_writev(_st_netfd_t *fd, const struct iovec *iov, int iov_size, st_utime_t timeout)
{
ssize_t n, rv;
size_t nleft, nbyte;
int index, iov_cnt;
struct iovec *tmp_iov;
struct iovec local_iov[_LOCAL_MAXIOV];
/* Calculate the total number of bytes to be sent */
nbyte = 0;
for (index = 0; index < iov_size; index++)
nbyte += iov[index].iov_len;
rv = (ssize_t)nbyte;
nleft = nbyte;
tmp_iov = (struct iovec *) iov; /* we promise not to modify iov */
iov_cnt = iov_size;
while (nleft > 0) {
if (iov_cnt == 1) {
if (st_write(fd, tmp_iov[0].iov_base, nleft, timeout) != (ssize_t) nleft)
rv = -1;
break;
}
if ((n = writev(fd->osfd, tmp_iov, iov_cnt)) < 0) {
if (errno == EINTR)
continue;
if (!_IO_NOT_READY_ERROR) {
rv = -1;
break;
}
} else {
if ((size_t) n == nleft)
break;
nleft -= n;
/* Find the next unwritten vector */
n = (ssize_t)(nbyte - nleft);
for (index = 0; (size_t) n >= iov[index].iov_len; index++)
n -= iov[index].iov_len;
if (tmp_iov == iov) {
/* Must copy iov's around */
if (iov_size - index <= _LOCAL_MAXIOV) {
tmp_iov = local_iov;
} else {
tmp_iov = calloc(1, (iov_size - index) * sizeof(struct iovec));
if (tmp_iov == NULL)
return -1;
}
}
/* Fill in the first partial read */
tmp_iov[0].iov_base = &(((char *)iov[index].iov_base)[n]);
tmp_iov[0].iov_len = iov[index].iov_len - n;
index++;
/* Copy the remaining vectors */
for (iov_cnt = 1; index < iov_size; iov_cnt++, index++) {
tmp_iov[iov_cnt].iov_base = iov[index].iov_base;
tmp_iov[iov_cnt].iov_len = iov[index].iov_len;
}
}
/* Wait until the socket becomes writable */
if (st_netfd_poll(fd, POLLOUT, timeout) < 0) {
rv = -1;
break;
}
}
if (tmp_iov != iov && tmp_iov != local_iov)
free(tmp_iov);
return rv;
}
int st_writev_resid(_st_netfd_t *fd, struct iovec **iov, int *iov_size, st_utime_t timeout)
{
ssize_t n;
while (*iov_size > 0) {
if (*iov_size == 1)
n = write(fd->osfd, (*iov)->iov_base, (*iov)->iov_len);
else
n = writev(fd->osfd, *iov, *iov_size);
if (n < 0) {
if (errno == EINTR)
continue;
if (!_IO_NOT_READY_ERROR)
return -1;
} else {
while ((size_t) n >= (*iov)->iov_len) {
n -= (*iov)->iov_len;
(*iov)->iov_base = (char *) (*iov)->iov_base + (*iov)->iov_len;
(*iov)->iov_len = 0;
(*iov)++;
(*iov_size)--;
if (n == 0)
break;
}
if (*iov_size == 0)
break;
(*iov)->iov_base = (char *) (*iov)->iov_base + n;
(*iov)->iov_len -= n;
}
/* Wait until the socket becomes writable */
if (st_netfd_poll(fd, POLLOUT, timeout) < 0)
return -1;
}
return 0;
}
/*
* Simple I/O functions for UDP.
*/
int st_recvfrom(_st_netfd_t *fd, void *buf, int len, struct sockaddr *from, int *fromlen, st_utime_t timeout)
{
int n;
while ((n = recvfrom(fd->osfd, buf, len, 0, from, (socklen_t *)fromlen)) < 0) {
if (errno == EINTR)
continue;
if (!_IO_NOT_READY_ERROR)
return -1;
/* Wait until the socket becomes readable */
if (st_netfd_poll(fd, POLLIN, timeout) < 0)
return -1;
}
return n;
}
int st_sendto(_st_netfd_t *fd, const void *msg, int len, const struct sockaddr *to, int tolen, st_utime_t timeout)
{
int n;
while ((n = sendto(fd->osfd, msg, len, 0, to, tolen)) < 0) {
if (errno == EINTR)
continue;
if (!_IO_NOT_READY_ERROR)
return -1;
/* Wait until the socket becomes writable */
if (st_netfd_poll(fd, POLLOUT, timeout) < 0)
return -1;
}
return n;
}
int st_recvmsg(_st_netfd_t *fd, struct msghdr *msg, int flags, st_utime_t timeout)
{
int n;
while ((n = recvmsg(fd->osfd, msg, flags)) < 0) {
if (errno == EINTR)
continue;
if (!_IO_NOT_READY_ERROR)
return -1;
/* Wait until the socket becomes readable */
if (st_netfd_poll(fd, POLLIN, timeout) < 0)
return -1;
}
return n;
}
int st_sendmsg(_st_netfd_t *fd, const struct msghdr *msg, int flags, st_utime_t timeout)
{
int n;
while ((n = sendmsg(fd->osfd, msg, flags)) < 0) {
if (errno == EINTR)
continue;
if (!_IO_NOT_READY_ERROR)
return -1;
/* Wait until the socket becomes writable */
if (st_netfd_poll(fd, POLLOUT, timeout) < 0)
return -1;
}
return n;
}
/*
* To open FIFOs or other special files.
*/
_st_netfd_t *st_open(const char *path, int oflags, mode_t mode)
{
int osfd, err;
_st_netfd_t *newfd;
while ((osfd = open(path, oflags | O_NONBLOCK, mode)) < 0) {
if (errno != EINTR)
return NULL;
}
newfd = _st_netfd_new(osfd, 0, 0);
if (!newfd) {
err = errno;
close(osfd);
errno = err;
}
return newfd;
}

121
trunk/3rdparty/st-srs/key.c vendored Normal file
View file

@ -0,0 +1,121 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Netscape Portable Runtime library.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1994-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s): Silicon Graphics, Inc.
*
* Portions created by SGI are Copyright (C) 2000-2001 Silicon
* Graphics, Inc. All Rights Reserved.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 or later (the
* "GPL"), in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your
* version of this file only under the terms of the GPL and not to
* allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
/*
* This file is derived directly from Netscape Communications Corporation,
* and consists of extensive modifications made during the year(s) 1999-2000.
*/
#include <stdlib.h>
#include <errno.h>
#include "common.h"
/*
* Destructor table for per-thread private data
*/
static _st_destructor_t _st_destructors[ST_KEYS_MAX];
static int key_max = 0;
/*
* Return a key to be used for thread specific data
*/
int st_key_create(int *keyp, _st_destructor_t destructor)
{
if (key_max >= ST_KEYS_MAX) {
errno = EAGAIN;
return -1;
}
*keyp = key_max++;
_st_destructors[*keyp] = destructor;
return 0;
}
int st_key_getlimit(void)
{
return ST_KEYS_MAX;
}
int st_thread_setspecific(int key, void *value)
{
_st_thread_t *me = _ST_CURRENT_THREAD();
if (key < 0 || key >= key_max) {
errno = EINVAL;
return -1;
}
if (value != me->private_data[key]) {
/* free up previously set non-NULL data value */
if (me->private_data[key] && _st_destructors[key]) {
(*_st_destructors[key])(me->private_data[key]);
}
me->private_data[key] = value;
}
return 0;
}
void *st_thread_getspecific(int key)
{
if (key < 0 || key >= key_max)
return NULL;
return ((_ST_CURRENT_THREAD())->private_data[key]);
}
/*
* Free up all per-thread private data
*/
void _st_thread_cleanup(_st_thread_t *thread)
{
int key;
for (key = 0; key < key_max; key++) {
if (thread->private_data[key] && _st_destructors[key]) {
(*_st_destructors[key])(thread->private_data[key]);
thread->private_data[key] = NULL;
}
}
}

51
trunk/3rdparty/st-srs/libst.def vendored Normal file
View file

@ -0,0 +1,51 @@
EXPORTS
st_accept @62
st_cond_broadcast @63
st_cond_destroy @64
st_cond_new @65
st_cond_signal @66
st_cond_timedwait @67
st_cond_wait @68
st_connect @69
st_getfdlimit @70
st_init @71
st_key_create @72
st_key_getlimit @73
st_mutex_destroy @74
st_mutex_lock @75
st_mutex_new @76
st_mutex_trylock @77
st_mutex_unlock @78
st_netfd_close @79
st_netfd_fileno @80
st_netfd_free @81
st_netfd_getspecific @82
st_netfd_open @83
st_netfd_open_socket @84
st_netfd_poll @85
st_netfd_serialize_accept @86
st_netfd_setspecific @87
st_open @88
st_poll @89
st_randomize_stacks @90
st_read @91
st_read_fully @92
st_read_resid @93
st_recvfrom @94
st_sendto @95
st_sleep @96
st_thread_create @97
st_thread_exit @98
st_thread_getspecific @99
st_thread_interrupt @100
st_thread_join @101
st_thread_self @102
st_thread_setspecific @103
st_time @104
st_timecache_set @105
st_usleep @106
st_utime @107
st_utime_last_clock @108
st_write @109
st_write_resid @110
st_writev @111

644
trunk/3rdparty/st-srs/md.S vendored Normal file
View file

@ -0,0 +1,644 @@
/* If user disable the ASM, such as avoiding bugs in ASM, donot compile it. */
#if !defined(MD_ST_NO_ASM)
/*
* Portions created by SGI are Copyright (C) 2000 Silicon Graphics, Inc.
* All Rights Reserved.
*/
#if defined(__ia64__)
/****************************************************************/
/*
* The internal __jmp_buf layout is different from one used
* by setjmp()/longjmp().
*
* Offset Description
* ------ -----------
* 0x000 stack pointer (r12)
* 0x008 gp (r1)
* 0x010 caller's unat
* 0x018 fpsr
* 0x020 r4
* 0x028 r5
* 0x030 r6
* 0x038 r7
* 0x040 rp (b0)
* 0x048 b1
* 0x050 b2
* 0x058 b3
* 0x060 b4
* 0x068 b5
* 0x070 ar.pfs
* 0x078 ar.lc
* 0x080 pr
* 0x088 ar.bsp
* 0x090 ar.unat
* 0x098 &__jmp_buf
* 0x0a0 ar.rsc
* 0x0a8 ar.rnat
* 0x0b0 f2
* 0x0c0 f3
* 0x0d0 f4
* 0x0e0 f5
* 0x0f0 f16
* 0x100 f17
* 0x110 f18
* 0x120 f19
* 0x130 f20
* 0x130 f21
* 0x140 f22
* 0x150 f23
* 0x160 f24
* 0x170 f25
* 0x180 f26
* 0x190 f27
* 0x1a0 f28
* 0x1b0 f29
* 0x1c0 f30
* 0x1d0 f31
*
* Note that the address of __jmp_buf is saved but not used: we assume
* that the jmp_buf data structure is never moved around in memory.
*/
/*
* Implemented according to "IA-64 Software Conventions and Runtime
* Architecture Guide", Chapter 10: "Context Management".
*/
.text
.psr abi64
.psr lsb
.lsb
/* _st_md_cxt_save(__jmp_buf env) */
.align 32
.global _st_md_cxt_save
.proc _st_md_cxt_save
_st_md_cxt_save:
alloc r14 = ar.pfs,1,0,0,0
mov r16 = ar.unat
;;
mov r17 = ar.fpsr
mov r2 = in0
add r3 = 8,in0
;;
st8.spill.nta [r2] = sp,16 // r12 (sp)
;;
st8.spill.nta [r3] = gp,16 // r1 (gp)
;;
st8.nta [r2] = r16,16 // save caller's unat
st8.nta [r3] = r17,16 // save fpsr
add r8 = 0xb0,in0
;;
st8.spill.nta [r2] = r4,16 // r4
;;
st8.spill.nta [r3] = r5,16 // r5
add r9 = 0xc0,in0
;;
stf.spill.nta [r8] = f2,32
stf.spill.nta [r9] = f3,32
mov r15 = rp
;;
stf.spill.nta [r8] = f4,32
stf.spill.nta [r9] = f5,32
mov r17 = b1
;;
stf.spill.nta [r8] = f16,32
stf.spill.nta [r9] = f17,32
mov r18 = b2
;;
stf.spill.nta [r8] = f18,32
stf.spill.nta [r9] = f19,32
mov r19 = b3
;;
stf.spill.nta [r8] = f20,32
stf.spill.nta [r9] = f21,32
mov r20 = b4
;;
stf.spill.nta [r8] = f22,32
stf.spill.nta [r9] = f23,32
mov r21 = b5
;;
stf.spill.nta [r8] = f24,32
stf.spill.nta [r9] = f25,32
mov r22 = ar.lc
;;
stf.spill.nta [r8] = f26,32
stf.spill.nta [r9] = f27,32
mov r24 = pr
;;
stf.spill.nta [r8] = f28,32
stf.spill.nta [r9] = f29,32
;;
stf.spill.nta [r8] = f30
stf.spill.nta [r9] = f31
st8.spill.nta [r2] = r6,16 // r6
;;
st8.spill.nta [r3] = r7,16 // r7
;;
mov r23 = ar.bsp
mov r25 = ar.unat
st8.nta [r2] = r15,16 // b0
st8.nta [r3] = r17,16 // b1
;;
st8.nta [r2] = r18,16 // b2
st8.nta [r3] = r19,16 // b3
mov r26 = ar.rsc
;;
st8.nta [r2] = r20,16 // b4
st8.nta [r3] = r21,16 // b5
;;
st8.nta [r2] = r14,16 // ar.pfs
st8.nta [r3] = r22,16 // ar.lc
;;
st8.nta [r2] = r24,16 // pr
st8.nta [r3] = r23,16 // ar.bsp
;;
st8.nta [r2] = r25,16 // ar.unat
st8.nta [r3] = in0,16 // &__jmp_buf (just in case)
;;
st8.nta [r2] = r26 // ar.rsc
;;
flushrs // flush dirty regs to backing store
;;
and r27 = ~0x3,r26 // clear ar.rsc.mode
;;
mov ar.rsc = r27 // put RSE in enforced lazy mode
;;
mov r28 = ar.rnat
;;
st8.nta [r3] = r28 // ar.rnat
mov ar.rsc = r26 // restore ar.rsc
;;
mov r8 = 0
br.ret.sptk.few b0
.endp _st_md_cxt_save
/****************************************************************/
/* _st_md_cxt_restore(__jmp_buf env, int val) */
.global _st_md_cxt_restore
.proc _st_md_cxt_restore
_st_md_cxt_restore:
alloc r8 = ar.pfs,2,0,0,0
add r2 = 0x88,in0 // r2 <- &jmpbuf.ar_bsp
mov r16 = ar.rsc
;;
flushrs // flush dirty regs to backing store
;;
and r17 = ~0x3,r16 // clear ar.rsc.mode
;;
mov ar.rsc = r17 // put RSE in enforced lazy mode
;;
invala // invalidate the ALAT
;;
ld8 r23 = [r2],8 // r23 <- jmpbuf.ar_bsp
;;
mov ar.bspstore = r23 // write BSPSTORE
ld8 r25 = [r2],24 // r25 <- jmpbuf.ar_unat
;;
ld8 r26 = [r2],-8 // r26 <- jmpbuf.ar_rnat
;;
mov ar.rnat = r26 // write RNAT
ld8 r27 = [r2] // r27 <- jmpbuf.ar_rsc
;;
mov ar.rsc = r27 // write RSE control
mov r2 = in0
;;
mov ar.unat = r25 // write ar.unat
add r3 = 8,in0
;;
ld8.fill.nta sp = [r2],16 // r12 (sp)
ld8.fill.nta gp = [r3],16 // r1 (gp)
;;
ld8.nta r16 = [r2],16 // caller's unat
ld8.nta r17 = [r3],16 // fpsr
;;
ld8.fill.nta r4 = [r2],16 // r4
ld8.fill.nta r5 = [r3],16 // r5
;;
ld8.fill.nta r6 = [r2],16 // r6
ld8.fill.nta r7 = [r3],16 // r7
;;
mov ar.unat = r16 // restore caller's unat
mov ar.fpsr = r17 // restore fpsr
;;
ld8.nta r16 = [r2],16 // b0
ld8.nta r17 = [r3],16 // b1
;;
ld8.nta r18 = [r2],16 // b2
ld8.nta r19 = [r3],16 // b3
;;
ld8.nta r20 = [r2],16 // b4
ld8.nta r21 = [r3],16 // b5
;;
ld8.nta r11 = [r2],16 // ar.pfs
ld8.nta r22 = [r3],72 // ar.lc
;;
ld8.nta r24 = [r2],48 // pr
mov b0 = r16
;;
ldf.fill.nta f2 = [r2],32
ldf.fill.nta f3 = [r3],32
mov b1 = r17
;;
ldf.fill.nta f4 = [r2],32
ldf.fill.nta f5 = [r3],32
mov b2 = r18
;;
ldf.fill.nta f16 = [r2],32
ldf.fill.nta f17 = [r3],32
mov b3 = r19
;;
ldf.fill.nta f18 = [r2],32
ldf.fill.nta f19 = [r3],32
mov b4 = r20
;;
ldf.fill.nta f20 = [r2],32
ldf.fill.nta f21 = [r3],32
mov b5 = r21
;;
ldf.fill.nta f22 = [r2],32
ldf.fill.nta f23 = [r3],32
mov ar.lc = r22
;;
ldf.fill.nta f24 = [r2],32
ldf.fill.nta f25 = [r3],32
cmp.eq p6,p7 = 0,in1
;;
ldf.fill.nta f26 = [r2],32
ldf.fill.nta f27 = [r3],32
mov ar.pfs = r11
;;
ldf.fill.nta f28 = [r2],32
ldf.fill.nta f29 = [r3],32
;;
ldf.fill.nta f30 = [r2]
ldf.fill.nta f31 = [r3]
(p6) mov r8 = 1
(p7) mov r8 = in1
mov pr = r24,-1
br.ret.sptk.few b0
.endp _st_md_cxt_restore
/****************************************************************/
#elif defined(__i386__)
/****************************************************************/
/*
* Internal __jmp_buf layout
*/
#define JB_BX 0
#define JB_SI 1
#define JB_DI 2
#define JB_BP 3
#define JB_SP 4
#define JB_PC 5
.file "md.S"
.text
/* _st_md_cxt_save(__jmp_buf env) */
.globl _st_md_cxt_save
.type _st_md_cxt_save, @function
.align 16
_st_md_cxt_save:
movl 4(%esp), %eax
/*
* Save registers.
*/
movl %ebx, (JB_BX*4)(%eax)
movl %esi, (JB_SI*4)(%eax)
movl %edi, (JB_DI*4)(%eax)
/* Save SP */
leal 4(%esp), %ecx
movl %ecx, (JB_SP*4)(%eax)
/* Save PC we are returning to */
movl 0(%esp), %ecx
movl %ecx, (JB_PC*4)(%eax)
/* Save caller frame pointer */
movl %ebp, (JB_BP*4)(%eax)
xorl %eax, %eax
ret
.size _st_md_cxt_save, .-_st_md_cxt_save
/****************************************************************/
/* _st_md_cxt_restore(__jmp_buf env, int val) */
.globl _st_md_cxt_restore
.type _st_md_cxt_restore, @function
.align 16
_st_md_cxt_restore:
/* First argument is jmp_buf */
movl 4(%esp), %ecx
/* Second argument is return value */
movl 8(%esp), %eax
/* Set the return address */
movl (JB_PC*4)(%ecx), %edx
/*
* Restore registers.
*/
movl (JB_BX*4)(%ecx), %ebx
movl (JB_SI*4)(%ecx), %esi
movl (JB_DI*4)(%ecx), %edi
movl (JB_BP*4)(%ecx), %ebp
movl (JB_SP*4)(%ecx), %esp
testl %eax, %eax
jnz 1f
incl %eax
/* Jump to saved PC */
1: jmp *%edx
.size _st_md_cxt_restore, .-_st_md_cxt_restore
/****************************************************************/
#elif defined(__amd64__) || defined(__x86_64__)
/****************************************************************/
/*
* Internal __jmp_buf layout
*/
#define JB_RBX 0
#define JB_RBP 1
#define JB_R12 2
#define JB_R13 3
#define JB_R14 4
#define JB_R15 5
#define JB_RSP 6
#define JB_PC 7
.file "md.S"
.text
/* _st_md_cxt_save(__jmp_buf env) */
.globl _st_md_cxt_save
.type _st_md_cxt_save, @function
.align 16
_st_md_cxt_save:
/*
* Save registers.
*/
movq %rbx, (JB_RBX*8)(%rdi)
movq %rbp, (JB_RBP*8)(%rdi)
movq %r12, (JB_R12*8)(%rdi)
movq %r13, (JB_R13*8)(%rdi)
movq %r14, (JB_R14*8)(%rdi)
movq %r15, (JB_R15*8)(%rdi)
/* Save SP */
leaq 8(%rsp), %rdx
movq %rdx, (JB_RSP*8)(%rdi)
/* Save PC we are returning to */
movq (%rsp), %rax
movq %rax, (JB_PC*8)(%rdi)
xorq %rax, %rax
ret
.size _st_md_cxt_save, .-_st_md_cxt_save
/****************************************************************/
/* _st_md_cxt_restore(__jmp_buf env, int val) */
.globl _st_md_cxt_restore
.type _st_md_cxt_restore, @function
.align 16
_st_md_cxt_restore:
/*
* Restore registers.
*/
movq (JB_RBX*8)(%rdi), %rbx
movq (JB_RBP*8)(%rdi), %rbp
movq (JB_R12*8)(%rdi), %r12
movq (JB_R13*8)(%rdi), %r13
movq (JB_R14*8)(%rdi), %r14
movq (JB_R15*8)(%rdi), %r15
/* Set return value */
test %esi, %esi
mov $01, %eax
cmove %eax, %esi
mov %esi, %eax
movq (JB_PC*8)(%rdi), %rdx
movq (JB_RSP*8)(%rdi), %rsp
/* Jump to saved PC */
jmpq *%rdx
.size _st_md_cxt_restore, .-_st_md_cxt_restore
/****************************************************************/
#elif defined(__aarch64__)
/****************************************************************/
/* https://github.com/ossrs/srs/issues/1282#issuecomment-445539513 */
#define JB_X19 0
#define JB_X20 1
#define JB_X21 2
#define JB_X22 3
#define JB_X23 4
#define JB_X24 5
#define JB_X25 6
#define JB_X26 7
#define JB_X27 8
#define JB_X28 9
#define JB_X29 10
#define JB_LR 11
#define JB_SP 13
#define JB_D8 14
#define JB_D9 15
#define JB_D10 16
#define JB_D11 17
#define JB_D12 18
#define JB_D13 19
#define JB_D14 20
#define JB_D15 21
.file "md.S"
.text
/* _st_md_cxt_save(__jmp_buf env) */
.globl _st_md_cxt_save
.type _st_md_cxt_save, %function
.align 4
_st_md_cxt_save:
stp x19, x20, [x0, #JB_X19<<3]
stp x21, x22, [x0, #JB_X21<<3]
stp x23, x24, [x0, #JB_X23<<3]
stp x25, x26, [x0, #JB_X25<<3]
stp x27, x28, [x0, #JB_X27<<3]
stp x29, x30, [x0, #JB_X29<<3]
stp d8, d9, [x0, #JB_D8<<3]
stp d10, d11, [x0, #JB_D10<<3]
stp d12, d13, [x0, #JB_D12<<3]
stp d14, d15, [x0, #JB_D14<<3]
mov x2, sp
str x2, [x0, #JB_SP<<3]
mov x0, #0
ret
.size _st_md_cxt_save, .-_st_md_cxt_save
/****************************************************************/
/* _st_md_cxt_restore(__jmp_buf env, int val) */
.globl _st_md_cxt_restore
.type _st_md_cxt_restore, %function
.align 4
_st_md_cxt_restore:
ldp x19, x20, [x0, #JB_X19<<3]
ldp x21, x22, [x0, #JB_X21<<3]
ldp x23, x24, [x0, #JB_X23<<3]
ldp x25, x26, [x0, #JB_X25<<3]
ldp x27, x28, [x0, #JB_X27<<3]
ldp x29, x30, [x0, #JB_X29<<3]
ldp d8, d9, [x0, #JB_D8<<3]
ldp d10, d11, [x0, #JB_D10<<3]
ldp d12, d13, [x0, #JB_D12<<3]
ldp d14, d15, [x0, #JB_D14<<3]
ldr x5, [x0, #JB_SP<<3]
mov sp, x5
cmp x1, #0
mov x0, #1
csel x0, x1, x0, ne
/* Use br instead of ret because ret is guaranteed to mispredict */
br x30
.size _st_md_cxt_restore, .-_st_md_cxt_restore
/****************************************************************/
#elif defined(__arm__)
/****************************************************************/
/* https://github.com/ossrs/srs/issues/1282#issuecomment-445539513 */
/* Register list for a ldm/stm instruction to load/store
the general registers from a __jmp_buf. */
# define JMP_BUF_REGLIST {v1-v6, sl, fp, sp, lr}
.file "md.S"
.text
/* _st_md_cxt_save(__jmp_buf env) */
.globl _st_md_cxt_save
.type _st_md_cxt_save, %function
.align 2
_st_md_cxt_save:
mov ip, r0
/* Save registers */
stmia ip!, JMP_BUF_REGLIST
#ifdef __VFP_FP__
/* Store the VFP registers. */
/* Following instruction is vstmia ip!, {d8-d15}. */
stc p11, cr8, [ip], #64
#endif
#ifdef __IWMMXT__
/* Save the call-preserved iWMMXt registers. */
/* Following instructions are wstrd wr10, [ip], #8 (etc.) */
stcl p1, cr10, [r12], #8
stcl p1, cr11, [r12], #8
stcl p1, cr12, [r12], #8
stcl p1, cr13, [r12], #8
stcl p1, cr14, [r12], #8
stcl p1, cr15, [r12], #8
#endif
mov r0, #0
bx lr
.size _st_md_cxt_save, .-_st_md_cxt_save
/****************************************************************/
/* _st_md_cxt_restore(__jmp_buf env, int val) */
.globl _st_md_cxt_restore
.type _st_md_cxt_restore, %function
.align 2
_st_md_cxt_restore:
mov ip, r0
/* Restore registers */
ldmia ip!, JMP_BUF_REGLIST
#ifdef __VFP_FP__
/* Restore the VFP registers. */
/* Following instruction is vldmia ip!, {d8-d15}. */
ldc p11, cr8, [r12], #64
#endif
#ifdef __IWMMXT__
/* Restore the call-preserved iWMMXt registers. */
/* Following instructions are wldrd wr10, [ip], #8 (etc.) */
ldcl p1, cr10, [r12], #8
ldcl p1, cr11, [r12], #8
ldcl p1, cr12, [r12], #8
ldcl p1, cr13, [r12], #8
ldcl p1, cr14, [r12], #8
ldcl p1, cr15, [r12], #8
#endif
movs r0, r1 /* get the return value in place */
moveq r0, #1 /* can't let setjmp() return zero! */
bx lr
.size _st_md_cxt_restore, .-_st_md_cxt_restore
/****************************************************************/
#endif
#endif

645
trunk/3rdparty/st-srs/md.h vendored Normal file
View file

@ -0,0 +1,645 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Netscape Portable Runtime library.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1994-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s): Silicon Graphics, Inc.
*
* Portions created by SGI are Copyright (C) 2000-2001 Silicon
* Graphics, Inc. All Rights Reserved.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 or later (the
* "GPL"), in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your
* version of this file only under the terms of the GPL and not to
* allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
/*
* This file is derived directly from Netscape Communications Corporation,
* and consists of extensive modifications made during the year(s) 1999-2000.
*/
#ifndef __ST_MD_H__
#define __ST_MD_H__
#if defined(ETIMEDOUT) && !defined(ETIME)
#define ETIME ETIMEDOUT
#endif
#if defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
#define MAP_ANON MAP_ANONYMOUS
#endif
#ifndef MAP_FAILED
#define MAP_FAILED -1
#endif
/*****************************************
* Platform specifics
*/
#if defined (AIX)
#define MD_STACK_GROWS_DOWN
#define MD_USE_SYSV_ANON_MMAP
#define MD_ACCEPT_NB_INHERITED
#define MD_ALWAYS_UNSERIALIZED_ACCEPT
#ifndef MD_HAVE_SOCKLEN_T
#define MD_HAVE_SOCKLEN_T
#define socklen_t unsigned long
#endif
#define MD_SETJMP(env) _setjmp(env)
#define MD_LONGJMP(env, val) _longjmp(env, val)
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
if (MD_SETJMP((_thread)->context)) \
_main(); \
(_thread)->context[3] = (long) (_sp); \
ST_END_MACRO
#define MD_GET_UTIME() \
timebasestruct_t rt; \
(void) read_real_time(&rt, TIMEBASE_SZ); \
(void) time_base_to_time(&rt, TIMEBASE_SZ); \
return (rt.tb_high * 1000000LL + rt.tb_low / 1000)
#elif defined (CYGWIN)
#define MD_STACK_GROWS_DOWN
#define MD_USE_BSD_ANON_MMAP
#define MD_ACCEPT_NB_NOT_INHERITED
#define MD_ALWAYS_UNSERIALIZED_ACCEPT
#define MD_SETJMP(env) setjmp(env)
#define MD_LONGJMP(env, val) longjmp(env, val)
#define MD_JB_SP 7
#define MD_GET_SP(_t) (_t)->context[MD_JB_SP]
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
if (MD_SETJMP((_thread)->context)) \
_main(); \
MD_GET_SP(_thread) = (long) (_sp); \
ST_END_MACRO
#define MD_GET_UTIME() \
struct timeval tv; \
(void) gettimeofday(&tv, NULL); \
return (tv.tv_sec * 1000000LL + tv.tv_usec)
#elif defined (DARWIN)
#define MD_STACK_GROWS_DOWN
#define MD_USE_BSD_ANON_MMAP
#define MD_ACCEPT_NB_INHERITED
#define MD_ALWAYS_UNSERIALIZED_ACCEPT
#define MD_HAVE_SOCKLEN_T
#define MD_USE_BUILTIN_SETJMP
#if defined(__amd64__) || defined(__x86_64__)
#define JB_SP 12
#define MD_GET_SP(_t) *((long *)&((_t)->context[JB_SP]))
#else
#error Unknown CPU architecture
#endif
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
if (MD_SETJMP((_thread)->context)) \
_main(); \
MD_GET_SP(_thread) = (long) (_sp); \
ST_END_MACRO
#if defined(MD_USE_BUILTIN_SETJMP)
#define MD_SETJMP(env) _st_md_cxt_save(env)
#define MD_LONGJMP(env, val) _st_md_cxt_restore(env, val)
extern int _st_md_cxt_save(jmp_buf env);
extern void _st_md_cxt_restore(jmp_buf env, int val);
#endif
#define MD_GET_UTIME() \
struct timeval tv; \
(void) gettimeofday(&tv, NULL); \
return (tv.tv_sec * 1000000LL + tv.tv_usec)
#elif defined (FREEBSD)
#define MD_STACK_GROWS_DOWN
#define MD_USE_BSD_ANON_MMAP
#define MD_ACCEPT_NB_INHERITED
#define MD_ALWAYS_UNSERIALIZED_ACCEPT
#define MD_SETJMP(env) _setjmp(env)
#define MD_LONGJMP(env, val) _longjmp(env, val)
#if defined(__i386__)
#define MD_JB_SP 2
#elif defined(__alpha__)
#define MD_JB_SP 34
#elif defined(__amd64__)
#define MD_JB_SP 2
#else
#error Unknown CPU architecture
#endif
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
if (MD_SETJMP((_thread)->context)) \
_main(); \
(_thread)->context[0]._jb[MD_JB_SP] = (long) (_sp); \
ST_END_MACRO
#define MD_GET_UTIME() \
struct timeval tv; \
(void) gettimeofday(&tv, NULL); \
return (tv.tv_sec * 1000000LL + tv.tv_usec)
#elif defined (HPUX)
#define MD_STACK_GROWS_UP
#define MD_USE_BSD_ANON_MMAP
#define MD_ACCEPT_NB_INHERITED
#define MD_ALWAYS_UNSERIALIZED_ACCEPT
#define MD_SETJMP(env) _setjmp(env)
#define MD_LONGJMP(env, val) _longjmp(env, val)
#ifndef __LP64__
/* 32-bit mode (ILP32 data model) */
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
if (MD_SETJMP((_thread)->context)) \
_main(); \
((long *)((_thread)->context))[1] = (long) (_sp); \
ST_END_MACRO
#else
/* 64-bit mode (LP64 data model) */
#define MD_STACK_PAD_SIZE 256
/* Last stack frame must be preserved */
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
if (MD_SETJMP((_thread)->context)) \
_main(); \
memcpy((char *)(_sp) - MD_STACK_PAD_SIZE, \
((char **)((_thread)->context))[1] - MD_STACK_PAD_SIZE, \
MD_STACK_PAD_SIZE); \
((long *)((_thread)->context))[1] = (long) (_sp); \
ST_END_MACRO
#endif /* !__LP64__ */
#define MD_GET_UTIME() \
struct timeval tv; \
(void) gettimeofday(&tv, NULL); \
return (tv.tv_sec * 1000000LL + tv.tv_usec)
#elif defined (IRIX)
#include <sys/syssgi.h>
#define MD_STACK_GROWS_DOWN
#define MD_USE_SYSV_ANON_MMAP
#define MD_ACCEPT_NB_INHERITED
#define MD_ALWAYS_UNSERIALIZED_ACCEPT
#define MD_SETJMP(env) setjmp(env)
#define MD_LONGJMP(env, val) longjmp(env, val)
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
(void) MD_SETJMP((_thread)->context); \
(_thread)->context[JB_SP] = (long) (_sp); \
(_thread)->context[JB_PC] = (long) _main; \
ST_END_MACRO
#define MD_GET_UTIME() \
static int inited = 0; \
static clockid_t clock_id = CLOCK_SGI_CYCLE; \
struct timespec ts; \
if (!inited) { \
if (syssgi(SGI_CYCLECNTR_SIZE) < 64) \
clock_id = CLOCK_REALTIME; \
inited = 1; \
} \
(void) clock_gettime(clock_id, &ts); \
return (ts.tv_sec * 1000000LL + ts.tv_nsec / 1000)
/*
* Cap the stack by zeroing out the saved return address register
* value. This allows libexc, used by SpeedShop, to know when to stop
* backtracing since it won't find main, start, or any other known
* stack root function in a state thread's stack. Without this libexc
* traces right off the stack and crashes.
* The function preamble stores ra at 8(sp), this stores zero there.
* N.B. This macro is compiler/ABI dependent. It must change if ANY more
* automatic variables are added to the _st_thread_main() routine, because
* the address where ra is stored will change.
*/
#if !defined(__GNUC__) && defined(_MIPS_SIM) && _MIPS_SIM != _ABIO32
#define MD_CAP_STACK(var_addr) \
(((volatile __uint64_t *)(var_addr))[1] = 0)
#endif
#elif defined (LINUX)
/*
* These are properties of the linux kernel and are the same on every
* flavor and architecture.
*/
#define MD_USE_BSD_ANON_MMAP
#define MD_ACCEPT_NB_NOT_INHERITED
#define MD_ALWAYS_UNSERIALIZED_ACCEPT
/*
* Modern GNU/Linux is Posix.1g compliant.
*/
#define MD_HAVE_SOCKLEN_T
/*
* All architectures and flavors of linux have the gettimeofday
* function but if you know of a faster way, use it.
*/
#define MD_GET_UTIME() \
struct timeval tv; \
(void) gettimeofday(&tv, NULL); \
return (tv.tv_sec * 1000000LL + tv.tv_usec)
#if defined(__ia64__)
#define MD_STACK_GROWS_DOWN
/*
* IA-64 architecture. Besides traditional memory call stack, IA-64
* uses general register stack. Thus each thread needs a backing store
* for register stack in addition to memory stack. Standard
* setjmp()/longjmp() cannot be used for thread context switching
* because their implementation implicitly assumes that only one
* register stack exists.
*/
#ifdef USE_LIBC_SETJMP
#undef USE_LIBC_SETJMP
#endif
#define MD_USE_BUILTIN_SETJMP
#define MD_STACK_PAD_SIZE 128
/* Last register stack frame must be preserved */
#define MD_INIT_CONTEXT(_thread, _sp, _bsp, _main) \
ST_BEGIN_MACRO \
if (MD_SETJMP((_thread)->context)) \
_main(); \
memcpy((char *)(_bsp) - MD_STACK_PAD_SIZE, \
(char *)(_thread)->context[0].__jmpbuf[17] - MD_STACK_PAD_SIZE, \
MD_STACK_PAD_SIZE); \
(_thread)->context[0].__jmpbuf[0] = (long) (_sp); \
(_thread)->context[0].__jmpbuf[17] = (long) (_bsp); \
ST_END_MACRO
#elif defined(__mips__)
#define MD_STACK_GROWS_DOWN
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
MD_SETJMP((_thread)->context); \
_thread->context[0].__jmpbuf[0].__pc = (__ptr_t) _main; \
_thread->context[0].__jmpbuf[0].__sp = _sp; \
ST_END_MACRO
#else /* Not IA-64 or mips */
/*
* On linux, there are a few styles of jmpbuf format. These vary based
* on architecture/glibc combination.
*
* Most of the glibc based toggles were lifted from:
* mozilla/nsprpub/pr/include/md/_linux.h
*/
/*
* Starting with glibc 2.4, JB_SP definitions are not public anymore.
* They, however, can still be found in glibc source tree in
* architecture-specific "jmpbuf-offsets.h" files.
* Most importantly, the content of jmp_buf is mangled by setjmp to make
* it completely opaque (the mangling can be disabled by setting the
* LD_POINTER_GUARD environment variable before application execution).
* Therefore we will use built-in _st_md_cxt_save/_st_md_cxt_restore
* functions as a setjmp/longjmp replacement wherever they are available
* unless USE_LIBC_SETJMP is defined.
*/
#if defined(__powerpc__)
#define MD_STACK_GROWS_DOWN
#if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1)
#ifndef JB_GPR1
#define JB_GPR1 0
#endif
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[JB_GPR1]
#else
/* not an error but certainly cause for caution */
#error "Untested use of old glibc on powerpc"
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[0].__misc[0]
#endif /* glibc 2.1 or later */
#elif defined(__alpha)
#define MD_STACK_GROWS_DOWN
#if defined(__GLIBC__) && __GLIBC__ >= 2
#ifndef JB_SP
#define JB_SP 8
#endif
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[JB_SP]
#else
/* not an error but certainly cause for caution */
#error "Untested use of old glibc on alpha"
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[0].__sp
#endif
#elif defined(__mc68000__)
#define MD_STACK_GROWS_DOWN
/* m68k still uses old style sigjmp_buf */
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[0].__sp
#elif defined(__sparc__)
#define MD_STACK_GROWS_DOWN
#if defined(__GLIBC__) && __GLIBC__ >= 2
#ifndef JB_SP
#define JB_SP 0
#endif
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[JB_SP]
#else
/* not an error but certainly cause for caution */
#error "Untested use of old glic on sparc -- also using odd mozilla derived __fp"
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[0].__fp
#endif
#elif defined(__i386__)
#define MD_STACK_GROWS_DOWN
#define MD_USE_BUILTIN_SETJMP
#if defined(__GLIBC__) && __GLIBC__ >= 2
#ifndef JB_SP
#define JB_SP 4
#endif
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[JB_SP]
#else
/* not an error but certainly cause for caution */
#error "Untested use of old glibc on i386"
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[0].__sp
#endif
#elif defined(__amd64__) || defined(__x86_64__)
#define MD_STACK_GROWS_DOWN
#define MD_USE_BUILTIN_SETJMP
#ifndef JB_RSP
#define JB_RSP 6
#endif
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[JB_RSP]
#elif defined(__aarch64__)
/* https://github.com/ossrs/state-threads/issues/9 */
#define MD_STACK_GROWS_DOWN
#define MD_USE_BUILTIN_SETJMP
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[13]
#elif defined(__arm__)
#define MD_STACK_GROWS_DOWN
/* https://github.com/ossrs/state-threads/issues/1#issuecomment-244648573 */
#define MD_USE_BUILTIN_SETJMP
/* force to use glibc solution, hack the guard jmpbuf from michaeltalyansky */
#ifdef USE_LIBC_SETJMP
#undef MD_USE_BUILTIN_SETJMP
#endif
#if defined(__GLIBC__) && __GLIBC__ >= 2
/* Merge from https://github.com/michaeltalyansky/state-threads/commit/56554a5c425aee8e7a73782eae23d74d83c4120a */
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[8]
#else
#error "ARM/Linux pre-glibc2 not supported yet"
#endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */
#elif defined(__s390__)
#define MD_STACK_GROWS_DOWN
/* There is no JB_SP in glibc at this time. (glibc 2.2.5)
*/
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[0].__gregs[9]
#elif defined(__hppa__)
#define MD_STACK_GROWS_UP
/* yes, this is gross, unfortunately at the moment (2002/08/01) there is
* a bug in hppa's glibc header definition for JB_SP, so we can't
* use that...
*/
#define MD_GET_SP(_t) (*(long *)(((char *)&(_t)->context[0].__jmpbuf[0]) + 76))
#else
#error "Unknown CPU architecture"
#endif /* Cases with common MD_INIT_CONTEXT and different SP locations */
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
if (MD_SETJMP((_thread)->context)) \
_main(); \
MD_GET_SP(_thread) = (long) (_sp); \
ST_END_MACRO
#endif /* Cases with different MD_INIT_CONTEXT */
#if defined(MD_USE_BUILTIN_SETJMP) && !defined(USE_LIBC_SETJMP)
#define MD_SETJMP(env) _st_md_cxt_save(env)
#define MD_LONGJMP(env, val) _st_md_cxt_restore(env, val)
extern int _st_md_cxt_save(jmp_buf env);
extern void _st_md_cxt_restore(jmp_buf env, int val);
#else
#define MD_SETJMP(env) setjmp(env)
#define MD_LONGJMP(env, val) longjmp(env, val)
#endif
#elif defined (NETBSD)
#define MD_STACK_GROWS_DOWN
#define MD_USE_BSD_ANON_MMAP
#define MD_ACCEPT_NB_INHERITED
#define MD_ALWAYS_UNSERIALIZED_ACCEPT
#define MD_HAVE_SOCKLEN_T
#define MD_SETJMP(env) _setjmp(env)
#define MD_LONGJMP(env, val) _longjmp(env, val)
#if defined(__i386__)
#define MD_JB_SP 2
#elif defined(__alpha__)
#define MD_JB_SP 34
#elif defined(__sparc__)
#define MD_JB_SP 0
#elif defined(__vax__)
#define MD_JB_SP 2
#else
#error Unknown CPU architecture
#endif
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
if (MD_SETJMP((_thread)->context)) \
_main(); \
(_thread)->context[MD_JB_SP] = (long) (_sp); \
ST_END_MACRO
#define MD_GET_UTIME() \
struct timeval tv; \
(void) gettimeofday(&tv, NULL); \
return (tv.tv_sec * 1000000LL + tv.tv_usec)
#elif defined (OPENBSD)
#define MD_STACK_GROWS_DOWN
#define MD_USE_BSD_ANON_MMAP
#define MD_ACCEPT_NB_INHERITED
#define MD_ALWAYS_UNSERIALIZED_ACCEPT
#define MD_SETJMP(env) _setjmp(env)
#define MD_LONGJMP(env, val) _longjmp(env, val)
#if defined(__i386__)
#define MD_JB_SP 2
#elif defined(__alpha__)
#define MD_JB_SP 34
#elif defined(__sparc__)
#define MD_JB_SP 0
#elif defined(__amd64__)
#define MD_JB_SP 6
#else
#error Unknown CPU architecture
#endif
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
if (MD_SETJMP((_thread)->context)) \
_main(); \
(_thread)->context[MD_JB_SP] = (long) (_sp); \
ST_END_MACRO
#define MD_GET_UTIME() \
struct timeval tv; \
(void) gettimeofday(&tv, NULL); \
return (tv.tv_sec * 1000000LL + tv.tv_usec)
#elif defined (OSF1)
#include <signal.h>
#define MD_STACK_GROWS_DOWN
#define MD_USE_SYSV_ANON_MMAP
#define MD_ACCEPT_NB_NOT_INHERITED
#define MD_ALWAYS_UNSERIALIZED_ACCEPT
#define MD_SETJMP(env) _setjmp(env)
#define MD_LONGJMP(env, val) _longjmp(env, val)
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
if (MD_SETJMP((_thread)->context)) \
_main(); \
((struct sigcontext *)((_thread)->context))->sc_sp = (long) (_sp); \
ST_END_MACRO
#define MD_GET_UTIME() \
struct timeval tv; \
(void) gettimeofday(&tv, NULL); \
return (tv.tv_sec * 1000000LL + tv.tv_usec)
#elif defined (SOLARIS)
#include <sys/filio.h>
extern int getpagesize(void);
#define MD_STACK_GROWS_DOWN
#define MD_USE_SYSV_ANON_MMAP
#define MD_ACCEPT_NB_NOT_INHERITED
#define MD_SETJMP(env) setjmp(env)
#define MD_LONGJMP(env, val) longjmp(env, val)
#if defined(sparc) || defined(__sparc)
#ifdef _LP64
#define MD_STACK_PAD_SIZE 4095
#endif
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
(void) MD_SETJMP((_thread)->context); \
(_thread)->context[1] = (long) (_sp); \
(_thread)->context[2] = (long) _main; \
ST_END_MACRO
#elif defined(i386) || defined(__i386)
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
(void) MD_SETJMP((_thread)->context); \
(_thread)->context[4] = (long) (_sp); \
(_thread)->context[5] = (long) _main; \
ST_END_MACRO
#elif defined(__amd64__)
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
if (MD_SETJMP((_thread)->context)) \
_main(); \
(_thread)->context[6] = (long) (_sp); \
ST_END_MACRO
#else
#error Unknown CPU architecture
#endif
#define MD_GET_UTIME() \
return (gethrtime() / 1000)
#else
#error Unknown OS
#endif /* OS */
#if !defined(MD_HAVE_POLL) && !defined(MD_DONT_HAVE_POLL)
#define MD_HAVE_POLL
#endif
#ifndef MD_STACK_PAD_SIZE
#define MD_STACK_PAD_SIZE 128
#endif
#if !defined(MD_HAVE_SOCKLEN_T) && !defined(socklen_t)
#define socklen_t int
#endif
#ifndef MD_CAP_STACK
#define MD_CAP_STACK(var_addr)
#endif
#endif /* !__ST_MD_H__ */

76
trunk/3rdparty/st-srs/md_darwin.S vendored Normal file
View file

@ -0,0 +1,76 @@
/* If user disable the ASM, such as avoiding bugs in ASM, donot compile it. */
#if !defined(MD_ST_NO_ASM)
#if defined(__amd64__) || defined(__x86_64__)
/****************************************************************/
/*
* Internal __jmp_buf layout
*/
#define JB_RBX 0
#define JB_RBP 1
#define JB_R12 2 /* Backup IP, https://www.cnblogs.com/Five100Miles/p/8458561.html */
#define JB_R13 3 /* Backup SP, https://www.cnblogs.com/Five100Miles/p/8458561.html */
#define JB_R14 4 /* Backup LR, https://www.cnblogs.com/Five100Miles/p/8458561.html */
#define JB_R15 5 /* Backup PC, https://www.cnblogs.com/Five100Miles/p/8458561.html */
#define JB_RSP 6
#define JB_PC 7
.file "md_darwin.S"
.text
/* _st_md_cxt_save(__jmp_buf env) */ /* The env is rdi, http://blog.chinaunix.net/uid-20157960-id-1974354.html */
.globl __st_md_cxt_save
.align 16
__st_md_cxt_save:
/*
* Save registers.
*/
movq %rbx, (JB_RBX*8)(%rdi) /* Save rbx to env[0], *(int64_t*)(rdi+0)=rbx */
movq %rbp, (JB_RBP*8)(%rdi) /* Save rbp to env[1], *(int64_t*)(rdi+1)=rbp */
movq %r12, (JB_R12*8)(%rdi) /* Save r12 to env[2], *(int64_t*)(rdi+2)=r12 */
movq %r13, (JB_R13*8)(%rdi) /* Save r13 to env[3], *(int64_t*)(rdi+3)=r13 */
movq %r14, (JB_R14*8)(%rdi) /* Save r14 to env[4], *(int64_t*)(rdi+4)=r14 */
movq %r15, (JB_R15*8)(%rdi) /* Save r15 to env[5], *(int64_t*)(rdi+5)=r15 */
/* Save SP */
leaq 8(%rsp), %rdx /* Save *(int64_t*)(rsp+8) to rdx, https://my.oschina.net/guonaihong/blog/508907 */
movq %rdx, (JB_RSP*8)(%rdi) /* Save rdx(rsp) to env[6], *(int64_t*)(rdi+6)=rdx */
/* Save PC we are returning to */
movq (%rsp), %rax /* Save PC(parent function address) %(rsp) to rax */
movq %rax, (JB_PC*8)(%rdi) /* Save rax(PC) to env[7], *(int64_t*)(rdi+7)=rax */
xorq %rax, %rax /* Reset rax to 0 */
ret
/****************************************************************/
/* _st_md_cxt_restore(__jmp_buf env, int val) */ /* The env is rdi, val is esi/rsi, http://blog.chinaunix.net/uid-20157960-id-1974354.html */
.globl __st_md_cxt_restore
.align 16
__st_md_cxt_restore:
/*
* Restore registers.
*/
movq (JB_RBX*8)(%rdi), %rbx /* Load rbx from env[0] */
movq (JB_RBP*8)(%rdi), %rbp /* Load rbp from env[1] */
movq (JB_R12*8)(%rdi), %r12 /* Load r12 from env[2] */
movq (JB_R13*8)(%rdi), %r13 /* Load r13 from env[3] */
movq (JB_R14*8)(%rdi), %r14 /* Load r14 from env[4] */
movq (JB_R15*8)(%rdi), %r15 /* Load r15 from env[5] */
/* Set return value */ /* The esi is param1 val, the eax is return value */
test %esi, %esi /* if (!val) { */
mov $01, %eax /* val=1; */
cmove %eax, %esi /* } */
mov %esi, %eax /* return val; */
movq (JB_PC*8)(%rdi), %rdx /* Load rdx(PC) from env[7] */
movq (JB_RSP*8)(%rdi), %rsp /* Load rsp from env[6] */
/* Jump to saved PC */
jmpq *%rdx /* Jump to rdx(PC) */
/****************************************************************/
#endif
#endif

45
trunk/3rdparty/st-srs/osguess.sh vendored Normal file
View file

@ -0,0 +1,45 @@
#
# This script can be used to automatically guess target OS.
# It requires the config.guess utility which is a part of GNU Autoconf.
# GNU Autoconf can be downloaded from ftp://ftp.gnu.org/gnu/autoconf/
#
# Use "default" as a make target for automatic builds.
#
# Specify path to the config.guess utility (unless set via environment)
#CONFIG_GUESS_PATH=
if [ x"$CONFIG_GUESS_PATH" = x ]; then
echo "Error: CONFIG_GUESS_PATH variable is not set"
exit 1
fi
if [ ! -f "$CONFIG_GUESS_PATH/config.guess" ]; then
echo "Can't find $CONFIG_GUESS_PATH/config.guess utility. Wrong path?"
exit 1
fi
sys_info=`/bin/sh $CONFIG_GUESS_PATH/config.guess`
echo "Building for $sys_info"
case "$sys_info" in
*-ibm-aix4* ) OS=AIX ;;
*-freebsd* ) OS=FREEBSD ;;
hppa*-hp-hpux11*) OS=HPUX ;;
*-sgi-irix6* ) OS=IRIX ;;
*-linux* ) OS=LINUX ;;
*-netbsd* ) OS=NETBSD ;;
*-openbsd* ) OS=OPENBSD ;;
*-dec-osf* ) OS=OSF1 ;;
*-solaris2* ) OS=SOLARIS ;;
*-darwin* ) OS=DARWIN ;;
* ) OS=
echo "Sorry, unsupported OS"
exit 1 ;;
esac
echo "Making with OS=$OS"

166
trunk/3rdparty/st-srs/public.h vendored Normal file
View file

@ -0,0 +1,166 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Netscape Portable Runtime library.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1994-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s): Silicon Graphics, Inc.
*
* Portions created by SGI are Copyright (C) 2000-2001 Silicon
* Graphics, Inc. All Rights Reserved.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 or later (the
* "GPL"), in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your
* version of this file only under the terms of the GPL and not to
* allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
#ifndef __ST_THREAD_H__
#define __ST_THREAD_H__
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
#include <time.h>
#include <errno.h>
#include <poll.h>
#define ST_VERSION "1.9"
#define ST_VERSION_MAJOR 1
#define ST_VERSION_MINOR 9
/* Undefine this to remove the context switch callback feature. */
#define ST_SWITCH_CB
#ifndef ETIME
#define ETIME ETIMEDOUT
#endif
#ifndef ST_UTIME_NO_TIMEOUT
#define ST_UTIME_NO_TIMEOUT ((st_utime_t) -1LL)
#endif
#ifndef ST_UTIME_NO_WAIT
#define ST_UTIME_NO_WAIT 0
#endif
#define ST_EVENTSYS_DEFAULT 0
#define ST_EVENTSYS_SELECT 1
#define ST_EVENTSYS_POLL 2
#define ST_EVENTSYS_ALT 3
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned long long st_utime_t;
typedef struct _st_thread * st_thread_t;
typedef struct _st_cond * st_cond_t;
typedef struct _st_mutex * st_mutex_t;
typedef struct _st_netfd * st_netfd_t;
#ifdef ST_SWITCH_CB
typedef void (*st_switch_cb_t)(void);
#endif
extern int st_init(void);
extern int st_getfdlimit(void);
extern int st_set_eventsys(int eventsys);
extern int st_get_eventsys(void);
extern const char *st_get_eventsys_name(void);
#ifdef ST_SWITCH_CB
extern st_switch_cb_t st_set_switch_in_cb(st_switch_cb_t cb);
extern st_switch_cb_t st_set_switch_out_cb(st_switch_cb_t cb);
#endif
extern st_thread_t st_thread_self(void);
extern void st_thread_exit(void *retval);
extern int st_thread_join(st_thread_t thread, void **retvalp);
extern void st_thread_interrupt(st_thread_t thread);
extern st_thread_t st_thread_create(void *(*start)(void *arg), void *arg, int joinable, int stack_size);
extern int st_randomize_stacks(int on);
extern int st_set_utime_function(st_utime_t (*func)(void));
extern st_utime_t st_utime(void);
extern st_utime_t st_utime_last_clock(void);
extern int st_timecache_set(int on);
extern time_t st_time(void);
extern int st_usleep(st_utime_t usecs);
extern int st_sleep(int secs);
extern st_cond_t st_cond_new(void);
extern int st_cond_destroy(st_cond_t cvar);
extern int st_cond_timedwait(st_cond_t cvar, st_utime_t timeout);
extern int st_cond_wait(st_cond_t cvar);
extern int st_cond_signal(st_cond_t cvar);
extern int st_cond_broadcast(st_cond_t cvar);
extern st_mutex_t st_mutex_new(void);
extern int st_mutex_destroy(st_mutex_t lock);
extern int st_mutex_lock(st_mutex_t lock);
extern int st_mutex_unlock(st_mutex_t lock);
extern int st_mutex_trylock(st_mutex_t lock);
extern int st_key_create(int *keyp, void (*destructor)(void *));
extern int st_key_getlimit(void);
extern int st_thread_setspecific(int key, void *value);
extern void *st_thread_getspecific(int key);
extern st_netfd_t st_netfd_open(int osfd);
extern st_netfd_t st_netfd_open_socket(int osfd);
extern void st_netfd_free(st_netfd_t fd);
extern int st_netfd_close(st_netfd_t fd);
extern int st_netfd_fileno(st_netfd_t fd);
extern void st_netfd_setspecific(st_netfd_t fd, void *value, void (*destructor)(void *));
extern void *st_netfd_getspecific(st_netfd_t fd);
extern int st_netfd_serialize_accept(st_netfd_t fd);
extern int st_netfd_poll(st_netfd_t fd, int how, st_utime_t timeout);
extern int st_poll(struct pollfd *pds, int npds, st_utime_t timeout);
extern st_netfd_t st_accept(st_netfd_t fd, struct sockaddr *addr, int *addrlen, st_utime_t timeout);
extern int st_connect(st_netfd_t fd, const struct sockaddr *addr, int addrlen, st_utime_t timeout);
extern ssize_t st_read(st_netfd_t fd, void *buf, size_t nbyte, st_utime_t timeout);
extern ssize_t st_read_fully(st_netfd_t fd, void *buf, size_t nbyte, st_utime_t timeout);
extern int st_read_resid(st_netfd_t fd, void *buf, size_t *resid, st_utime_t timeout);
extern ssize_t st_readv(st_netfd_t fd, const struct iovec *iov, int iov_size, st_utime_t timeout);
extern int st_readv_resid(st_netfd_t fd, struct iovec **iov, int *iov_size, st_utime_t timeout);
extern ssize_t st_write(st_netfd_t fd, const void *buf, size_t nbyte, st_utime_t timeout);
extern int st_write_resid(st_netfd_t fd, const void *buf, size_t *resid, st_utime_t timeout);
extern ssize_t st_writev(st_netfd_t fd, const struct iovec *iov, int iov_size, st_utime_t timeout);
extern int st_writev_resid(st_netfd_t fd, struct iovec **iov, int *iov_size, st_utime_t timeout);
extern int st_recvfrom(st_netfd_t fd, void *buf, int len, struct sockaddr *from, int *fromlen, st_utime_t timeout);
extern int st_sendto(st_netfd_t fd, const void *msg, int len, const struct sockaddr *to, int tolen, st_utime_t timeout);
extern int st_recvmsg(st_netfd_t fd, struct msghdr *msg, int flags, st_utime_t timeout);
extern int st_sendmsg(st_netfd_t fd, const struct msghdr *msg, int flags, st_utime_t timeout);
extern st_netfd_t st_open(const char *path, int oflags, mode_t mode);
#ifdef DEBUG
extern void _st_show_thread_stack(st_thread_t thread, const char *messg);
extern void _st_iterate_threads(void);
#endif
#ifdef __cplusplus
}
#endif
#endif /* !__ST_THREAD_H__ */

705
trunk/3rdparty/st-srs/sched.c vendored Normal file
View file

@ -0,0 +1,705 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Netscape Portable Runtime library.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1994-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s): Silicon Graphics, Inc.
*
* Portions created by SGI are Copyright (C) 2000-2001 Silicon
* Graphics, Inc. All Rights Reserved.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 or later (the
* "GPL"), in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your
* version of this file only under the terms of the GPL and not to
* allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
/*
* This file is derived directly from Netscape Communications Corporation,
* and consists of extensive modifications made during the year(s) 1999-2000.
*/
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include "common.h"
/* merge from https://github.com/toffaletti/state-threads/commit/7f57fc9acc05e657bca1223f1e5b9b1a45ed929b */
#ifndef NVALGRIND
#include <valgrind/valgrind.h>
#endif
/* Global data */
_st_vp_t _st_this_vp; /* This VP */
_st_thread_t *_st_this_thread; /* Current thread */
int _st_active_count = 0; /* Active thread count */
time_t _st_curr_time = 0; /* Current time as returned by time(2) */
st_utime_t _st_last_tset; /* Last time it was fetched */
int st_poll(struct pollfd *pds, int npds, st_utime_t timeout)
{
struct pollfd *pd;
struct pollfd *epd = pds + npds;
_st_pollq_t pq;
_st_thread_t *me = _ST_CURRENT_THREAD();
int n;
if (me->flags & _ST_FL_INTERRUPT) {
me->flags &= ~_ST_FL_INTERRUPT;
errno = EINTR;
return -1;
}
if ((*_st_eventsys->pollset_add)(pds, npds) < 0)
return -1;
pq.pds = pds;
pq.npds = npds;
pq.thread = me;
pq.on_ioq = 1;
_ST_ADD_IOQ(pq);
if (timeout != ST_UTIME_NO_TIMEOUT)
_ST_ADD_SLEEPQ(me, timeout);
me->state = _ST_ST_IO_WAIT;
_ST_SWITCH_CONTEXT(me);
n = 0;
if (pq.on_ioq) {
/* If we timed out, the pollq might still be on the ioq. Remove it */
_ST_DEL_IOQ(pq);
(*_st_eventsys->pollset_del)(pds, npds);
} else {
/* Count the number of ready descriptors */
for (pd = pds; pd < epd; pd++) {
if (pd->revents)
n++;
}
}
if (me->flags & _ST_FL_INTERRUPT) {
me->flags &= ~_ST_FL_INTERRUPT;
errno = EINTR;
return -1;
}
return n;
}
void _st_vp_schedule(void)
{
_st_thread_t *thread;
if (_ST_RUNQ.next != &_ST_RUNQ) {
/* Pull thread off of the run queue */
thread = _ST_THREAD_PTR(_ST_RUNQ.next);
_ST_DEL_RUNQ(thread);
} else {
/* If there are no threads to run, switch to the idle thread */
thread = _st_this_vp.idle_thread;
}
ST_ASSERT(thread->state == _ST_ST_RUNNABLE);
/* Resume the thread */
thread->state = _ST_ST_RUNNING;
_ST_RESTORE_CONTEXT(thread);
}
/*
* Initialize this Virtual Processor
*/
int st_init(void)
{
_st_thread_t *thread;
if (_st_active_count) {
/* Already initialized */
return 0;
}
/* We can ignore return value here */
st_set_eventsys(ST_EVENTSYS_DEFAULT);
if (_st_io_init() < 0)
return -1;
memset(&_st_this_vp, 0, sizeof(_st_vp_t));
ST_INIT_CLIST(&_ST_RUNQ);
ST_INIT_CLIST(&_ST_IOQ);
ST_INIT_CLIST(&_ST_ZOMBIEQ);
#ifdef DEBUG
ST_INIT_CLIST(&_ST_THREADQ);
#endif
if ((*_st_eventsys->init)() < 0)
return -1;
_st_this_vp.pagesize = getpagesize();
_st_this_vp.last_clock = st_utime();
/*
* Create idle thread
*/
_st_this_vp.idle_thread = st_thread_create(_st_idle_thread_start, NULL, 0, 0);
if (!_st_this_vp.idle_thread)
return -1;
_st_this_vp.idle_thread->flags = _ST_FL_IDLE_THREAD;
_st_active_count--;
_ST_DEL_RUNQ(_st_this_vp.idle_thread);
/*
* Initialize primordial thread
*/
thread = (_st_thread_t *) calloc(1, sizeof(_st_thread_t) + (ST_KEYS_MAX * sizeof(void *)));
if (!thread)
return -1;
thread->private_data = (void **) (thread + 1);
thread->state = _ST_ST_RUNNING;
thread->flags = _ST_FL_PRIMORDIAL;
_ST_SET_CURRENT_THREAD(thread);
_st_active_count++;
#ifdef DEBUG
_ST_ADD_THREADQ(thread);
#endif
return 0;
}
#ifdef ST_SWITCH_CB
st_switch_cb_t st_set_switch_in_cb(st_switch_cb_t cb)
{
st_switch_cb_t ocb = _st_this_vp.switch_in_cb;
_st_this_vp.switch_in_cb = cb;
return ocb;
}
st_switch_cb_t st_set_switch_out_cb(st_switch_cb_t cb)
{
st_switch_cb_t ocb = _st_this_vp.switch_out_cb;
_st_this_vp.switch_out_cb = cb;
return ocb;
}
#endif
/*
* Start function for the idle thread
*/
/* ARGSUSED */
void *_st_idle_thread_start(void *arg)
{
_st_thread_t *me = _ST_CURRENT_THREAD();
while (_st_active_count > 0) {
/* Idle vp till I/O is ready or the smallest timeout expired */
_ST_VP_IDLE();
/* Check sleep queue for expired threads */
_st_vp_check_clock();
me->state = _ST_ST_RUNNABLE;
_ST_SWITCH_CONTEXT(me);
}
/* No more threads */
exit(0);
/* NOTREACHED */
return NULL;
}
void st_thread_exit(void *retval)
{
_st_thread_t *thread = _ST_CURRENT_THREAD();
thread->retval = retval;
_st_thread_cleanup(thread);
_st_active_count--;
if (thread->term) {
/* Put thread on the zombie queue */
thread->state = _ST_ST_ZOMBIE;
_ST_ADD_ZOMBIEQ(thread);
/* Notify on our termination condition variable */
st_cond_signal(thread->term);
/* Switch context and come back later */
_ST_SWITCH_CONTEXT(thread);
/* Continue the cleanup */
st_cond_destroy(thread->term);
thread->term = NULL;
}
#ifdef DEBUG
_ST_DEL_THREADQ(thread);
#endif
/* merge from https://github.com/toffaletti/state-threads/commit/7f57fc9acc05e657bca1223f1e5b9b1a45ed929b */
#ifndef NVALGRIND
if (!(thread->flags & _ST_FL_PRIMORDIAL)) {
VALGRIND_STACK_DEREGISTER(thread->stack->valgrind_stack_id);
}
#endif
if (!(thread->flags & _ST_FL_PRIMORDIAL))
_st_stack_free(thread->stack);
/* Find another thread to run */
_ST_SWITCH_CONTEXT(thread);
/* Not going to land here */
}
int st_thread_join(_st_thread_t *thread, void **retvalp)
{
_st_cond_t *term = thread->term;
/* Can't join a non-joinable thread */
if (term == NULL) {
errno = EINVAL;
return -1;
}
if (_ST_CURRENT_THREAD() == thread) {
errno = EDEADLK;
return -1;
}
/* Multiple threads can't wait on the same joinable thread */
if (term->wait_q.next != &term->wait_q) {
errno = EINVAL;
return -1;
}
while (thread->state != _ST_ST_ZOMBIE) {
if (st_cond_timedwait(term, ST_UTIME_NO_TIMEOUT) != 0)
return -1;
}
if (retvalp)
*retvalp = thread->retval;
/*
* Remove target thread from the zombie queue and make it runnable.
* When it gets scheduled later, it will do the clean up.
*/
thread->state = _ST_ST_RUNNABLE;
_ST_DEL_ZOMBIEQ(thread);
_ST_ADD_RUNQ(thread);
return 0;
}
void _st_thread_main(void)
{
_st_thread_t *thread = _ST_CURRENT_THREAD();
/*
* Cap the stack by zeroing out the saved return address register
* value. This allows some debugging/profiling tools to know when
* to stop unwinding the stack. It's a no-op on most platforms.
*/
MD_CAP_STACK(&thread);
/* Run thread main */
thread->retval = (*thread->start)(thread->arg);
/* All done, time to go away */
st_thread_exit(thread->retval);
}
/*
* Insert "thread" into the timeout heap, in the position
* specified by thread->heap_index. See docs/timeout_heap.txt
* for details about the timeout heap.
*/
static _st_thread_t **heap_insert(_st_thread_t *thread) {
int target = thread->heap_index;
int s = target;
_st_thread_t **p = &_ST_SLEEPQ;
int bits = 0;
int bit;
int index = 1;
while (s) {
s >>= 1;
bits++;
}
for (bit = bits - 2; bit >= 0; bit--) {
if (thread->due < (*p)->due) {
_st_thread_t *t = *p;
thread->left = t->left;
thread->right = t->right;
*p = thread;
thread->heap_index = index;
thread = t;
}
index <<= 1;
if (target & (1 << bit)) {
p = &((*p)->right);
index |= 1;
} else {
p = &((*p)->left);
}
}
thread->heap_index = index;
*p = thread;
thread->left = thread->right = NULL;
return p;
}
/*
* Delete "thread" from the timeout heap.
*/
static void heap_delete(_st_thread_t *thread) {
_st_thread_t *t, **p;
int bits = 0;
int s, bit;
/* First find and unlink the last heap element */
p = &_ST_SLEEPQ;
s = _ST_SLEEPQ_SIZE;
while (s) {
s >>= 1;
bits++;
}
for (bit = bits - 2; bit >= 0; bit--) {
if (_ST_SLEEPQ_SIZE & (1 << bit)) {
p = &((*p)->right);
} else {
p = &((*p)->left);
}
}
t = *p;
*p = NULL;
--_ST_SLEEPQ_SIZE;
if (t != thread) {
/*
* Insert the unlinked last element in place of the element we are deleting
*/
t->heap_index = thread->heap_index;
p = heap_insert(t);
t = *p;
t->left = thread->left;
t->right = thread->right;
/*
* Reestablish the heap invariant.
*/
for (;;) {
_st_thread_t *y; /* The younger child */
int index_tmp;
if (t->left == NULL)
break;
else if (t->right == NULL)
y = t->left;
else if (t->left->due < t->right->due)
y = t->left;
else
y = t->right;
if (t->due > y->due) {
_st_thread_t *tl = y->left;
_st_thread_t *tr = y->right;
*p = y;
if (y == t->left) {
y->left = t;
y->right = t->right;
p = &y->left;
} else {
y->left = t->left;
y->right = t;
p = &y->right;
}
t->left = tl;
t->right = tr;
index_tmp = t->heap_index;
t->heap_index = y->heap_index;
y->heap_index = index_tmp;
} else {
break;
}
}
}
thread->left = thread->right = NULL;
}
void _st_add_sleep_q(_st_thread_t *thread, st_utime_t timeout)
{
thread->due = _ST_LAST_CLOCK + timeout;
thread->flags |= _ST_FL_ON_SLEEPQ;
thread->heap_index = ++_ST_SLEEPQ_SIZE;
heap_insert(thread);
}
void _st_del_sleep_q(_st_thread_t *thread)
{
heap_delete(thread);
thread->flags &= ~_ST_FL_ON_SLEEPQ;
}
void _st_vp_check_clock(void)
{
_st_thread_t *thread;
st_utime_t elapsed, now;
now = st_utime();
elapsed = now - _ST_LAST_CLOCK;
_ST_LAST_CLOCK = now;
if (_st_curr_time && now - _st_last_tset > 999000) {
_st_curr_time = time(NULL);
_st_last_tset = now;
}
while (_ST_SLEEPQ != NULL) {
thread = _ST_SLEEPQ;
ST_ASSERT(thread->flags & _ST_FL_ON_SLEEPQ);
if (thread->due > now)
break;
_ST_DEL_SLEEPQ(thread);
/* If thread is waiting on condition variable, set the time out flag */
if (thread->state == _ST_ST_COND_WAIT)
thread->flags |= _ST_FL_TIMEDOUT;
/* Make thread runnable */
ST_ASSERT(!(thread->flags & _ST_FL_IDLE_THREAD));
thread->state = _ST_ST_RUNNABLE;
_ST_ADD_RUNQ(thread);
}
}
void st_thread_interrupt(_st_thread_t *thread)
{
/* If thread is already dead */
if (thread->state == _ST_ST_ZOMBIE)
return;
thread->flags |= _ST_FL_INTERRUPT;
if (thread->state == _ST_ST_RUNNING || thread->state == _ST_ST_RUNNABLE)
return;
if (thread->flags & _ST_FL_ON_SLEEPQ)
_ST_DEL_SLEEPQ(thread);
/* Make thread runnable */
thread->state = _ST_ST_RUNNABLE;
_ST_ADD_RUNQ(thread);
}
/* Merge from https://github.com/michaeltalyansky/state-threads/commit/cce736426c2320ffec7c9820df49ee7a18ae638c */
#if defined(__arm__) && !defined(MD_USE_BUILTIN_SETJMP) && __GLIBC_MINOR__ >= 19
extern unsigned long __pointer_chk_guard;
#define PTR_MANGLE(var) \
(var) = (__typeof (var)) ((unsigned long) (var) ^ __pointer_chk_guard)
#define PTR_DEMANGLE(var) PTR_MANGLE (var)
#endif
_st_thread_t *st_thread_create(void *(*start)(void *arg), void *arg, int joinable, int stk_size)
{
_st_thread_t *thread;
_st_stack_t *stack;
void **ptds;
char *sp;
#ifdef __ia64__
char *bsp;
#endif
/* Adjust stack size */
if (stk_size == 0)
stk_size = ST_DEFAULT_STACK_SIZE;
stk_size = ((stk_size + _ST_PAGE_SIZE - 1) / _ST_PAGE_SIZE) * _ST_PAGE_SIZE;
stack = _st_stack_new(stk_size);
if (!stack)
return NULL;
/* Allocate thread object and per-thread data off the stack */
#if defined (MD_STACK_GROWS_DOWN)
sp = stack->stk_top;
#ifdef __ia64__
/*
* The stack segment is split in the middle. The upper half is used
* as backing store for the register stack which grows upward.
* The lower half is used for the traditional memory stack which
* grows downward. Both stacks start in the middle and grow outward
* from each other.
*/
sp -= (stk_size >> 1);
bsp = sp;
/* Make register stack 64-byte aligned */
if ((unsigned long)bsp & 0x3f)
bsp = bsp + (0x40 - ((unsigned long)bsp & 0x3f));
stack->bsp = bsp + _ST_STACK_PAD_SIZE;
#endif
sp = sp - (ST_KEYS_MAX * sizeof(void *));
ptds = (void **) sp;
sp = sp - sizeof(_st_thread_t);
thread = (_st_thread_t *) sp;
/* Make stack 64-byte aligned */
if ((unsigned long)sp & 0x3f)
sp = sp - ((unsigned long)sp & 0x3f);
stack->sp = sp - _ST_STACK_PAD_SIZE;
#elif defined (MD_STACK_GROWS_UP)
sp = stack->stk_bottom;
thread = (_st_thread_t *) sp;
sp = sp + sizeof(_st_thread_t);
ptds = (void **) sp;
sp = sp + (ST_KEYS_MAX * sizeof(void *));
/* Make stack 64-byte aligned */
if ((unsigned long)sp & 0x3f)
sp = sp + (0x40 - ((unsigned long)sp & 0x3f));
stack->sp = sp + _ST_STACK_PAD_SIZE;
#else
#error Unknown OS
#endif
memset(thread, 0, sizeof(_st_thread_t));
memset(ptds, 0, ST_KEYS_MAX * sizeof(void *));
/* Initialize thread */
thread->private_data = ptds;
thread->stack = stack;
thread->start = start;
thread->arg = arg;
#ifndef __ia64__
/* Merge from https://github.com/michaeltalyansky/state-threads/commit/cce736426c2320ffec7c9820df49ee7a18ae638c */
#if defined(__arm__) && !defined(MD_USE_BUILTIN_SETJMP) && __GLIBC_MINOR__ >= 19
volatile void * lsp = PTR_MANGLE(stack->sp);
if (_setjmp ((thread)->context))
_st_thread_main();
(thread)->context[0].__jmpbuf[8] = (long) (lsp);
#else
_ST_INIT_CONTEXT(thread, stack->sp, _st_thread_main);
#endif
#else
_ST_INIT_CONTEXT(thread, stack->sp, stack->bsp, _st_thread_main);
#endif
/* If thread is joinable, allocate a termination condition variable */
if (joinable) {
thread->term = st_cond_new();
if (thread->term == NULL) {
_st_stack_free(thread->stack);
return NULL;
}
}
/* Make thread runnable */
thread->state = _ST_ST_RUNNABLE;
_st_active_count++;
_ST_ADD_RUNQ(thread);
#ifdef DEBUG
_ST_ADD_THREADQ(thread);
#endif
/* merge from https://github.com/toffaletti/state-threads/commit/7f57fc9acc05e657bca1223f1e5b9b1a45ed929b */
#ifndef NVALGRIND
if (!(thread->flags & _ST_FL_PRIMORDIAL)) {
thread->stack->valgrind_stack_id = VALGRIND_STACK_REGISTER(thread->stack->stk_top, thread->stack->stk_bottom);
}
#endif
return thread;
}
_st_thread_t *st_thread_self(void)
{
return _ST_CURRENT_THREAD();
}
#ifdef DEBUG
/* ARGSUSED */
void _st_show_thread_stack(_st_thread_t *thread, const char *messg)
{
}
/* To be set from debugger */
int _st_iterate_threads_flag = 0;
void _st_iterate_threads(void)
{
static _st_thread_t *thread = NULL;
static jmp_buf orig_jb, save_jb;
_st_clist_t *q;
if (!_st_iterate_threads_flag) {
if (thread) {
memcpy(thread->context, save_jb, sizeof(jmp_buf));
MD_LONGJMP(orig_jb, 1);
}
return;
}
if (thread) {
memcpy(thread->context, save_jb, sizeof(jmp_buf));
_st_show_thread_stack(thread, NULL);
} else {
if (MD_SETJMP(orig_jb)) {
_st_iterate_threads_flag = 0;
thread = NULL;
_st_show_thread_stack(thread, "Iteration completed");
return;
}
thread = _ST_CURRENT_THREAD();
_st_show_thread_stack(thread, "Iteration started");
}
q = thread->tlink.next;
if (q == &_ST_THREADQ)
q = q->next;
ST_ASSERT(q != &_ST_THREADQ);
thread = _ST_THREAD_THREADQ_PTR(q);
if (thread == _ST_CURRENT_THREAD())
MD_LONGJMP(orig_jb, 1);
memcpy(save_jb, thread->context, sizeof(jmp_buf));
MD_LONGJMP(thread->context, 1);
}
#endif /* DEBUG */

10
trunk/3rdparty/st-srs/st.pc.in vendored Normal file
View file

@ -0,0 +1,10 @@
prefix=@prefix@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: libst
Description: State Thread Library
Version: @VERSION@
Libs: -L${libdir} -lst
Cflags: -I${includedir}

79
trunk/3rdparty/st-srs/st.spec vendored Normal file
View file

@ -0,0 +1,79 @@
Summary: State Threads Library
Name: st
Version: 1.9
Release: 1
Copyright: MPL 1.2 or GPL 2+
Packager: Wesley W. Terpstra <wesley@terpstra.ca>
Source: http://prdownloads.sourceforge.net/state-threads/st-%{version}.tar.gz
Prefix: /usr
BuildRoot: /tmp/%{name}-%{version}-build
Group: Development/Libraries
%description
The State Threads library has an interface similar to POSIX threads.
However, the threads are actually all run in-process. This type of
threading allows for controlled schedualing points. It is highly useful
for designing robust and extremely scalable internet applications since
there is no resource contention and locking is generally unnecessary.
It can be combined with traditional threading or multiple process
parallelism to take advantage of multiple processors.
See: <http://state-threads.sourceforge.net/docs/st.html> for further
information about how state threads improve performance.
%package -n libst-devel
Summary: State Threads Library - Development Files
Group: Development/Libraries
Requires: libst1
%description -n libst-devel
Development headers and documentation for libst
%package -n libst1
Summary: State Threads Library - Shared Libs Major 1
Group: System/Libraries
%description -n libst1
Shared libraries for running applications linked against api version 1.
%prep
%setup -q
%build
make CONFIG_GUESS_PATH=/usr/share/automake default-optimized
%install
if [ -d ${RPM_BUILD_ROOT} ]; then rm -rf ${RPM_BUILD_ROOT}; fi
mkdir -m 0755 -p ${RPM_BUILD_ROOT}/%{prefix}/lib/pkgconfig
mkdir -m 0755 -p ${RPM_BUILD_ROOT}/%{prefix}/include
mkdir -m 0755 -p ${RPM_BUILD_ROOT}/%{prefix}/share/doc/libst-devel
cp -a obj/libst.* ${RPM_BUILD_ROOT}/%{prefix}/lib
cp -a obj/st.h ${RPM_BUILD_ROOT}/%{prefix}/include
sed "s*@prefix@*%{prefix}*g" <st.pc >${RPM_BUILD_ROOT}/%{prefix}/lib/pkgconfig/st.pc
cp -a docs/* ${RPM_BUILD_ROOT}/%{prefix}/share/doc/libst-devel/
cp -a examples ${RPM_BUILD_ROOT}/%{prefix}/share/doc/libst-devel/
%post -n libst1
/sbin/ldconfig %{prefix}/lib
%files -n libst1
%defattr(-,root,root)
%{prefix}/lib/lib*.so.*
%files -n libst-devel
%defattr(-,root,root)
%{prefix}/include/*
%{prefix}/lib/lib*.a
%{prefix}/lib/lib*.so
%{prefix}/lib/pkgconfig/st.pc
%{prefix}/share/doc/libst-devel/*
%clean
if [ -d ${RPM_BUILD_ROOT} ]; then rm -rf ${RPM_BUILD_ROOT}; fi
%changelog
* Wed Dec 26 2001 Wesley W. Terpstra <wesley@terpstra.ca>
- first rpms for libst-1.3.tar.gz

173
trunk/3rdparty/st-srs/stk.c vendored Normal file
View file

@ -0,0 +1,173 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Netscape Portable Runtime library.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1994-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s): Silicon Graphics, Inc.
*
* Portions created by SGI are Copyright (C) 2000-2001 Silicon
* Graphics, Inc. All Rights Reserved.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 or later (the
* "GPL"), in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your
* version of this file only under the terms of the GPL and not to
* allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
/*
* This file is derived directly from Netscape Communications Corporation,
* and consists of extensive modifications made during the year(s) 1999-2000.
*/
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include "common.h"
/* How much space to leave between the stacks, at each end */
#define REDZONE _ST_PAGE_SIZE
_st_clist_t _st_free_stacks = ST_INIT_STATIC_CLIST(&_st_free_stacks);
int _st_num_free_stacks = 0;
int _st_randomize_stacks = 0;
static char *_st_new_stk_segment(int size);
_st_stack_t *_st_stack_new(int stack_size)
{
_st_clist_t *qp;
_st_stack_t *ts;
int extra;
for (qp = _st_free_stacks.next; qp != &_st_free_stacks; qp = qp->next) {
ts = _ST_THREAD_STACK_PTR(qp);
if (ts->stk_size >= stack_size) {
/* Found a stack that is big enough */
ST_REMOVE_LINK(&ts->links);
_st_num_free_stacks--;
ts->links.next = NULL;
ts->links.prev = NULL;
return ts;
}
}
/* Make a new thread stack object. */
if ((ts = (_st_stack_t *)calloc(1, sizeof(_st_stack_t))) == NULL)
return NULL;
extra = _st_randomize_stacks ? _ST_PAGE_SIZE : 0;
ts->vaddr_size = stack_size + 2*REDZONE + extra;
ts->vaddr = _st_new_stk_segment(ts->vaddr_size);
if (!ts->vaddr) {
free(ts);
return NULL;
}
ts->stk_size = stack_size;
ts->stk_bottom = ts->vaddr + REDZONE;
ts->stk_top = ts->stk_bottom + stack_size;
#ifdef DEBUG
mprotect(ts->vaddr, REDZONE, PROT_NONE);
mprotect(ts->stk_top + extra, REDZONE, PROT_NONE);
#endif
if (extra) {
long offset = (random() % extra) & ~0xf;
ts->stk_bottom += offset;
ts->stk_top += offset;
}
return ts;
}
/*
* Free the stack for the current thread
*/
void _st_stack_free(_st_stack_t *ts)
{
if (!ts)
return;
/* Put the stack on the free list */
ST_APPEND_LINK(&ts->links, _st_free_stacks.prev);
_st_num_free_stacks++;
}
static char *_st_new_stk_segment(int size)
{
#ifdef MALLOC_STACK
void *vaddr = malloc(size);
#else
static int zero_fd = -1;
int mmap_flags = MAP_PRIVATE;
void *vaddr;
#if defined (MD_USE_SYSV_ANON_MMAP)
if (zero_fd < 0) {
if ((zero_fd = open("/dev/zero", O_RDWR, 0)) < 0)
return NULL;
fcntl(zero_fd, F_SETFD, FD_CLOEXEC);
}
#elif defined (MD_USE_BSD_ANON_MMAP)
mmap_flags |= MAP_ANON;
#else
#error Unknown OS
#endif
vaddr = mmap(NULL, size, PROT_READ | PROT_WRITE, mmap_flags, zero_fd, 0);
if (vaddr == (void *)MAP_FAILED)
return NULL;
#endif /* MALLOC_STACK */
return (char *)vaddr;
}
/* Not used */
#if 0
void _st_delete_stk_segment(char *vaddr, int size)
{
#ifdef MALLOC_STACK
free(vaddr);
#else
(void) munmap(vaddr, size);
#endif
}
#endif
int st_randomize_stacks(int on)
{
int wason = _st_randomize_stacks;
_st_randomize_stacks = on;
if (on)
srandom((unsigned int) st_utime());
return wason;
}

368
trunk/3rdparty/st-srs/sync.c vendored Normal file
View file

@ -0,0 +1,368 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Netscape Portable Runtime library.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1994-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s): Silicon Graphics, Inc.
*
* Portions created by SGI are Copyright (C) 2000-2001 Silicon
* Graphics, Inc. All Rights Reserved.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 or later (the
* "GPL"), in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your
* version of this file only under the terms of the GPL and not to
* allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
/*
* This file is derived directly from Netscape Communications Corporation,
* and consists of extensive modifications made during the year(s) 1999-2000.
*/
#include <stdlib.h>
#include <time.h>
#include <errno.h>
#include "common.h"
extern time_t _st_curr_time;
extern st_utime_t _st_last_tset;
extern int _st_active_count;
static st_utime_t (*_st_utime)(void) = NULL;
/*****************************************
* Time functions
*/
st_utime_t st_utime(void)
{
if (_st_utime == NULL) {
#ifdef MD_GET_UTIME
MD_GET_UTIME();
#else
#error Unknown OS
#endif
}
return (*_st_utime)();
}
int st_set_utime_function(st_utime_t (*func)(void))
{
if (_st_active_count) {
errno = EINVAL;
return -1;
}
_st_utime = func;
return 0;
}
st_utime_t st_utime_last_clock(void)
{
return _ST_LAST_CLOCK;
}
int st_timecache_set(int on)
{
int wason = (_st_curr_time) ? 1 : 0;
if (on) {
_st_curr_time = time(NULL);
_st_last_tset = st_utime();
} else
_st_curr_time = 0;
return wason;
}
time_t st_time(void)
{
if (_st_curr_time)
return _st_curr_time;
return time(NULL);
}
int st_usleep(st_utime_t usecs)
{
_st_thread_t *me = _ST_CURRENT_THREAD();
if (me->flags & _ST_FL_INTERRUPT) {
me->flags &= ~_ST_FL_INTERRUPT;
errno = EINTR;
return -1;
}
if (usecs != ST_UTIME_NO_TIMEOUT) {
me->state = _ST_ST_SLEEPING;
_ST_ADD_SLEEPQ(me, usecs);
} else
me->state = _ST_ST_SUSPENDED;
_ST_SWITCH_CONTEXT(me);
if (me->flags & _ST_FL_INTERRUPT) {
me->flags &= ~_ST_FL_INTERRUPT;
errno = EINTR;
return -1;
}
return 0;
}
int st_sleep(int secs)
{
return st_usleep((secs >= 0) ? secs * (st_utime_t) 1000000LL : ST_UTIME_NO_TIMEOUT);
}
/*****************************************
* Condition variable functions
*/
_st_cond_t *st_cond_new(void)
{
_st_cond_t *cvar;
cvar = (_st_cond_t *) calloc(1, sizeof(_st_cond_t));
if (cvar) {
ST_INIT_CLIST(&cvar->wait_q);
}
return cvar;
}
int st_cond_destroy(_st_cond_t *cvar)
{
if (cvar->wait_q.next != &cvar->wait_q) {
errno = EBUSY;
return -1;
}
free(cvar);
return 0;
}
int st_cond_timedwait(_st_cond_t *cvar, st_utime_t timeout)
{
_st_thread_t *me = _ST_CURRENT_THREAD();
int rv;
if (me->flags & _ST_FL_INTERRUPT) {
me->flags &= ~_ST_FL_INTERRUPT;
errno = EINTR;
return -1;
}
/* Put caller thread on the condition variable's wait queue */
me->state = _ST_ST_COND_WAIT;
ST_APPEND_LINK(&me->wait_links, &cvar->wait_q);
if (timeout != ST_UTIME_NO_TIMEOUT)
_ST_ADD_SLEEPQ(me, timeout);
_ST_SWITCH_CONTEXT(me);
ST_REMOVE_LINK(&me->wait_links);
rv = 0;
if (me->flags & _ST_FL_TIMEDOUT) {
me->flags &= ~_ST_FL_TIMEDOUT;
errno = ETIME;
rv = -1;
}
if (me->flags & _ST_FL_INTERRUPT) {
me->flags &= ~_ST_FL_INTERRUPT;
errno = EINTR;
rv = -1;
}
return rv;
}
int st_cond_wait(_st_cond_t *cvar)
{
return st_cond_timedwait(cvar, ST_UTIME_NO_TIMEOUT);
}
static int _st_cond_signal(_st_cond_t *cvar, int broadcast)
{
_st_thread_t *thread;
_st_clist_t *q;
for (q = cvar->wait_q.next; q != &cvar->wait_q; q = q->next) {
thread = _ST_THREAD_WAITQ_PTR(q);
if (thread->state == _ST_ST_COND_WAIT) {
if (thread->flags & _ST_FL_ON_SLEEPQ)
_ST_DEL_SLEEPQ(thread);
/* Make thread runnable */
thread->state = _ST_ST_RUNNABLE;
_ST_ADD_RUNQ(thread);
if (!broadcast)
break;
}
}
return 0;
}
int st_cond_signal(_st_cond_t *cvar)
{
return _st_cond_signal(cvar, 0);
}
int st_cond_broadcast(_st_cond_t *cvar)
{
return _st_cond_signal(cvar, 1);
}
/*****************************************
* Mutex functions
*/
_st_mutex_t *st_mutex_new(void)
{
_st_mutex_t *lock;
lock = (_st_mutex_t *) calloc(1, sizeof(_st_mutex_t));
if (lock) {
ST_INIT_CLIST(&lock->wait_q);
lock->owner = NULL;
}
return lock;
}
int st_mutex_destroy(_st_mutex_t *lock)
{
if (lock->owner != NULL || lock->wait_q.next != &lock->wait_q) {
errno = EBUSY;
return -1;
}
free(lock);
return 0;
}
int st_mutex_lock(_st_mutex_t *lock)
{
_st_thread_t *me = _ST_CURRENT_THREAD();
if (me->flags & _ST_FL_INTERRUPT) {
me->flags &= ~_ST_FL_INTERRUPT;
errno = EINTR;
return -1;
}
if (lock->owner == NULL) {
/* Got the mutex */
lock->owner = me;
return 0;
}
if (lock->owner == me) {
errno = EDEADLK;
return -1;
}
/* Put caller thread on the mutex's wait queue */
me->state = _ST_ST_LOCK_WAIT;
ST_APPEND_LINK(&me->wait_links, &lock->wait_q);
_ST_SWITCH_CONTEXT(me);
ST_REMOVE_LINK(&me->wait_links);
if ((me->flags & _ST_FL_INTERRUPT) && lock->owner != me) {
me->flags &= ~_ST_FL_INTERRUPT;
errno = EINTR;
return -1;
}
return 0;
}
int st_mutex_unlock(_st_mutex_t *lock)
{
_st_thread_t *thread;
_st_clist_t *q;
if (lock->owner != _ST_CURRENT_THREAD()) {
errno = EPERM;
return -1;
}
for (q = lock->wait_q.next; q != &lock->wait_q; q = q->next) {
thread = _ST_THREAD_WAITQ_PTR(q);
if (thread->state == _ST_ST_LOCK_WAIT) {
lock->owner = thread;
/* Make thread runnable */
thread->state = _ST_ST_RUNNABLE;
_ST_ADD_RUNQ(thread);
return 0;
}
}
/* No threads waiting on this mutex */
lock->owner = NULL;
return 0;
}
int st_mutex_trylock(_st_mutex_t *lock)
{
if (lock->owner != NULL) {
errno = EBUSY;
return -1;
}
/* Got the mutex */
lock->owner = _ST_CURRENT_THREAD();
return 0;
}

Binary file not shown.

Binary file not shown.

36
trunk/Dockerfile Normal file
View file

@ -0,0 +1,36 @@
FROM ossrs/srs:dev AS build
# Install depends tools.
RUN yum install -y gcc make gcc-c++ patch unzip perl git
# Build and install SRS.
COPY . /srs
WORKDIR /srs/trunk
RUN ./configure --jobs=2 && make -j2 && make install
# All config files for SRS.
RUN cp -R conf /usr/local/srs/conf
# The default index.html and srs-console.
RUN cp research/api-server/static-dir/index.html /usr/local/srs/objs/nginx/html/
RUN cp research/api-server/static-dir/favicon.ico /usr/local/srs/objs/nginx/html/
RUN cp research/players/crossdomain.xml /usr/local/srs/objs/nginx/html/
RUN cp -R research/console /usr/local/srs/objs/nginx/html/
RUN cp -R research/players /usr/local/srs/objs/nginx/html/
#RUN cp -R 3rdparty/signaling/www/demos /usr/local/srs/objs/nginx/html/
############################################################
# dist
############################################################
FROM centos:7 AS dist
# Expose ports for live streaming
EXPOSE 1935 1985 8080
# FFMPEG 4.1
COPY --from=build /usr/local/bin/ffmpeg /usr/local/srs/objs/ffmpeg/bin/ffmpeg
# SRS binary, config files and srs-console.
COPY --from=build /usr/local/srs /usr/local/srs
# Default workdir and command.
WORKDIR /usr/local/srs
CMD ["./objs/srs", "-c", "conf/srs.conf"]

9
trunk/Dockerfile.cov Normal file
View file

@ -0,0 +1,9 @@
FROM ossrs/srs:dev
# Install depends tools.
RUN yum install -y gcc make gcc-c++ patch unzip perl git
# Build and install SRS.
COPY . /srs
WORKDIR /srs/trunk
RUN ./configure --with-utest --gcov --jobs=2 && make -j2

9
trunk/Dockerfile.test Normal file
View file

@ -0,0 +1,9 @@
FROM ossrs/srs:dev
# Install depends tools.
RUN yum install -y gcc make gcc-c++ patch unzip perl git
# Build and install SRS.
COPY . /srs
WORKDIR /srs/trunk
RUN ./configure --with-utest --jobs=2 && make -j2

View file

@ -17,12 +17,14 @@ FILE=${SRS_OBJS}/${SRS_MAKEFILE}
APP_TARGET="${SRS_OBJS_DIR}/${APP_NAME}"
echo "generate app ${APP_NAME} depends...";
echo "Generating app ${APP_NAME} depends.";
echo "# build ${APP_TARGET}" >> ${FILE}
# generate the binary depends, for example:
# srs: objs/srs
echo "${BUILD_KEY}: ${APP_TARGET}" >> ${FILE}
echo "" >> ${FILE}
# the link commands, for example:
# objs/srs: objs/src/core/srs_core.o
echo -n "${APP_TARGET}: " >> ${FILE}
@ -52,7 +54,7 @@ for item in ${MODULE_OBJS[*]}; do
done
echo "" >> ${FILE}
echo "generate app ${APP_NAME} link...";
echo "Generating app ${APP_NAME} link.";
# genereate the actual link command, for example:
# $(LINK) -o objs/srs objs/src/core/srs_core.o -ldl
@ -88,5 +90,6 @@ done
# link options.
echo -n "${LINK_OPTIONS}" >> ${FILE}
echo "" >> ${FILE}
echo "" >> ${FILE}
echo -n "generate app ${APP_NAME} ok"; echo '!';
echo -n "Generate app ${APP_NAME} ok"; echo '!';

View file

@ -11,6 +11,7 @@ echo "#ifndef SRS_AUTO_HEADER_HPP" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_AUTO_HEADER_HPP" >> $SRS_AUTO_HEADERS_H
echo "" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_AUTO_PACKAGER \"${SRS_AUTO_PACKAGER}\"" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_AUTO_BUILD_TS \"`date +%s`\"" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_AUTO_BUILD_DATE \"`date \"+%Y-%m-%d %H:%M:%S\"`\"" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_AUTO_UNAME \"`uname -a`\"" >> $SRS_AUTO_HEADERS_H
@ -18,24 +19,36 @@ echo "#define SRS_AUTO_USER_CONFIGURE \"${SRS_AUTO_USER_CONFIGURE}\"" >> $SRS_AU
echo "#define SRS_AUTO_CONFIGURE \"${SRS_AUTO_CONFIGURE}\"" >> $SRS_AUTO_HEADERS_H
echo "" >> $SRS_AUTO_HEADERS_H
function srs_define_macro()
{
macro=$1 && file=$2
echo "#define $macro" >> $file
echo "#define ${macro}_BOOL true" >> $file
}
function srs_define_macro_value()
{
macro=$1 && value=$2 && file=$3
echo "#define $macro $value" >> $file
echo "#define ${macro}_BOOL true" >> $file
}
function srs_undefine_macro()
{
macro=$1 && file=$2
echo "#undef $macro" >> $file
echo "#define ${macro}_BOOL false" >> $file
}
# export the preset.
if [ $SRS_OSX = YES ]; then
echo "#define SRS_OSX" >> $SRS_AUTO_HEADERS_H
fi
if [ $SRS_X86_X64 = YES ]; then
echo "#define SRS_X86_X64" >> $SRS_AUTO_HEADERS_H
fi
if [ $SRS_ARM_UBUNTU12 = YES ]; then
echo "#define SRS_ARM_UBUNTU12" >> $SRS_AUTO_HEADERS_H
fi
if [ $SRS_MIPS_UBUNTU12 = YES ]; then
echo "#define SRS_MIPS_UBUNTU12" >> $SRS_AUTO_HEADERS_H
srs_define_macro "SRS_X86_X64" $SRS_AUTO_HEADERS_H
fi
if [ $SRS_PI = YES ]; then
echo "#define SRS_PI" >> $SRS_AUTO_HEADERS_H
srs_define_macro "SRS_PI" $SRS_AUTO_HEADERS_H
fi
if [ $SRS_CUBIE = YES ]; then
echo "#define SRS_CUBIE" >> $SRS_AUTO_HEADERS_H
srs_define_macro "SRS_CUBIE" $SRS_AUTO_HEADERS_H
fi
if [ $SRS_EXPORT_LIBRTMP_PROJECT != NO ]; then
echo "#define SRS_EXPORT_LIBRTMP" >> $SRS_AUTO_HEADERS_H
@ -48,176 +61,87 @@ echo "" >> $SRS_AUTO_HEADERS_H
#####################################################################################
# generate auto headers file, depends on the finished of options.sh
#####################################################################################
# write to source file
if [ $SRS_CROSS_BUILD = YES ]; then
echo "cc=$SrsArmCC gcc=$SrsArmGCC g++=$SrsArmCXX ar=$SrsArmAR ld=$SrsArmLD randlib=$SrsArmRANDLIB"
echo "#define SRS_AUTO_EMBEDED_TOOL_CHAIN \"cc=$SrsArmCC gcc=$SrsArmGCC g++=$SrsArmCXX ar=$SrsArmAR ld=$SrsArmLD randlib=$SrsArmRANDLIB\"" >> $SRS_AUTO_HEADERS_H
else
echo "#define SRS_AUTO_EMBEDED_TOOL_CHAIN \"normal x86/x64 gcc\"" >> $SRS_AUTO_HEADERS_H
fi
echo "" >> $SRS_AUTO_HEADERS_H
# auto headers in depends.
if [ $SRS_HTTP_CORE = YES ]; then
echo "#define SRS_AUTO_HTTP_CORE" >> $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_HTTP_CORE" >> $SRS_AUTO_HEADERS_H
fi
if [ $SRS_HTTP_SERVER = YES ]; then
echo "#define SRS_AUTO_HTTP_SERVER" >> $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_HTTP_SERVER" >> $SRS_AUTO_HEADERS_H
fi
if [ $SRS_STREAM_CASTER = YES ]; then
echo "#define SRS_AUTO_STREAM_CASTER" >> $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_STREAM_CASTER" >> $SRS_AUTO_HEADERS_H
fi
if [ $SRS_HTTP_API = YES ]; then
echo "#define SRS_AUTO_HTTP_API" >> $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_HTTP_API" >> $SRS_AUTO_HEADERS_H
fi
if [ $SRS_NGINX = YES ]; then
echo "#define SRS_AUTO_NGINX" >> $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_NGINX" >> $SRS_AUTO_HEADERS_H
fi
if [ $SRS_DVR = YES ]; then
echo "#define SRS_AUTO_DVR" >> $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_DVR" >> $SRS_AUTO_HEADERS_H
fi
if [ $SRS_HLS = YES ]; then
echo "#define SRS_AUTO_HLS" >> $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_HLS" >> $SRS_AUTO_HEADERS_H
fi
if [ $SRS_HDS = YES ]; then
echo "#define SRS_AUTO_HDS" >> $SRS_AUTO_HEADERS_H
srs_define_macro "SRS_AUTO_HDS" $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_HDS" >> $SRS_AUTO_HEADERS_H
fi
if [ $SRS_HTTP_CALLBACK = YES ]; then
echo "#define SRS_AUTO_HTTP_CALLBACK" >> $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_HTTP_CALLBACK" >> $SRS_AUTO_HEADERS_H
fi
if [ $SRS_SSL = YES ]; then
echo "#define SRS_AUTO_SSL" >> $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_SSL" >> $SRS_AUTO_HEADERS_H
srs_undefine_macro "SRS_AUTO_HDS" $SRS_AUTO_HEADERS_H
fi
if [ $SRS_MEM_WATCH = YES ]; then
echo "#define SRS_AUTO_MEM_WATCH" >> $SRS_AUTO_HEADERS_H
srs_define_macro "SRS_AUTO_MEM_WATCH" $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_MEM_WATCH" >> $SRS_AUTO_HEADERS_H
srs_undefine_macro "SRS_AUTO_MEM_WATCH" $SRS_AUTO_HEADERS_H
fi
# whether compile ffmpeg tool
if [ $SRS_FFMPEG_TOOL = YES ]; then
echo "#define SRS_AUTO_FFMPEG_TOOL" >> $SRS_AUTO_HEADERS_H
if [ $SRS_UTEST = YES ]; then
srs_define_macro "SRS_AUTO_UTEST" $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_FFMPEG_TOOL" >> $SRS_AUTO_HEADERS_H
srs_undefine_macro "SRS_AUTO_UTEST" $SRS_AUTO_HEADERS_H
fi
# whatever the FFMPEG tools, if transcode and ingest specified,
# srs always compile the FFMPEG tool stub which used to start the FFMPEG process.
if [ $SRS_FFMPEG_STUB = YES ]; then
echo "#define SRS_AUTO_FFMPEG_STUB" >> $SRS_AUTO_HEADERS_H
srs_define_macro "SRS_AUTO_FFMPEG_STUB" $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_FFMPEG_STUB" >> $SRS_AUTO_HEADERS_H
fi
if [ $SRS_TRANSCODE = YES ]; then
echo "#define SRS_AUTO_TRANSCODE" >> $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_TRANSCODE" >> $SRS_AUTO_HEADERS_H
fi
if [ $SRS_INGEST = YES ]; then
echo "#define SRS_AUTO_INGEST" >> $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_INGEST" >> $SRS_AUTO_HEADERS_H
fi
# for statistic.
if [ $SRS_STAT = YES ]; then
echo "#define SRS_AUTO_STAT" >> $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_STAT" >> $SRS_AUTO_HEADERS_H
srs_undefine_macro "SRS_AUTO_FFMPEG_STUB" $SRS_AUTO_HEADERS_H
fi
if [ $SRS_GPERF = YES ]; then
echo "#define SRS_AUTO_GPERF" >> $SRS_AUTO_HEADERS_H
srs_define_macro "SRS_AUTO_GPERF" $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_GPERF" >> $SRS_AUTO_HEADERS_H
srs_undefine_macro "SRS_AUTO_GPERF" $SRS_AUTO_HEADERS_H
fi
if [ $SRS_GPERF_MC = YES ]; then
echo "#define SRS_AUTO_GPERF_MC" >> $SRS_AUTO_HEADERS_H
srs_define_macro "SRS_AUTO_GPERF_MC" $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_GPERF_MC" >> $SRS_AUTO_HEADERS_H
srs_undefine_macro "SRS_AUTO_GPERF_MC" $SRS_AUTO_HEADERS_H
fi
if [ $SRS_GPERF_MD = YES ]; then
srs_define_macro "SRS_AUTO_GPERF_MD" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_AUTO_GPERF_MD" $SRS_AUTO_HEADERS_H
fi
if [ $SRS_GPERF_MP = YES ]; then
echo "#define SRS_AUTO_GPERF_MP" >> $SRS_AUTO_HEADERS_H
srs_define_macro "SRS_AUTO_GPERF_MP" $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_GPERF_MP" >> $SRS_AUTO_HEADERS_H
srs_undefine_macro "SRS_AUTO_GPERF_MP" $SRS_AUTO_HEADERS_H
fi
if [ $SRS_GPERF_CP = YES ]; then
echo "#define SRS_AUTO_GPERF_CP" >> $SRS_AUTO_HEADERS_H
srs_define_macro "SRS_AUTO_GPERF_CP" $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_GPERF_CP" >> $SRS_AUTO_HEADERS_H
srs_undefine_macro "SRS_AUTO_GPERF_CP" $SRS_AUTO_HEADERS_H
fi
#####################################################################################
# for embeded.
#####################################################################################
if [ $SRS_CROSS_BUILD = YES ]; then
echo "#define SRS_AUTO_EMBEDED_CPU" >> $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_EMBEDED_CPU" >> $SRS_AUTO_HEADERS_H
fi
# arm
if [ $SRS_ARM_UBUNTU12 = YES ]; then
echo "#define SRS_AUTO_ARM_UBUNTU12" >> $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_ARM_UBUNTU12" >> $SRS_AUTO_HEADERS_H
fi
# mips
if [ $SRS_MIPS_UBUNTU12 = YES ]; then
echo "#define SRS_AUTO_MIPS_UBUNTU12" >> $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_MIPS_UBUNTU12" >> $SRS_AUTO_HEADERS_H
fi
echo "" >> $SRS_AUTO_HEADERS_H
# for log level compile settings
if [ $SRS_LOG_VERBOSE = YES ]; then
echo "#define SRS_AUTO_VERBOSE" >> $SRS_AUTO_HEADERS_H
srs_define_macro "SRS_AUTO_VERBOSE" $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_VERBOSE" >> $SRS_AUTO_HEADERS_H
srs_undefine_macro "SRS_AUTO_VERBOSE" $SRS_AUTO_HEADERS_H
fi
if [ $SRS_LOG_INFO = YES ]; then
echo "#define SRS_AUTO_INFO" >> $SRS_AUTO_HEADERS_H
srs_define_macro "SRS_AUTO_INFO" $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_INFO" >> $SRS_AUTO_HEADERS_H
srs_undefine_macro "SRS_AUTO_INFO" $SRS_AUTO_HEADERS_H
fi
if [ $SRS_LOG_TRACE = YES ]; then
echo "#define SRS_AUTO_TRACE" >> $SRS_AUTO_HEADERS_H
srs_define_macro "SRS_AUTO_TRACE" $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_AUTO_TRACE" >> $SRS_AUTO_HEADERS_H
srs_undefine_macro "SRS_AUTO_TRACE" $SRS_AUTO_HEADERS_H
fi
if [ $SRS_CROSS_BUILD = YES ]; then
srs_define_macro "SRS_AUTO_CROSSBUILD" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_AUTO_CROSSBUILD" $SRS_AUTO_HEADERS_H
fi
if [ $SRS_OSX = YES ]; then
srs_define_macro "SRS_AUTO_OSX" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_AUTO_OSX" $SRS_AUTO_HEADERS_H
fi
# prefix
@ -229,17 +153,23 @@ echo "" >> $SRS_AUTO_HEADERS_H
#####################################################################################
# generated the contributors from AUTHORS.txt
#####################################################################################
SRS_CONSTRIBUTORS=`cat ../AUTHORS.txt|grep "*"|awk '{print $2}'`
echo "#define SRS_AUTO_CONSTRIBUTORS \"\\" >> $SRS_AUTO_HEADERS_H
for CONTRIBUTOR in $SRS_CONSTRIBUTORS; do
echo "${CONTRIBUTOR} \\" >> $SRS_AUTO_HEADERS_H
done
echo "\"" >> $SRS_AUTO_HEADERS_H
if [[ -f ../AUTHORS.txt ]]; then
SRS_CONSTRIBUTORS=`cat ../AUTHORS.txt|grep "*"|awk '{print $2}'`
echo "#define SRS_AUTO_CONSTRIBUTORS \"\\" >> $SRS_AUTO_HEADERS_H
for CONTRIBUTOR in $SRS_CONSTRIBUTORS; do
echo "${CONTRIBUTOR} \\" >> $SRS_AUTO_HEADERS_H
done
echo "\"" >> $SRS_AUTO_HEADERS_H
else
echo "#define SRS_AUTO_CONSTRIBUTORS \"ossrs\"" >> $SRS_AUTO_HEADERS_H
fi
# new empty line to auto headers file.
echo "" >> $SRS_AUTO_HEADERS_H
#####################################################################################
# auto header EOF.
#####################################################################################
echo "#endif" >> $SRS_AUTO_HEADERS_H
echo "" >> $SRS_AUTO_HEADERS_H

View file

@ -76,7 +76,6 @@ else
cd $ff_current_dir &&
rm -rf x264-snapshot-20181116-2245 && unzip -q ${ff_src_dir}/x264-snapshot-20181116-2245.zip &&
cd x264-snapshot-20181116-2245 &&
# chmod +w configure && patch -p0 <../../../3rdparty/patches/5.x264.osx.gcc.patch &&
./configure --prefix=${ff_release_dir} --disable-opencl --bit-depth=all \
--enable-static --disable-avs --disable-swscale --disable-lavf \
--disable-ffms --disable-gpac --disable-cli &&

45
trunk/auto/coverage.sh Normal file
View file

@ -0,0 +1,45 @@
#!/bin/bash
# In .circleci/config.yml, generate *.gcno with
# ./configure --gcov --with-utest --without-research --without-librtmp && make
# and generate *.gcda by
# ./objs/srs_utest
# Workdir is objs/cover.
workdir=`pwd`/objs/cover
# Create trunk under workdir.
mkdir -p $workdir && cd $workdir
ret=$?; if [[ $ret -ne 0 ]]; then echo "Enter workdir failed, ret=$ret"; exit $ret; fi
CODECOV_ARGS=""
if [[ $SRS_PROJECT != '' ]]; then
# -R root dir Used when not in git/hg project to identify project root directory
# -p dir Project root directory. Also used when preparing gcov
CODECOV_ARGS="$CODECOV_ARGS -R $SRS_PROJECT -p $SRS_PROJECT"
fi
if [[ $SRS_BRANCH != '' ]]; then
# -B branch Specify the branch name
CODECOV_ARGS="$CODECOV_ARGS -B $SRS_BRANCH"
fi
if [[ $SRS_SHA != '' ]]; then
# -C sha Specify the commit sha
CODECOV_ARGS="$CODECOV_ARGS -C $SRS_SHA"
fi
if [[ $SRS_PR != '' ]]; then
# -P pr Specify the pull request number
CODECOV_ARGS="$CODECOV_ARGS -P $SRS_PR"
fi
# Upload report with *.gcov
# Remark: The file codecov.yml is not neccessary. It literally depends on git.
# Note: The right path is like:
# https://codecov.io/gh/ossrs/srs/src/3.0release/trunk/src/protocol/srs_rtmp_stack.cpp
# https://codecov.io/gh/ossrs/srs/src/20fbb4466fdc8ba5d810b8570df6004063212838/trunk/src/protocol/srs_rtmp_stack.cpp
# Remark: It takes a few minutes to sync with github, so it might not available when CircleCI is done.
# https://circleci.com/gh/ossrs/srs/tree/3.0release
cd $workdir &&
export CODECOV_TOKEN="493bba46-c468-4e73-8b45-8cdd8ff62d96" &&
bash <(curl -s https://codecov.io/bash) $CODECOV_ARGS &&
echo "Done" && exit 0

View file

@ -25,8 +25,8 @@ function require_sudoer()
}
# TODO: check gcc/g++
echo "check gcc/g++/gdb/make"
echo "depends tools are ok"
echo "Checking gcc/g++/gdb/make."
echo "Required tools are ok."
#####################################################################################
# for Ubuntu, auto install tools by apt-get
#####################################################################################
@ -34,7 +34,7 @@ OS_IS_UBUNTU=NO
function Ubuntu_prepare()
{
if [ $SRS_CUBIE = YES ]; then
echo "for cubieboard, use ubuntu prepare"
echo "For cubieboard, please use ubuntu prepare."
else
uname -v|grep Ubuntu >/dev/null 2>&1
ret=$?; if [[ 0 -ne $ret ]]; then
@ -45,102 +45,71 @@ function Ubuntu_prepare()
fi
fi
fi
# cross build for arm, install the cross build tool chain.
if [ $SRS_ARM_UBUNTU12 = YES ]; then
$SrsArmCC --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi"
require_sudoer "sudo apt-get install -y --force-yes gcc-arm-linux-gnueabi g++-arm-linux-gnueabi"
sudo apt-get install -y --force-yes gcc-arm-linux-gnueabi g++-arm-linux-gnueabi; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi success"
fi
fi
# cross build for mips, user must installed the tool chain.
if [ $SRS_MIPS_UBUNTU12 = YES ]; then
$SrsArmCC --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "user must install the tool chain: $SrsArmCC"
return 2
fi
fi
OS_IS_UBUNTU=YES
echo "Ubuntu detected, install tools if needed"
echo "Installing tools for Ubuntu."
gcc --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install gcc"
echo "Installing gcc."
require_sudoer "sudo apt-get install -y --force-yes gcc"
sudo apt-get install -y --force-yes gcc; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install gcc success"
echo "The gcc is installed."
fi
g++ --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install g++"
echo "Installing g++."
require_sudoer "sudo apt-get install -y --force-yes g++"
sudo apt-get install -y --force-yes g++; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install g++ success"
echo "The g++ is installed."
fi
make --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install make"
echo "Installing make."
require_sudoer "sudo apt-get install -y --force-yes make"
sudo apt-get install -y --force-yes make; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install make success"
echo "The make is installed."
fi
patch --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install patch"
echo "Installing patch."
require_sudoer "sudo apt-get install -y --force-yes patch"
sudo apt-get install -y --force-yes patch; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install patch success"
echo "The patch is installed."
fi
unzip --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install unzip"
echo "Installing unzip."
require_sudoer "sudo apt-get install -y --force-yes unzip"
sudo apt-get install -y --force-yes unzip; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install unzip success"
echo "The unzip is installed."
fi
if [ $SRS_NGINX = YES ]; then
if [[ ! -f /usr/include/pcre.h ]]; then
echo "install libpcre3-dev"
require_sudoer "sudo apt-get install -y --force-yes libpcre3-dev"
sudo apt-get install -y --force-yes libpcre3-dev; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install libpcre3-dev success"
if [[ $SRS_VALGRIND == YES ]]; then
valgrind --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "Installing valgrind."
require_sudoer "sudo apt-get install -y --force-yes valgrind"
sudo apt-get install -y --force-yes valgrind; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "The valgrind is installed."
fi
fi
if [[ $SRS_VALGRIND == YES ]]; then
if [[ ! -f /usr/include/valgrind/valgrind.h ]]; then
echo "Installing valgrind-dev."
require_sudoer "sudo apt-get install -y --force-yes valgrind-dbg"
sudo apt-get install -y --force-yes valgrind-dev; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "The valgrind-dev is installed."
fi
fi
if [ $SRS_FFMPEG_TOOL = YES ]; then
autoconf --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install autoconf"
require_sudoer "sudo apt-get install -y --force-yes autoconf"
sudo apt-get install -y --force-yes autoconf; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install autoconf success"
fi
libtool --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install libtool"
require_sudoer "sudo apt-get install -y --force-yes libtool"
sudo apt-get install -y --force-yes libtool; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install libtool success"
fi
if [[ ! -f /usr/include/zlib.h ]]; then
echo "install zlib1g-dev"
require_sudoer "sudo apt-get install -y --force-yes zlib1g-dev"
sudo apt-get install -y --force-yes zlib1g-dev; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install zlib1g-dev success"
fi
fi
echo "Ubuntu install tools success"
echo "Tools for Ubuntu are installed."
return 0
}
# donot prepare tools, for srs-librtmp depends only gcc and g++.
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
Ubuntu_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "Ubuntu prepare failed, ret=$ret"; exit $ret; fi
Ubuntu_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "Install tools for ubuntu failed, ret=$ret"; exit $ret; fi
fi
#####################################################################################
# for Centos, auto install tools by yum
#####################################################################################
@ -150,99 +119,73 @@ function Centos_prepare()
if [[ ! -f /etc/redhat-release ]]; then
return 0;
fi
# cross build for arm, install the cross build tool chain.
if [ $SRS_CROSS_BUILD = YES ]; then
echo "embeded(arm/mips) is invalid for CentOS"
return 1
fi
OS_IS_CENTOS=YES
echo "Centos detected, install tools if needed"
echo "Installing tools for Centos."
gcc --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install gcc"
echo "Installing gcc."
require_sudoer "sudo yum install -y gcc"
sudo yum install -y gcc; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install gcc success"
echo "The gcc is installed."
fi
g++ --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install gcc-c++"
echo "Installing gcc-c++."
require_sudoer "sudo yum install -y gcc-c++"
sudo yum install -y gcc-c++; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install gcc-c++ success"
echo "The gcc-c++ is installed."
fi
make --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install make"
echo "Installing make."
require_sudoer "sudo yum install -y make"
sudo yum install -y make; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install make success"
echo "The make is installed."
fi
patch --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install patch"
echo "Installing patch."
require_sudoer "sudo yum install -y patch"
sudo yum install -y patch; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install patch success"
echo "The patch is installed."
fi
unzip --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install unzip"
echo "Installing unzip."
require_sudoer "sudo yum install -y unzip"
sudo yum install -y unzip; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install unzip success"
echo "The unzip is installed."
fi
if [ $SRS_NGINX = YES ]; then
if [[ ! -f /usr/include/pcre.h ]]; then
echo "install pcre-devel"
require_sudoer "sudo yum install -y pcre-devel"
sudo yum install -y pcre-devel; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install pcre-devel success"
if [[ $SRS_VALGRIND == YES ]]; then
valgrind --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "Installing valgrind."
require_sudoer "sudo yum install -y valgrind"
sudo yum install -y valgrind; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "The valgrind is installed."
fi
fi
if [[ $SRS_VALGRIND == YES ]]; then
if [[ ! -f /usr/include/valgrind/valgrind.h ]]; then
echo "Installing valgrind-devel."
require_sudoer "sudo yum install -y valgrind-devel"
sudo yum install -y valgrind-devel; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "The valgrind-devel is installed."
fi
fi
if [ $SRS_FFMPEG_TOOL = YES ]; then
automake --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install automake"
require_sudoer "sudo yum install -y automake"
sudo yum install -y automake; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install automake success"
fi
autoconf --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install autoconf"
require_sudoer "sudo yum install -y autoconf"
sudo yum install -y autoconf; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install autoconf success"
fi
libtool --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install libtool"
require_sudoer "sudo yum install -y libtool"
sudo yum install -y libtool; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install libtool success"
fi
if [[ ! -f /usr/include/zlib.h ]]; then
echo "install zlib-devel"
require_sudoer "sudo yum install -y zlib-devel"
sudo yum install -y zlib-devel; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install zlib-devel success"
fi
fi
echo "Centos install tools success"
echo "Tools for Centos are installed."
return 0
}
# donot prepare tools, for srs-librtmp depends only gcc and g++.
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
Centos_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "CentOS prepare failed, ret=$ret"; exit $ret; fi
Centos_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "Install tools for CentOS failed, ret=$ret"; exit $ret; fi
fi
#####################################################################################
# for Centos, auto install tools by yum
# For OSX, auto install tools by brew
#####################################################################################
OS_IS_OSX=NO
function OSX_prepare()
@ -255,7 +198,7 @@ function OSX_prepare()
fi
return 0;
fi
# cross build for arm, install the cross build tool chain.
if [ $SRS_CROSS_BUILD = YES ]; then
echo "embeded(arm/mips) is invalid for OSX"
@ -278,35 +221,35 @@ function OSX_prepare()
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install brew success"
fi
gcc --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install gcc"
echo "brew install gcc"
brew install gcc; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install gcc success"
fi
g++ --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install gcc-c++"
echo "brew install gcc-c++"
brew install gcc-c++; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install gcc-c++ success"
fi
make --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install make"
echo "brew install make"
brew install make; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install make success"
fi
patch --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install patch"
echo "brew install patch"
brew install patch; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install patch success"
fi
unzip --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install unzip"
echo "brew install unzip"
@ -314,45 +257,6 @@ function OSX_prepare()
echo "install unzip success"
fi
if [ $SRS_NGINX = YES ]; then
if [[ ! -f /usr/local/include/pcre.h ]]; then
echo "install pcre"
echo "brew install pcre"
brew install pcre; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install pcre success"
fi
fi
if [ $SRS_FFMPEG_TOOL = YES ]; then
automake --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install automake"
echo "brew install automake"
brew install automake; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install automake success"
fi
autoconf --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install autoconf"
echo "brew install autoconf"
brew install autoconf; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install autoconf success"
fi
which libtool >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install libtool"
echo "brew install libtool"
brew install libtool; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install libtool success"
fi
brew info zlib >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install zlib"
echo "brew install zlib"
brew install zlib; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install zlib success"
fi
fi
echo "OSX install tools success"
return 0
}
@ -361,14 +265,17 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
OSX_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "OSX prepare failed, ret=$ret"; exit $ret; fi
fi
# the sed command
#####################################################################################
# for Centos, auto install tools by yum
#####################################################################################
# We must use a bash function instead of variable.
function sed_utility() {
if [ $OS_IS_OSX = YES ]; then
sed -i '' "$@"
else
sed -i "$@"
fi
ret=$?; if [[ $ret -ne 0 ]]; then
if [ $OS_IS_OSX = YES ]; then
echo "sed -i '' \"$@\""
@ -383,118 +290,69 @@ SED="sed_utility" && echo "SED is $SED"
#####################################################################################
# check the os.
#####################################################################################
# user must specifies something what a fuck, we suppport following os:
# centos/ubuntu/osx,
# Only supports:
# linux, centos/ubuntu as such,
# cross build for embeded system, for example, mips or arm,
# directly build on arm/mips, for example, pi or cubie,
# export srs-librtmp
# others is invalid.
if [[ $OS_IS_UBUNTU = NO && $OS_IS_CENTOS = NO && $OS_IS_OSX = NO && $SRS_EXPORT_LIBRTMP_PROJECT = NO ]]; then
if [[ $SRS_PI = NO && $SRS_CUBIE = NO && $SRS_CROSS_BUILD = NO ]]; then
echo "what a fuck, os not supported."
echo "Your OS `uname -s` is not supported."
exit 1
fi
fi
#####################################################################################
# st-1.9
# state-threads
#####################################################################################
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
# check the cross build flag file, if flag changed, need to rebuild the st.
_ST_MAKE=linux-debug && _ST_EXTRA_CFLAGS="-DMD_HAVE_EPOLL"
_ST_MAKE=linux-debug && _ST_EXTRA_CFLAGS="-DMD_HAVE_EPOLL" && _ST_LD=${SRS_TOOL_LD} && _ST_OBJ="LINUX_*"
if [[ $SRS_VALGRIND == YES ]]; then
_ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS -DMD_VALGRIND"
fi
# for osx, use darwin for st, donot use epoll.
if [ $OS_IS_OSX = YES ]; then
_ST_MAKE=darwin-debug && _ST_EXTRA_CFLAGS="-DMD_HAVE_KQUEUE"
if [[ $SRS_OSX == YES ]]; then
_ST_MAKE=darwin-debug && _ST_EXTRA_CFLAGS="-DMD_HAVE_KQUEUE" && _ST_LD=${SRS_TOOL_CC} && _ST_OBJ="DARWIN_*"
fi
# memory leak for linux-optimized
# @see: https://github.com/ossrs/srs/issues/197
if [ $SRS_CROSS_BUILD = YES ]; then
# ok, arm specified, if the flag filed does not exists, need to rebuild.
if [[ -f ${SRS_OBJS}/_flag.st.cross.build.tmp && -f ${SRS_OBJS}/st/libst.a ]]; then
echo "st-1.9t for arm is ok.";
else
# TODO: FIXME: patch the bug.
# patch st for arm, @see: https://github.com/ossrs/srs/wiki/v1_CN_SrsLinuxArm#st-arm-bug-fix
echo "build st-1.9t for arm";
(
rm -rf ${SRS_OBJS}/st-1.9 && cd ${SRS_OBJS} &&
unzip -q ../3rdparty/st-1.9.zip && cd st-1.9 && chmod +w * &&
patch -p0 < ../../3rdparty/patches/1.st.arm.patch &&
patch -p0 < ../../3rdparty/patches/3.st.osx.kqueue.patch &&
patch -p0 < ../../3rdparty/patches/4.st.disable.examples.patch &&
patch -p0 < ../../3rdparty/patches/6.st.osx10.14.build.patch &&
make ${_ST_MAKE} CC=${SrsArmCC} AR=${SrsArmAR} LD=${SrsArmLD} RANDLIB=${SrsArmRANDLIB} EXTRA_CFLAGS="${_ST_EXTRA_CFLAGS}" &&
cd .. && rm -rf st && ln -sf st-1.9/obj st &&
cd .. && touch ${SRS_OBJS}/_flag.st.cross.build.tmp
)
fi
# Always alloc on heap, @see https://github.com/ossrs/srs/issues/509#issuecomment-719931676
_ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS -DMALLOC_STACK"
# Pass the global extra flags.
if [[ $SRS_EXTRA_FLAGS != '' ]]; then
_ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS $SRS_EXTRA_FLAGS"
fi
# Patched ST from https://github.com/ossrs/state-threads/tree/srs
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/st/libst.a ]]; then
echo "The state-threads is ok.";
else
if [[ ! -f ${SRS_OBJS}/_flag.st.cross.build.tmp && -f ${SRS_OBJS}/st/libst.a ]]; then
echo "st-1.9t is ok.";
else
# patch st for arm, @see: https://github.com/ossrs/srs/wiki/v1_CN_SrsLinuxArm#st-arm-bug-fix
echo "build st-1.9t";
(
rm -rf ${SRS_OBJS}/st-1.9 && cd ${SRS_OBJS} &&
unzip -q ../3rdparty/st-1.9.zip && cd st-1.9 && chmod +w * &&
patch -p0 < ../../3rdparty/patches/1.st.arm.patch &&
patch -p0 < ../../3rdparty/patches/3.st.osx.kqueue.patch &&
patch -p0 < ../../3rdparty/patches/4.st.disable.examples.patch &&
patch -p0 < ../../3rdparty/patches/6.st.osx10.14.build.patch &&
make ${_ST_MAKE} EXTRA_CFLAGS="${_ST_EXTRA_CFLAGS}" &&
cd .. && rm -rf st && ln -sf st-1.9/obj st &&
cd .. && rm -f ${SRS_OBJS}/_flag.st.cross.build.tmp
)
fi
echo "Building state-threads.";
(
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/st-srs && mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/st-srs &&
# Create a hidden directory .src
cd ${SRS_OBJS}/${SRS_PLATFORM}/st-srs && ln -sf ../../../3rdparty/st-srs .src &&
# Link source files under .src
for file in `(cd .src && find . -maxdepth 1 -type f ! -name '*.o' ! -name '*.d')`; do
ln -sf .src/$file $file;
done &&
# Link source files under .src/xxx, the first child dir.
for dir in `(cd .src && find . -maxdepth 1 -type d|grep '\./'|grep -v Linux|grep -v Darwin)`; do
mkdir -p $dir &&
for file in `(cd .src/$dir && find . -maxdepth 1 -type f ! -name '*.o' ! -name '*.d')`; do
ln -sf ../.src/$dir/$file $dir/$file;
done;
done &&
# Build source code.
make ${_ST_MAKE} EXTRA_CFLAGS="${_ST_EXTRA_CFLAGS}" \
CC=${SRS_TOOL_CC} AR=${SRS_TOOL_AR} LD=${_ST_LD} RANDLIB=${SRS_TOOL_RANDLIB} &&
cd .. && rm -f st && ln -sf st-srs/${_ST_OBJ} st
)
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "build st-1.9 failed, ret=$ret"; exit $ret; fi
if [ ! -f ${SRS_OBJS}/st/libst.a ]; then echo "build st-1.9 static lib failed."; exit -1; fi
fi
#####################################################################################
# http-parser-2.1
#####################################################################################
# check the cross build flag file, if flag changed, need to rebuild the st.
if [ $SRS_HTTP_CORE = YES ]; then
# ok, arm specified, if the flag filed does not exists, need to rebuild.
if [ $SRS_CROSS_BUILD = YES ]; then
if [[ -f ${SRS_OBJS}/_flag.st.hp.tmp && -f ${SRS_OBJS}/hp/http_parser.h && -f ${SRS_OBJS}/hp/libhttp_parser.a ]]; then
echo "http-parser-2.1 for arm is ok.";
else
echo "build http-parser-2.1 for arm";
(
rm -rf ${SRS_OBJS}/http-parser-2.1 && cd ${SRS_OBJS} && unzip -q ../3rdparty/http-parser-2.1.zip &&
cd http-parser-2.1 &&
patch -p0 < ../../3rdparty/patches/2.http.parser.patch &&
make CC=${SrsArmCC} AR=${SrsArmAR} package &&
cd .. && rm -rf hp && ln -sf http-parser-2.1 hp &&
cd .. && touch ${SRS_OBJS}/_flag.st.hp.tmp
)
fi
else
# cross build not specified, if exists flag, need to rebuild for no-arm platform.
if [[ ! -f ${SRS_OBJS}/_flag.st.hp.tmp && -f ${SRS_OBJS}/hp/http_parser.h && -f ${SRS_OBJS}/hp/libhttp_parser.a ]]; then
echo "http-parser-2.1 is ok.";
else
echo "build http-parser-2.1";
(
rm -rf ${SRS_OBJS}/http-parser-2.1 && cd ${SRS_OBJS} && unzip -q ../3rdparty/http-parser-2.1.zip &&
cd http-parser-2.1 &&
patch -p0 < ../../3rdparty/patches/2.http.parser.patch &&
# Patch build error for https://github.com/ossrs/srs/pull/1312#issuecomment-480243404
patch -p0 < ../../3rdparty/patches/7.http.parser.patch &&
make package &&
cd .. && rm -rf hp && ln -sf http-parser-2.1 hp &&
cd .. && rm -f ${SRS_OBJS}/_flag.st.hp.tmp
)
fi
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "build http-parser-2.1 failed, ret=$ret"; exit $ret; fi
if [[ ! -f ${SRS_OBJS}/hp/http_parser.h ]]; then echo "build http-parser-2.1 failed"; exit -1; fi
if [[ ! -f ${SRS_OBJS}/hp/libhttp_parser.a ]]; then echo "build http-parser-2.1 failed"; exit -1; fi
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build state-threads failed, ret=$ret"; exit $ret; fi
# Always update the links.
(cd ${SRS_OBJS} && rm -rf st && ln -sf ${SRS_PLATFORM}/st-srs/${_ST_OBJ} st)
if [ ! -f ${SRS_OBJS}/st/libst.a ]; then echo "Build state-threads static lib failed."; exit -1; fi
fi
#####################################################################################
@ -512,30 +370,6 @@ END
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
mkdir -p ${SRS_OBJS}/nginx
fi
# make nginx
__SRS_BUILD_NGINX=NO; if [ $SRS_CROSS_BUILD = NO ]; then if [ $SRS_NGINX = YES ]; then __SRS_BUILD_NGINX=YES; fi fi
if [ $__SRS_BUILD_NGINX = YES ]; then
if [[ -f ${SRS_OBJS}/nginx/sbin/nginx ]]; then
echo "nginx-1.5.7 is ok.";
else
echo "build nginx-1.5.7";
(
rm -rf ${SRS_OBJS}/nginx-1.5.7 && cd ${SRS_OBJS} &&
unzip -q ../3rdparty/nginx-1.5.7.zip && cd nginx-1.5.7 &&
./configure --prefix=`pwd`/_release && make ${SRS_JOBS} && make install &&
cd .. && rm -rf nginx && ln -sf nginx-1.5.7/_release nginx
)
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "build nginx-1.5.7 failed, ret=$ret"; exit $ret; fi
if [ ! -f ${SRS_OBJS}/nginx/sbin/nginx ]; then echo "build nginx-1.5.7 failed."; exit -1; fi
# use current user to config nginx,
# srs will write ts/m3u8 file use current user,
# nginx default use nobody, so cannot read the ts/m3u8 created by srs.
cp ${SRS_OBJS}/nginx/conf/nginx.conf ${SRS_OBJS}/nginx/conf/nginx.conf.bk
$SED "s/^.user nobody;/user `whoami`;/g" ${SRS_OBJS}/nginx/conf/nginx.conf
fi
# the demo dir.
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
@ -554,39 +388,43 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
# copy players to nginx html dir.
rm -rf ${SRS_OBJS}/nginx/html/players &&
ln -sf `pwd`/research/players ${SRS_OBJS}/nginx/html/players &&
rm -f ${SRS_OBJS}/nginx/crossdomain.xml &&
ln -sf `pwd`/research/players/crossdomain.xml ${SRS_OBJS}/nginx/html/crossdomain.xml
ln -sf `pwd`/research/players ${SRS_OBJS}/nginx/html/players
# For srs-console.
rm -rf ${SRS_OBJS}/nginx/html/console &&
ln -sf `pwd`/research/console ${SRS_OBJS}/nginx/html/console
# for favicon.ico
rm -rf ${SRS_OBJS}/nginx/html/favicon.ico &&
ln -sf `pwd`/research/api-server/static-dir/favicon.ico ${SRS_OBJS}/nginx/html/favicon.ico
# For home page index.html
rm -rf ${SRS_OBJS}/nginx/html/index.html &&
ln -sf `pwd`/research/api-server/static-dir/index.html ${SRS_OBJS}/nginx/html/index.html
# nginx.html to detect whether nginx is alive
echo "nginx is ok" > ${SRS_OBJS}/nginx/html/nginx.html
echo "Nginx is ok." > ${SRS_OBJS}/nginx/html/nginx.html
fi
#####################################################################################
# cherrypy for http hooks callback, CherryPy-3.2.4
#####################################################################################
if [ $SRS_HTTP_CALLBACK = YES ]; then
if [[ -f ${SRS_OBJS}/CherryPy-3.2.4/setup.py ]]; then
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/CherryPy-3.2.4/setup.py ]]; then
echo "CherryPy-3.2.4 is ok.";
else
echo "install CherryPy-3.2.4";
echo "Installing CherryPy-3.2.4";
(
rm -rf ${SRS_OBJS}/CherryPy-3.2.4 && cd ${SRS_OBJS} &&
unzip -q ../3rdparty/CherryPy-3.2.4.zip && cd CherryPy-3.2.4 &&
rm -rf ${SRS_OBJS}/CherryPy-3.2.4 && cd ${SRS_OBJS}/${SRS_PLATFORM} &&
unzip -q ../../3rdparty/CherryPy-3.2.4.zip && cd CherryPy-3.2.4 &&
python setup.py install --user
)
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "build CherryPy-3.2.4 failed, ret=$ret"; exit $ret; fi
if [ ! -f ${SRS_OBJS}/CherryPy-3.2.4/setup.py ]; then echo "build CherryPy-3.2.4 failed."; exit -1; fi
fi
if [ ! -f ${SRS_OBJS}/${SRS_PLATFORM}/CherryPy-3.2.4/setup.py ]; then echo "build CherryPy-3.2.4 failed."; exit -1; fi
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
echo "link players to cherrypy static-dir"
echo "Link players to cherrypy static-dir"
rm -rf research/api-server/static-dir/players &&
ln -sf `pwd`/research/players research/api-server/static-dir/players &&
rm -f research/api-server/static-dir/crossdomain.xml &&
@ -597,108 +435,82 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
rm -rf research/api-server/static-dir/forward &&
mkdir -p `pwd`/${SRS_OBJS}/nginx/html/forward &&
ln -sf `pwd`/${SRS_OBJS}/nginx/html/forward research/api-server/static-dir/forward
ret=$?; if [[ $ret -ne 0 ]]; then echo "[warn] link players to cherrypy static-dir failed"; fi
ret=$?; if [[ $ret -ne 0 ]]; then echo "Warning: Ignore error to link players to cherrypy static-dir."; fi
fi
#####################################################################################
# generate demo index.html
# openssl, for rtmp complex handshake and HLS encryption.
#####################################################################################
# if nginx enalbed, generate nginx index file.
if [ $__SRS_BUILD_NGINX = YES ]; then
rm -f ${SRS_OBJS}/nginx/html/index.html &&
ln -sf `pwd`/research/players/nginx_index.html ${SRS_OBJS}/nginx/html/index.html
if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL == YES ]]; then
echo "Warning: Use system libssl, without compiling openssl."
fi
# if http-server enalbed, use srs embeded http-server
if [ $SRS_HTTP_SERVER = YES ]; then
rm -f ${SRS_OBJS}/nginx/html/index.html &&
ln -sf `pwd`/research/players/srs-http-server_index.html ${SRS_OBJS}/nginx/html/index.html
fi
# if api-server enabled, generate for api server.
if [ $SRS_HTTP_CALLBACK = YES ]; then
rm -f ${SRS_OBJS}/nginx/html/index.html &&
ln -sf `pwd`/research/players/api-server_index.html ${SRS_OBJS}/nginx/html/index.html
fi
#####################################################################################
# openssl, for rtmp complex handshake
#####################################################################################
# extra configure options
CONFIGURE_TOOL="./config"
if [ $SRS_CROSS_BUILD = YES ]; then
CONFIGURE_TOOL="./Configure linux-armv4"
fi
if [ $SRS_OSX = YES ]; then
CONFIGURE_TOOL="./Configure darwin64-`uname -m`-cc"
fi
OPENSSL_HOTFIX="-DOPENSSL_NO_HEARTBEATS"
# @see http://www.openssl.org/news/secadv/20140407.txt
# Affected users should upgrade to OpenSSL 1.0.1g. Users unable to immediately
# Affected users should upgrade to OpenSSL 1.1.0e. Users unable to immediately
# upgrade can alternatively recompile OpenSSL with -DOPENSSL_NO_HEARTBEATS.
if [ $SRS_SSL = YES ]; then
if [ $SRS_USE_SYS_SSL = YES ]; then
echo "warning: donot compile ssl, use system ssl"
else
# check the cross build flag file, if flag changed, need to rebuild the st.
if [ $SRS_CROSS_BUILD = YES ]; then
# ok, arm specified, if the flag filed does not exists, need to rebuild.
if [[ -f ${SRS_OBJS}/_flag.ssl.cross.build.tmp && -f ${SRS_OBJS}/openssl/lib/libssl.a ]]; then
echo "openssl-1.0.1f for arm is ok.";
else
echo "build openssl-1.0.1f for arm";
(
rm -rf ${SRS_OBJS}/openssl-1.0.1f && cd ${SRS_OBJS} &&
unzip -q ../3rdparty/openssl-1.0.1f.zip && cd openssl-1.0.1f &&
$CONFIGURE_TOOL --prefix=`pwd`/_release -no-shared no-asm $OPENSSL_HOTFIX &&
make CC=${SrsArmCC} GCC=${SrsArmGCC} AR="${SrsArmAR} r" \
LD=${SrsArmLD} LINK=${SrsArmGCC} RANDLIB=${SrsArmRANDLIB} &&
make install_sw &&
cd .. && rm -rf openssl && ln -sf openssl-1.0.1f/_release openssl &&
cd .. && touch ${SRS_OBJS}/_flag.ssl.cross.build.tmp
)
fi
else
# cross build not specified, if exists flag, need to rebuild for no-arm platform.
if [[ ! -f ${SRS_OBJS}/_flag.ssl.cross.build.tmp && -f ${SRS_OBJS}/openssl/lib/libssl.a ]]; then
echo "openssl-1.0.1f is ok.";
else
echo "build openssl-1.0.1f";
(
rm -rf ${SRS_OBJS}/openssl-1.0.1f && cd ${SRS_OBJS} &&
unzip -q ../3rdparty/openssl-1.0.1f.zip && cd openssl-1.0.1f &&
$CONFIGURE_TOOL --prefix=`pwd`/_release -no-shared $OPENSSL_HOTFIX &&
make && make install_sw &&
cd .. && rm -rf openssl && ln -sf openssl-1.0.1f/_release openssl &&
cd .. && rm -f ${SRS_OBJS}/_flag.ssl.cross.build.tmp
)
fi
if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL != YES ]]; then
OPENSSL_OPTIONS="-no-shared -no-threads -no-asm -DOPENSSL_NO_HEARTBEATS"
OPENSSL_CONFIG="./config"
# https://stackoverflow.com/questions/15539062/cross-compiling-of-openssl-for-linux-arm-v5te-linux-gnueabi-toolchain
if [[ $SRS_CROSS_BUILD == YES ]]; then
OPENSSL_CONFIG="./Configure linux-armv4"
elif [[ ! -f ${SRS_OBJS}/${SRS_PLATFORM}/openssl/lib/libssl.a ]]; then
# Try to use exists libraries.
if [[ -f /usr/local/ssl/lib/libssl.a ]]; then
(mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/openssl/lib && cd ${SRS_OBJS}/${SRS_PLATFORM}/openssl/lib &&
ln -sf /usr/local/ssl/lib/libssl.a && ln -sf /usr/local/ssl/lib/libcrypto.a &&
mkdir -p /usr/local/ssl/lib/pkgconfig && ln -sf /usr/local/ssl/lib/pkgconfig)
(mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/openssl/include && cd ${SRS_OBJS}/${SRS_PLATFORM}/openssl/include &&
ln -sf /usr/local/ssl/include/openssl)
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "build openssl-1.0.1f failed, ret=$ret"; exit $ret; fi
if [ ! -f ${SRS_OBJS}/openssl/lib/libssl.a ]; then echo "build openssl-1.0.1f failed."; exit -1; fi
fi
# Which lib we use.
OPENSSL_LIB="openssl-1.1.0e/_release"
if [[ ! -f ${SRS_OBJS}/${SRS_PLATFORM}/${OPENSSL_LIB}/lib/libssl.a ]]; then
OPENSSL_LIB="openssl"
fi
# cross build not specified, if exists flag, need to rebuild for no-arm platform.
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/openssl/lib/libssl.a ]]; then
echo "Openssl-1.1.0e is ok.";
else
echo "Building openssl-1.1.0e.";
(
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/openssl-1.1.0e && cd ${SRS_OBJS}/${SRS_PLATFORM} &&
unzip -q ../../3rdparty/openssl-1.1.0e.zip && cd openssl-1.1.0e &&
${OPENSSL_CONFIG} --prefix=`pwd`/_release $OPENSSL_OPTIONS &&
make CC=${SRS_TOOL_CC} AR="${SRS_TOOL_AR} -rs" LD=${SRS_TOOL_LD} RANDLIB=${SRS_TOOL_RANDLIB} && make install_sw &&
cd .. && rm -rf openssl && ln -sf openssl-1.1.0e/_release openssl
)
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build openssl-1.1.0e failed, ret=$ret"; exit $ret; fi
# Always update the links.
(cd ${SRS_OBJS} && rm -rf openssl && ln -sf ${SRS_PLATFORM}/${OPENSSL_LIB} openssl)
if [ ! -f ${SRS_OBJS}/openssl/lib/libssl.a ]; then echo "Build openssl-1.1.0e failed."; exit -1; fi
fi
#####################################################################################
# live transcoding, ffmpeg-4.1, x264-core157, lame-3.99.5, libaacplus-2.0.2.
#####################################################################################
# Always link the ffmpeg tools if exists.
if [[ -f /usr/local/bin/ffmpeg && ! -f ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg ]]; then
mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg/bin &&
ln -sf /usr/local/bin/ffmpeg ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg/bin/ffmpeg &&
(cd ${SRS_OBJS} && rm -rf ffmpeg && ln -sf ${SRS_PLATFORM}/ffmpeg)
fi
if [ $SRS_FFMPEG_TOOL = YES ]; then
if [[ -f /usr/local/bin/ffmpeg && ! -f ${SRS_OBJS}/ffmpeg/bin/ffmpeg ]]; then
mkdir -p ${SRS_OBJS}/ffmpeg/bin && ln -sf /usr/local/bin/ffmpeg ${SRS_OBJS}/ffmpeg/bin/ffmpeg
fi
if [[ -f ${SRS_OBJS}/ffmpeg/bin/ffmpeg ]]; then
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg/bin/ffmpeg ]]; then
echo "ffmpeg-4.1 is ok.";
else
echo "build ffmpeg-4.1";
(
cd ${SRS_OBJS} && pwd_dir=`pwd` &&
rm -rf ffmepg.src && mkdir -p ffmpeg.src && cd ffmpeg.src &&
rm -f build_ffmpeg.sh && ln -sf ../../auto/build_ffmpeg.sh && . build_ffmpeg.sh &&
cd ${pwd_dir} && rm -rf ffmpeg && ln -sf ffmpeg.src/_release ffmpeg
)
echo -e "${RED}Error: No FFmpeg found at /usr/local/bin/ffmpeg${BLACK}"
echo -e "${RED} Please copy it from srs-docker${BLACK}"
echo -e "${RED} or download from http://ffmpeg.org/download.html${BLACK}"
echo -e "${RED} or disable it by --without-ffmpeg${BLACK}"
exit -1;
fi
# Always update the links.
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg ]]; then
(cd ${SRS_OBJS} && rm -rf ffmpeg && ln -sf ${SRS_PLATFORM}/ffmpeg)
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "build ffmpeg-4.1 failed, ret=$ret"; exit $ret; fi
if [ ! -f ${SRS_OBJS}/ffmpeg/bin/ffmpeg ]; then echo "build ffmpeg-4.1 failed."; exit -1; fi
fi
#####################################################################################
@ -709,63 +521,63 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
mkdir -p ${SRS_OBJS}/research
(cd ${SRS_WORKDIR}/research/hls && make ${SRS_JOBS} && mv ts_info ../../${SRS_OBJS_DIR}/research)
ret=$?; if [[ $ret -ne 0 ]]; then echo "build research/hls failed, ret=$ret"; exit $ret; fi
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build research/hls failed, ret=$ret"; exit $ret; fi
(cd research/ffempty && make ${SRS_JOBS} && mv ffempty ../../${SRS_OBJS_DIR}/research)
ret=$?; if [[ $ret -ne 0 ]]; then echo "build research/ffempty failed, ret=$ret"; exit $ret; fi
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build research/ffempty failed, ret=$ret"; exit $ret; fi
fi
fi
if [ $SRS_LIBRTMP = YES ]; then
if [[ $SRS_LIBRTMP == YES ]]; then
mkdir -p ${SRS_OBJS}/research
# librtmp
(cd ${SRS_WORKDIR}/research/librtmp && mkdir -p objs && ln -sf `pwd`/objs ../../${SRS_OBJS_DIR}/research/librtmp)
ret=$?; if [[ $ret -ne 0 ]]; then echo "link research/librtmp failed, ret=$ret"; exit $ret; fi
(cd ${SRS_WORKDIR}/research/librtmp && mkdir -p objs &&
rm -rf ../../${SRS_OBJS_DIR}/research/librtmp &&
ln -sf `pwd`/objs ../../${SRS_OBJS_DIR}/research/librtmp)
ret=$?; if [[ $ret -ne 0 ]]; then echo "Link research/librtmp failed, ret=$ret"; exit $ret; fi
fi
#####################################################################################
# build utest code
#####################################################################################
if [ $SRS_UTEST = YES ]; then
if [[ -f ${SRS_OBJS}/gtest/include/gtest/gtest.h ]]; then
echo "gtest-1.6.0 is ok.";
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/gtest/include/gtest/gtest.h ]]; then
echo "The gtest-1.6.0 is ok.";
else
echo "build gtest-1.6.0";
echo "Build gtest-1.6.0";
(
rm -rf ${SRS_OBJS}/gtest-1.6.0 && cd ${SRS_OBJS} &&
unzip -q ../3rdparty/gtest-1.6.0.zip &&
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/gtest-1.6.0 && cd ${SRS_OBJS}/${SRS_PLATFORM} &&
unzip -q ../../3rdparty/gtest-1.6.0.zip &&
rm -rf gtest && ln -sf gtest-1.6.0 gtest
)
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "build gtest-1.6.0 failed, ret=$ret"; exit $ret; fi
if [ ! -f ${SRS_OBJS}/gtest/include/gtest/gtest.h ]; then echo "build gtest-1.6.0 failed."; exit -1; fi
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build gtest-1.6.0 failed, ret=$ret"; exit $ret; fi
# Always update the links.
(cd ${SRS_OBJS} && rm -rf gtest && ln -sf ${SRS_PLATFORM}/gtest-1.6.0 gtest)
if [ ! -f ${SRS_OBJS}/gtest/include/gtest/gtest.h ]; then echo "Build gtest-1.6.0 failed."; exit -1; fi
fi
#####################################################################################
# build gperf code
#####################################################################################
if [ $SRS_GPERF = YES ]; then
if [[ -f ${SRS_OBJS}/gperf/bin/pprof ]]; then
echo "gperftools-2.1 is ok.";
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/gperf/bin/pprof ]]; then
echo "The gperftools-2.1 is ok.";
else
echo "build gperftools-2.1";
echo "Build gperftools-2.1";
(
rm -rf ${SRS_OBJS}/gperftools-2.1 && cd ${SRS_OBJS} &&
unzip -q ../3rdparty/gperftools-2.1.zip && cd gperftools-2.1 &&
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/gperftools-2.1 && cd ${SRS_OBJS}/${SRS_PLATFORM} &&
unzip -q ../../3rdparty/gperftools-2.1.zip && cd gperftools-2.1 &&
./configure --prefix=`pwd`/_release --enable-frame-pointers && make ${SRS_JOBS} && make install &&
cd .. && rm -rf gperf && ln -sf gperftools-2.1/_release gperf &&
rm -rf pprof && ln -sf gperf/bin/pprof pprof
)
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "build gperftools-2.1 failed, ret=$ret"; exit $ret; fi
if [ ! -f ${SRS_OBJS}/gperf/bin/pprof ]; then echo "build gperftools-2.1 failed."; exit -1; fi
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build gperftools-2.1 failed, ret=$ret"; exit $ret; fi
# Always update the links.
(cd ${SRS_OBJS} && rm -rf pprof && ln -sf ${SRS_PLATFORM}/gperf/bin/pprof pprof)
if [ ! -f ${SRS_OBJS}/gperf/bin/pprof ]; then echo "Build gperftools-2.1 failed."; exit -1; fi
fi
#####################################################################################
# generated the test script
#####################################################################################
rm -rf ${SRS_OBJS}/srs.test && ln -sf `pwd`/scripts/srs.test objs/srs.test

View file

@ -1,12 +1,5 @@
#!/bin/bash
OS_IS_OSX=NO
uname -s|grep Darwin >/dev/null 2>&1
ret=$?; if [[ 0 -eq $ret ]]; then
OS_IS_OSX=YES
fi
echo "Is OSX: ${OS_IS_OSX}"
# when export srs-librtmp single files
# package the whole project to srs_librtmp.h and srs_librtmp.cpp
#
@ -27,28 +20,28 @@ cp $SRS_EXPORT_LIBRTMP_SINGLE/src/libs/srs_librtmp.hpp $SRS_EXPORT_LIBRTMP_SINGL
# create srs_librtmp.cpp
FILE=$SRS_EXPORT_LIBRTMP_SINGLE/srs_librtmp.cpp
cat << END >$FILE
/*
The MIT License (MIT)
Copyright (c) 2013-2015 SRS(ossrs)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* The MIT License (MIT)
*
* Copyright (c) 2013-2017 OSSRS(winlin)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "srs_librtmp.h"
@ -59,7 +52,7 @@ ret=$?; if [[ $ret -ne 0 ]]; then
echo -e "${RED}failed to generate the srs_librtmp.cpp${BLACK}"
exit $ret
fi
# module to cpp files.
# module to hpp files.
function build_module_hpp()
{
echo "build files ${SRS_LIBRTMP_OBJS} to $FILE"
@ -127,14 +120,14 @@ int main(int argc, char** argv)
END
# compile the example
(cd $SRS_EXPORT_LIBRTMP_SINGLE && echo "${SRS_SINGLE_LIBRTMP_COMPILE}" &&
`${SRS_SINGLE_LIBRTMP_COMPILE}` && ./example && rm -f example)
ret=$?; if [[ $ret -ne 0 ]]; then
echo "(cd $SRS_EXPORT_LIBRTMP_SINGLE && ${SRS_SINGLE_LIBRTMP_COMPILE} && ./example && rm -f example)"
echo -e "${RED}failed to compile example.${BLACK}"
exit $ret
fi
## compile the example
#(cd $SRS_EXPORT_LIBRTMP_SINGLE && echo "${SRS_SINGLE_LIBRTMP_COMPILE}" &&
#`${SRS_SINGLE_LIBRTMP_COMPILE}` && ./example && rm -f example)
#ret=$?; if [[ $ret -ne 0 ]]; then
# echo "(cd $SRS_EXPORT_LIBRTMP_SINGLE && ${SRS_SINGLE_LIBRTMP_COMPILE} && ./example && rm -f example)"
# echo -e "${RED}failed to compile example.${BLACK}"
# exit $ret
#fi
# clear the files for srs-librtmp project, generated by generate-srs-librtmp-project.sh
(cd $SRS_EXPORT_LIBRTMP_SINGLE && rm -rf auto $SRS_OBJS_DIR research src Makefile)

View file

@ -14,11 +14,12 @@ FILE=${SRS_OBJS}/${SRS_MAKEFILE}
LIB_TARGET="${SRS_OBJS_DIR}/${LIB_NAME}"
LIB_TAGET_STATIC="${LIB_TARGET}.a"
echo "generate lib ${LIB_NAME} depends..."
echo "Generating lib ${LIB_NAME} depends."
echo "" >> ${FILE}
echo "# archive library ${LIB_TAGET_STATIC}" >> ${FILE}
echo "${BUILD_KEY}: ${LIB_TAGET_STATIC}" >> ${FILE}
echo "" >> ${FILE}
# build depends
echo -n "${LIB_TAGET_STATIC}: " >> ${FILE}
@ -41,7 +42,7 @@ echo -n " @bash auto/generate_header.sh ${SRS_OBJS_DIR}" >> ${FILE}
echo "" >> ${FILE}
# archive librtmp.a
echo -n " \$(AR) -rs ${LIB_TAGET_STATIC} " >> ${FILE}
echo -n " \$(AR) \$(ARFLAGS) ${LIB_TAGET_STATIC} " >> ${FILE}
for item in ${MODULE_OBJS[*]}; do
FILE_NAME=`basename $item`
FILE_NAME=${FILE_NAME%.*}
@ -60,4 +61,4 @@ echo "" >> ${FILE}
echo " @mkdir -p ${SRS_OBJS_DIR}/include" >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
echo " @mkdir -p ${SRS_OBJS_DIR}/lib" >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
echo -n "generate lib ${LIB_NAME} ok"; echo '!';
echo -n "Generate lib ${LIB_NAME} ok"; echo '!';

View file

@ -17,7 +17,7 @@
FILE=${SRS_OBJS}/${SRS_MAKEFILE}
echo "#####################################################################################" >> ${FILE}
echo "# the ${MODULE_ID} module." >> ${FILE}
echo "# The module ${MODULE_ID}." >> ${FILE}
echo "#####################################################################################" >> ${FILE}
echo >> ${FILE}
@ -41,7 +41,7 @@ echo -n "${INCS_NAME} = -I${MODULE_DIR} " >> ${FILE}
for item in ${MODULE_DEPENDS[*]}; do
DEP_INCS_NAME="${item}_INCS"do
DEP_INCS_NAME="${item}_MODULE_INCS"
echo -n "\$(${DEP_INCS_NAME}) " >> ${FILE}
echo -n "\$(${DEP_INCS_NAME})" >> ${FILE}
done
#
# depends library header files
@ -79,7 +79,8 @@ for item in ${MODULE_FILES[*]}; do
MODULE_OBJS="${MODULE_OBJS[@]} ${CPP_FILE}"
if [ -f ${CPP_FILE} ]; then
echo "${OBJ_FILE}: \$(${DEPS_NAME}) ${CPP_FILE} " >> ${FILE}
echo " \$(CXX) -c \$(CXXFLAGS) ${DEFINES} \$(${INCS_NAME})\\" >> ${FILE}
echo " \$(CXX) -c \$(CXXFLAGS) ${DEFINES}\\" >> ${FILE}
echo " \$(${INCS_NAME})\\" >> ${FILE}
echo " -o ${OBJ_FILE} ${CPP_FILE}" >> ${FILE}
fi
done
@ -88,4 +89,4 @@ echo "" >> ${FILE}
# parent Makefile, to create module output dir before compile it.
echo " @mkdir -p ${SRS_OBJS_DIR}/${MODULE_DIR}" >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
echo -n "generate module ${MODULE_ID} ok"; echo '!';
echo -n "Generate modules ${MODULE_ID} ok"; echo '!';

File diff suppressed because it is too large Load diff

45
trunk/auto/setup_variables.sh Normal file → Executable file
View file

@ -1,30 +1,29 @@
#!/bin/bash
# when options parsed, setup some variables, then build the depends.
OS_KERNEL_NAME=$(uname -s)
OS_KERNRL_RELEASE=$(uname -r|awk -F '-' '{print $1}')
OS_PREFIX="Platform"
# when arm specified, setup the cross build variables.
if [ $SRS_ARM_UBUNTU12 = YES ]; then
__SrsArmCC="arm-linux-gnueabi-gcc";
__SrsArmGCC="arm-linux-gnueabi-gcc";
__SrsArmCXX="arm-linux-gnueabi-g++";
__SrsArmAR="arm-linux-gnueabi-ar";
__SrsArmLD="arm-linux-gnueabi-ld";
__SrsArmRANDLIB="arm-linux-gnueabi-ranlib";
# Build platform cache.
SRS_PLATFORM="${OS_PREFIX}-${OS_KERNEL_NAME}-${OS_KERNRL_RELEASE}"
if [[ ${SRS_BUILD_TAG} != "" ]]; then
SRS_PLATFORM="${SRS_PLATFORM}-${SRS_BUILD_TAG}"
fi
# Use isolate cache for different SRS version.
SRS_PLATFORM="${SRS_PLATFORM}-SRS3"
if [ $SRS_MIPS_UBUNTU12 = YES ]; then
__SrsArmCC="mipsel-openwrt-linux-gcc";
__SrsArmGCC="mipsel-openwrt-linux-gcc";
__SrsArmCXX="mipsel-openwrt-linux-g++";
__SrsArmAR="mipsel-openwrt-linux-ar";
__SrsArmLD="mipsel-openwrt-linux-ld";
__SrsArmRANDLIB="mipsel-openwrt-linux-ranlib";
fi
echo "SRS_WORKDIR: ${SRS_WORKDIR}, SRS_OBJS_DIR: ${SRS_OBJS_DIR}, SRS_OBJS: ${SRS_OBJS}, SRS_PLATFORM: ${SRS_PLATFORM}"
# For src object files on each platform.
(
mkdir -p ${SRS_OBJS_DIR} && cd ${SRS_OBJS_DIR} &&
rm -rf src utest srs srs_utest research include lib srs_hls_ingester srs_mp4_parser &&
mkdir -p ${SRS_PLATFORM}/src && ln -sf ${SRS_PLATFORM}/src &&
mkdir -p ${SRS_PLATFORM}/utest && ln -sf ${SRS_PLATFORM}/utest &&
mkdir -p ${SRS_PLATFORM}/research && ln -sf ${SRS_PLATFORM}/research &&
mkdir -p ${SRS_PLATFORM}/include && ln -sf ${SRS_PLATFORM}/include &&
mkdir -p ${SRS_PLATFORM}/lib && ln -sf ${SRS_PLATFORM}/lib
)
echo "Fast cleanup, if need to do full cleanup, please use: make clean"
# the arm-ubuntu12 options for make for depends
if [[ -z $SrsArmCC ]]; then SrsArmCC=$__SrsArmCC; fi
if [[ -z $SrsArmGCC ]]; then SrsArmGCC=$__SrsArmGCC; fi
if [[ -z $SrsArmCXX ]]; then SrsArmCXX=$__SrsArmCXX; fi
if [[ -z $SrsArmAR ]]; then SrsArmAR=$__SrsArmAR; fi
if [[ -z $SrsArmLD ]]; then SrsArmLD=$__SrsArmLD; fi
if [[ -z $SrsArmRANDLIB ]]; then SrsArmRANDLIB=$__SrsArmRANDLIB; fi

View file

@ -1,26 +1,28 @@
#!/bin/bash
# colorful summary
SrsHlsSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_HLS = YES ]; then SrsHlsSummaryColor="\${GREEN}"; fi
SrsDvrSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_DVR = YES ]; then SrsDvrSummaryColor="\${GREEN}"; fi
SrsNginxSummaryColor="\${GREEN}{disabled} "; if [ $SRS_NGINX = YES ]; then SrsNginxSummaryColor="\${GREEN}"; fi
SrsSslSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_SSL = YES ]; then SrsSslSummaryColor="\${GREEN}"; fi
SrsFfmpegSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_FFMPEG_TOOL = YES ]; then SrsFfmpegSummaryColor="\${GREEN}"; fi
SrsTranscodeSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_TRANSCODE = YES ]; then SrsTranscodeSummaryColor="\${GREEN}"; fi
SrsIngestSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_INGEST = YES ]; then SrsIngestSummaryColor="\${GREEN}"; fi
SrsHttpCallbackSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_HTTP_CALLBACK = YES ]; then SrsHttpCallbackSummaryColor="\${GREEN}"; fi
SrsHttpServerSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_HTTP_SERVER = YES ]; then SrsHttpServerSummaryColor="\${GREEN}"; fi
SrsHttpApiSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_HTTP_API = YES ]; then SrsHttpApiSummaryColor="\${GREEN}"; fi
SrsStreamCasterSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_STREAM_CASTER = YES ]; then SrsStreamCasterSummaryColor="\${GREEN}"; fi
SrsLibrtmpSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_LIBRTMP = YES ]; then SrsLibrtmpSummaryColor="\${GREEN}"; fi
SrsLibrtmpSSLSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_LIBRTMP = YES ]; then if [ $SRS_SSL = YES ]; then SrsLibrtmpSSLSummaryColor="\${GREEN}"; fi fi
SrsResearchSummaryColor="\${GREEN}{disabled} "; if [ $SRS_RESEARCH = YES ]; then SrsResearchSummaryColor="\${GREEN}"; fi
SrsUtestSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_UTEST = YES ]; then SrsUtestSummaryColor="\${GREEN}"; fi
SrsGperfSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF = YES ]; then SrsGperfSummaryColor="\${GREEN}"; fi
SrsGperfMCSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF_MC = YES ]; then SrsGperfMCSummaryColor="\${YELLOW}"; fi
SrsGperfMPSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF_MP = YES ]; then SrsGperfMPSummaryColor="\${YELLOW}"; fi
SrsGperfCPSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF_CP = YES ]; then SrsGperfCPSummaryColor="\${YELLOW}"; fi
SrsGprofSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPROF = YES ]; then SrsGprofSummaryColor="\${YELLOW}"; fi
SrsHlsSummaryColor="\${YELLOW}(Disabled) "; if [ $SRS_HLS = YES ]; then SrsHlsSummaryColor="\${GREEN}"; fi
SrsDvrSummaryColor="\${YELLOW}(Disabled) "; if [ $SRS_DVR = YES ]; then SrsDvrSummaryColor="\${GREEN}"; fi
SrsNginxSummaryColor="\${GREEN}(Disabled) "; if [ $SRS_NGINX = YES ]; then SrsNginxSummaryColor="\${GREEN}"; fi
SrsSslSummaryColor="\${YELLOW}(Disabled) "; if [ $SRS_SSL = YES ]; then SrsSslSummaryColor="\${GREEN}"; fi
SrsFfmpegSummaryColor="\${YELLOW}(Disabled) "; if [ $SRS_FFMPEG_TOOL = YES ]; then SrsFfmpegSummaryColor="\${GREEN}"; fi
SrsTranscodeSummaryColor="\${YELLOW}(Disabled) "; if [ $SRS_TRANSCODE = YES ]; then SrsTranscodeSummaryColor="\${GREEN}"; fi
SrsIngestSummaryColor="\${YELLOW}(Disabled) "; if [ $SRS_INGEST = YES ]; then SrsIngestSummaryColor="\${GREEN}"; fi
SrsHttpCallbackSummaryColor="\${YELLOW}(Disabled) "; if [ $SRS_HTTP_CALLBACK = YES ]; then SrsHttpCallbackSummaryColor="\${GREEN}"; fi
SrsHttpServerSummaryColor="\${YELLOW}(Disabled) "; if [ $SRS_HTTP_SERVER = YES ]; then SrsHttpServerSummaryColor="\${GREEN}"; fi
SrsHttpApiSummaryColor="\${YELLOW}(Disabled) "; if [ $SRS_HTTP_API = YES ]; then SrsHttpApiSummaryColor="\${GREEN}"; fi
SrsStreamCasterSummaryColor="\${YELLOW}(Disabled) "; if [ $SRS_STREAM_CASTER = YES ]; then SrsStreamCasterSummaryColor="\${GREEN}"; fi
SrsLibrtmpSummaryColor="\${YELLOW}(Disabled) "; if [ $SRS_LIBRTMP = YES ]; then SrsLibrtmpSummaryColor="\${GREEN}"; fi
SrsLibrtmpSSLSummaryColor="\${YELLOW}(Disabled) "; if [ $SRS_LIBRTMP = YES ]; then if [ $SRS_SSL = YES ]; then SrsLibrtmpSSLSummaryColor="\${GREEN}"; fi fi
SrsResearchSummaryColor="\${GREEN}(Disabled) "; if [ $SRS_RESEARCH = YES ]; then SrsResearchSummaryColor="\${GREEN}"; fi
SrsUtestSummaryColor="\${YELLOW}(Disabled) "; if [ $SRS_UTEST = YES ]; then SrsUtestSummaryColor="\${GREEN}"; fi
SrsGperfSummaryColor="\${GREEN}(Disabled) "; if [ $SRS_GPERF = YES ]; then SrsGperfSummaryColor="\${GREEN}"; fi
SrsGperfMCSummaryColor="\${GREEN}(Disabled) "; if [ $SRS_GPERF_MC = YES ]; then SrsGperfMCSummaryColor="\${YELLOW}"; fi
SrsGperfMDSummaryColor="\${GREEN}(Disabled) "; if [ $SRS_GPERF_MD = YES ]; then SrsGperfMDSummaryColor="\${YELLOW}"; fi
SrsGperfMPSummaryColor="\${GREEN}(Disabled) "; if [ $SRS_GPERF_MP = YES ]; then SrsGperfMPSummaryColor="\${YELLOW}"; fi
SrsGperfCPSummaryColor="\${GREEN}(Disabled) "; if [ $SRS_GPERF_CP = YES ]; then SrsGperfCPSummaryColor="\${YELLOW}"; fi
SrsGprofSummaryColor="\${GREEN}(Disabled) "; if [ $SRS_GPROF = YES ]; then SrsGprofSummaryColor="\${YELLOW}"; fi
SrsValgrindSummaryColor="\${YELLOW}(Disabled) "; if [ $SRS_VALGRIND = YES ]; then SrsValgrindSummaryColor="\${GREEN}"; fi
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
cat <<END > ${SRS_OBJS}/${SRS_BUILD_SUMMARY}
@ -33,76 +35,24 @@ GREEN="\\${GREEN}"
YELLOW="\\${YELLOW}"
BLACK="\\${BLACK}"
echo -e "\${GREEN}build summary:\${BLACK}"
echo -e "\${GREEN}The build summary:\${BLACK}"
echo -e " \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
echo -e " |${SrsGperfSummaryColor}gperf @see: https://github.com/ossrs/srs/wiki/v1_CN_GPERF\${BLACK}"
echo -e " | ${SrsGperfMCSummaryColor}gmc @see: http://google-perftools.googlecode.com/svn/trunk/doc/heap_checker.html\${BLACK}"
echo -e " | ${SrsGperfMCSummaryColor}gmc: gperf memory check, or memory leak detect\${BLACK}"
echo -e " | ${SrsGperfMCSummaryColor}env PPROF_PATH=./objs/pprof HEAPCHECK=normal ./objs/srs -c conf/console.conf 2>gmc.log # start gmc\${BLACK}"
echo -e " | ${SrsGperfMCSummaryColor}killall -2 srs # or CTRL+C to stop gmc\${BLACK}"
echo -e " | ${SrsGperfMCSummaryColor}cat gmc.log # to analysis memory leak\${BLACK}"
echo -e " | ${SrsGperfMPSummaryColor}gmp @see: http://google-perftools.googlecode.com/svn/trunk/doc/heapprofile.html\${BLACK}"
echo -e " | ${SrsGperfMPSummaryColor}gmp: gperf memory profile, similar to gcp\${BLACK}"
echo -e " | ${SrsGperfMPSummaryColor}rm -f gperf.srs.gmp*; ./objs/srs -c conf/console.conf # start gmp\${BLACK}"
echo -e " | ${SrsGperfMPSummaryColor}killall -2 srs # or CTRL+C to stop gmp\${BLACK}"
echo -e " | ${SrsGperfMPSummaryColor}./objs/pprof --text objs/srs gperf.srs.gmp* # to analysis memory profile\${BLACK}"
echo -e " | ${SrsGperfCPSummaryColor}gcp @see: http://google-perftools.googlecode.com/svn/trunk/doc/cpuprofile.html\${BLACK}"
echo -e " | ${SrsGperfCPSummaryColor}gcp: gperf cpu profile\${BLACK}"
echo -e " | ${SrsGperfCPSummaryColor}rm -f gperf.srs.gcp*; ./objs/srs -c conf/console.conf # start gcp\${BLACK}"
echo -e " | ${SrsGperfCPSummaryColor}killall -2 srs # or CTRL+C to stop gcp\${BLACK}"
echo -e " | ${SrsGperfCPSummaryColor}./objs/pprof --text objs/srs gperf.srs.gcp* # to analysis cpu profile\${BLACK}"
echo -e " \${GREEN}For SRS benchmark, gperf, gprof and valgrind, please read:\${BLACK}"
echo -e " \${GREEN} http://blog.csdn.net/win_lin/article/details/53503869\${BLACK}"
echo -e " \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
echo -e " |${SrsGprofSummaryColor}gprof @see: https://github.com/ossrs/srs/wiki/v1_CN_GPROF\${BLACK}"
echo -e " |${SrsGprofSummaryColor}gprof: GNU profile tool, @see: http://www.cs.utah.edu/dept/old/texinfo/as/gprof.html\${BLACK}"
echo -e " | ${SrsGprofSummaryColor}rm -f gmon.out; ./objs/srs -c conf/console.conf # start gprof\${BLACK}"
echo -e " | ${SrsGprofSummaryColor}killall -2 srs # or CTRL+C to stop gprof\${BLACK}"
echo -e " | ${SrsGprofSummaryColor}gprof -b ./objs/srs gmon.out > gprof.srs.log && rm -f gmon.out # gprof report to gprof.srs.log\${BLACK}"
echo -e " |\${GREEN}The main server usage: ./objs/srs -c conf/srs.conf, start the srs server\${BLACK}"
echo -e " | ${SrsHlsSummaryColor}About HLS, please read https://github.com/ossrs/srs/wiki/v2_CN_DeliveryHLS\${BLACK}"
echo -e " | ${SrsDvrSummaryColor}About DVR, please read https://github.com/ossrs/srs/wiki/v3_CN_DVR\${BLACK}"
echo -e " | ${SrsSslSummaryColor}About SSL, please read https://github.com/ossrs/srs/wiki/v1_CN_RTMPHandshake\${BLACK}"
echo -e " | ${SrsTranscodeSummaryColor}About transcoding, please read https://github.com/ossrs/srs/wiki/v3_CN_FFMPEG\${BLACK}"
echo -e " | ${SrsIngestSummaryColor}About ingester, please read https://github.com/ossrs/srs/wiki/v1_CN_Ingest\${BLACK}"
echo -e " | ${SrsHttpCallbackSummaryColor}About http-callback, please read https://github.com/ossrs/srs/wiki/v3_CN_HTTPCallback\${BLACK}"
echo -e " | ${SrsHttpServerSummaryColor}Aoubt http-server, please read https://github.com/ossrs/srs/wiki/v2_CN_HTTPServer\${BLACK}"
echo -e " | ${SrsHttpApiSummaryColor}About http-api, please read https://github.com/ossrs/srs/wiki/v3_CN_HTTPApi\${BLACK}"
echo -e " | ${SrsStreamCasterSummaryColor}About stream-caster, please read https://github.com/ossrs/srs/wiki/v2_CN_Streamer\${BLACK}"
echo -e " | ${SrsValgrindSummaryColor}About VALGRIND, please read https://github.com/ossrs/state-threads/issues/2\${BLACK}"
echo -e " \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
echo -e " |${SrsUtestSummaryColor}utest: ./objs/srs_utest, the utest for srs\${BLACK}"
echo -e " \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
echo -e " |${SrsLibrtmpSummaryColor}librtmp @see: https://github.com/ossrs/srs/wiki/v1_CN_SrsLibrtmp\${BLACK}"
echo -e " |${SrsLibrtmpSummaryColor}librtmp: ./objs/include, ./objs/lib, the srs-librtmp library\${BLACK}"
echo -e " | ${SrsLibrtmpSummaryColor}simple handshake: publish/play stream with simple handshake to server\${BLACK}"
echo -e " | ${SrsLibrtmpSSLSummaryColor}complex handshake: it's not required for client, recommend disable it\${BLACK}"
echo -e " | ${SrsLibrtmpSummaryColor}librtmp-sample: ./research/librtmp, the srs-librtmp client sample\${BLACK}"
echo -e " | ${SrsLibrtmpSummaryColor}librtmp-sample: ./research/librtmp/objs/srs_ingest_flv\${BLACK}"
echo -e " | ${SrsLibrtmpSummaryColor}librtmp-sample: ./research/librtmp/objs/srs_ingest_rtmp\${BLACK}"
echo -e " | ${SrsLibrtmpSummaryColor}librtmp-sample: ./research/librtmp/objs/srs_detect_rtmp\${BLACK}"
echo -e " | ${SrsLibrtmpSummaryColor}librtmp-sample: ./research/librtmp/objs/srs_bandwidth_check\${BLACK}"
echo -e " \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
echo -e " |${SrsResearchSummaryColor}research: ./objs/research, api server, players, ts info, librtmp.\${BLACK}"
echo -e " | ${SrsResearchSummaryColor} @see https://github.com/ossrs/srs/wiki/v2_CN_SrsLibrtmp#srs-librtmp-examples\${BLACK}"
echo -e " \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
echo -e " |\${GREEN}tools: important tool, others @see https://github.com/ossrs/srs/wiki/v2_CN_SrsLibrtmp#srs-librtmp-examples\${BLACK}"
echo -e " | \${GREEN}./objs/srs_ingest_hls -i http://ossrs.net/live/livestream.m3u8 -y rtmp://127.0.0.1/live/livestream\${BLACK}"
echo -e " \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
echo -e " |\${GREEN}server: ./objs/srs -c conf/srs.conf, start the srs server\${BLACK}"
echo -e " | ${SrsHlsSummaryColor}hls @see: https://github.com/ossrs/srs/wiki/v2_CN_DeliveryHLS\${BLACK}"
echo -e " | ${SrsHlsSummaryColor}hls: generate m3u8 and ts from rtmp stream\${BLACK}"
echo -e " | ${SrsDvrSummaryColor}dvr @see: https://github.com/ossrs/srs/wiki/v2_CN_DVR\${BLACK}"
echo -e " | ${SrsDvrSummaryColor}dvr: record RTMP stream to flv files.\${BLACK}"
echo -e " | ${SrsNginxSummaryColor}nginx @see: https://github.com/ossrs/srs/wiki/v2_CN_DeliveryHLS\${BLACK}"
echo -e " | ${SrsNginxSummaryColor}nginx: delivery HLS stream by nginx\${BLACK}"
echo -e " | ${SrsNginxSummaryColor}nginx: sudo ./objs/nginx/sbin/nginx\${BLACK}"
echo -e " | ${SrsSslSummaryColor}ssl @see: https://github.com/ossrs/srs/wiki/v1_CN_RTMPHandshake\${BLACK}"
echo -e " | ${SrsSslSummaryColor}ssl: support RTMP complex handshake for client required, for instance, flash\${BLACK}"
echo -e " | ${SrsFfmpegSummaryColor}ffmpeg @see: https://github.com/ossrs/srs/wiki/v1_CN_FFMPEG\${BLACK}"
echo -e " | ${SrsFfmpegSummaryColor}ffmpeg: transcode, mux, ingest tool\${BLACK}"
echo -e " | ${SrsFfmpegSummaryColor}ffmpeg: ./objs/ffmpeg/bin/ffmpeg\${BLACK}"
echo -e " | ${SrsTranscodeSummaryColor}transcode @see: https://github.com/ossrs/srs/wiki/v1_CN_FFMPEG\${BLACK}"
echo -e " | ${SrsTranscodeSummaryColor}transcode: support transcoding RTMP stream\${BLACK}"
echo -e " | ${SrsIngestSummaryColor}ingest @see: https://github.com/ossrs/srs/wiki/v1_CN_Ingest\${BLACK}"
echo -e " | ${SrsIngestSummaryColor}ingest: support ingest file/stream/device then push to SRS by RTMP stream\${BLACK}"
echo -e " | ${SrsHttpCallbackSummaryColor}http-callback @see: https://github.com/ossrs/srs/wiki/v2_CN_HTTPCallback\${BLACK}"
echo -e " | ${SrsHttpCallbackSummaryColor}http-callback: support http callback for authentication and event injection\${BLACK}"
echo -e " | ${SrsHttpServerSummaryColor}http-server @see: https://github.com/ossrs/srs/wiki/v2_CN_HTTPServer\${BLACK}"
echo -e " | ${SrsHttpServerSummaryColor}http-server: support http server to delivery http stream\${BLACK}"
echo -e " | ${SrsHttpApiSummaryColor}http-api @see: https://github.com/ossrs/srs/wiki/v2_CN_HTTPApi\${BLACK}"
echo -e " | ${SrsHttpApiSummaryColor}http-api: support http api to manage server\${BLACK}"
echo -e " | ${SrsStreamCasterSummaryColor}stream-caster @see: https://github.com/ossrs/srs/wiki/v2_CN_Streamer\${BLACK}"
echo -e " | ${SrsStreamCasterSummaryColor}stream-caster: start server to cast stream over other protocols.\${BLACK}"
echo -e " \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
echo -e "\${GREEN}binaries @see: https://github.com/ossrs/srs/wiki/v2_CN_Build\${BLACK}"
echo -e "\${GREEN}binaries, please read https://github.com/ossrs/srs/wiki/v2_CN_Build\${BLACK}"
echo "You can:"
echo " ./objs/srs -c conf/srs.conf"

View file

@ -16,19 +16,10 @@ mkdir -p ${SRS_OBJS}/utest
# the prefix to generate the objs/utest/Makefile
# dirs relative to current dir(objs/utest), it's trunk/objs/utest
# trunk of srs, which contains the src dir, relative to objs/utest, it's trunk
SRS_TRUNK_PREFIX=../..
SRS_TRUNK_PREFIX=../../..
# gest dir, relative to objs/utest, it's trunk/objs/gtest
GTEST_DIR=${SRS_TRUNK_PREFIX}/${SRS_OBJS_DIR}/gtest
# the extra defines to compile utest.
EXTRA_DEFINES=""
# for osx to disable the error.
# gtest/include/gtest/internal/gtest-port.h:499:13: fatal error: 'tr1/tuple' file not found
if [ $SRS_OSX = YES ]; then
EXTRA_DEFINES="$EXTRA_DEFINES -DGTEST_HAS_TR1_TUPLE=0"
fi
cat << END > ${FILE}
# user must run make the ${SRS_OBJS_DIR}/utest dir
# at the same dir of Makefile.
@ -173,13 +164,17 @@ echo "" >> ${FILE}
echo "# link all depends libraries" >> ${FILE}
echo -n "DEPS_LIBRARIES_FILES = " >> ${FILE}
for item in ${ModuleLibFiles[*]}; do
echo -n "${SRS_TRUNK_PREFIX}/${item} " >> ${FILE}
if [[ -f ${item} ]]; then
echo -n "${SRS_TRUNK_PREFIX}/${item} " >> ${FILE}
else
echo -n "${item} " >> ${FILE}
fi
done
echo "" >> ${FILE}; echo "" >> ${FILE}
#
echo "# generate the utest binary" >> ${FILE}
cat << END >> ${FILE}
${SRS_TRUNK_PREFIX}/${SRS_OBJS_DIR}/${APP_NAME} : \$(SRS_UTEST_DEPS) ${MODULE_OBJS} gtest_main.a
${SRS_TRUNK_PREFIX}/${SRS_OBJS_DIR}/${APP_NAME} : \$(SRS_UTEST_DEPS) ${MODULE_OBJS} gtest.a
\$(CXX) -o \$@ \$(CPPFLAGS) \$(CXXFLAGS) \$^ \$(DEPS_LIBRARIES_FILES) ${LINK_OPTIONS}
END
@ -187,4 +182,4 @@ END
# parent Makefile, to create module output dir before compile it.
echo " @mkdir -p ${SRS_OBJS_DIR}/utest" >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
echo -n "generate utest ok"; echo '!';
echo -n "Generate utest ok"; echo '!';

View file

@ -0,0 +1,79 @@
listen 1935;
pid ./objs/srs.pid;
srs_log_tank console;
srs_log_level trace;
max_connections 1000;
daemon off;
http_api {
enabled on;
listen 1985;
crossdomain on;
raw_api {
enabled on;
allow_reload on;
allow_query on;
allow_update on;
}
}
# for SRS1.
http_stream {
enabled on;
listen 8080;
dir ./objs/nginx/html;
}
vhost __defaultVhost__ {
# for SRS1.
http {
enabled on;
mount [vhost]/hls;
dir ./objs/nginx/html/hls;
}
# for SRS1.
refer github.com github.io;
refer_publish github.com github.io;
refer_play github.com github.io;
# for SRS2
publish_1stpkt_timeout 20000;
publish_normal_timeout 7000;
# for SRS2
mr {
enabled off;
latency 350;
}
# for SRS1
mode remote;
origin 127.0.0.1:1935 localhost:1935;
token_traverse off;
vhost same.edge.srs.com;
debug_srs_upnode off;
# for SRS1
forward 127.0.0.1:1936 127.0.0.1:1937;
# for SRS1
time_jitter full;
# for SRS2
mix_correct off;
#for SRS1
atc on;
atc_auto on;
# for SRS2
mw_latency 100;
# for SRS1
gop_cache off;
queue_length 10;
# for SRS2
send_min_interval 10.0;
reduce_sequence_header on;
}

23
trunk/conf/dash.conf Normal file
View file

@ -0,0 +1,23 @@
# the config for srs to delivery dash
# @see https://github.com/ossrs/srs/wiki/v1_CN_SampleDASH
# @see full.conf for detail config.
listen 1935;
max_connections 1000;
daemon off;
srs_log_tank console;
http_server {
enabled on;
listen 8080;
dir ./objs/nginx/html;
}
vhost __defaultVhost__ {
dash {
enabled on;
dash_fragment 30;
dash_update_period 150;
dash_timeshift 300;
dash_path ./objs/nginx/html;
dash_mpd_file [app]/[stream].mpd;
}
}

View file

@ -11,7 +11,9 @@ pid ./objs/srs.demo.19350.pid;
vhost __defaultVhost__ {
enabled on;
gop_cache on;
play {
gop_cache on;
}
hls {
enabled on;
hls_path ./objs/nginx/html/forward;

View file

@ -44,7 +44,10 @@ vhost demo.srs.com {
enabled on;
gop_cache on;
queue_length 30;
forward 127.0.0.1:19350;
forward {
enabled on;
destination 127.0.0.1:19350;
}
bandcheck {
enabled off;
}

29
trunk/conf/docker.conf Normal file
View file

@ -0,0 +1,29 @@
# main config for srs.
# @see full.conf for detail config.
listen 1935;
max_connections 1000;
srs_log_tank console;
daemon off;
http_api {
enabled on;
listen 1985;
}
http_server {
enabled on;
listen 8080;
dir ./objs/nginx/html;
}
stats {
network 0;
disk sda sdb xvda xvdb;
}
vhost __defaultVhost__ {
hls {
enabled on;
}
http_remux {
enabled on;
mount [vhost]/[app]/[stream].flv;
}
}

13
trunk/conf/dvr.mp4.conf Normal file
View file

@ -0,0 +1,13 @@
# the config for srs to dvr in session mode
# @see https://github.com/ossrs/srs/wiki/v3_CN_DVR
# @see full.conf for detail config.
listen 1935;
max_connections 1000;
vhost __defaultVhost__ {
dvr {
enabled on;
dvr_path ./objs/nginx/html/[app]/[stream].[timestamp].mp4;
dvr_plan session;
}
}

View file

@ -1,6 +1,6 @@
# the config for srs to dvr in custom path.
# @see https://github.com/ossrs/srs/wiki/v2_CN_DVR#custom-path
# @see https://github.com/ossrs/srs/wiki/v2_EN_DVR#custom-path
# @see https://github.com/ossrs/srs/wiki/v3_CN_DVR#custom-path
# @see https://github.com/ossrs/srs/wiki/v3_EN_DVR#custom-path
# @see full.conf for detail config.
listen 1935;

View file

@ -1,5 +1,5 @@
# the config for srs to dvr in segment mode
# @see https://github.com/ossrs/srs/wiki/v2_CN_DVR
# @see https://github.com/ossrs/srs/wiki/v3_CN_DVR
# @see full.conf for detail config.
listen 1935;

Some files were not shown because too many files have changed in this diff Show more