Skip to content

Commit 0c38d35

Browse files
committed
Update liblcb
1 parent 11b8b36 commit 0c38d35

6 files changed

Lines changed: 65 additions & 21 deletions

File tree

conf/msd_channels.conf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,21 @@
9292

9393

9494
<channel>
95-
<name>cam_angara.ts</name>
95+
<name>test.tstest.ts</name>
9696
<hubProfileName>default-HD</hubProfileName>
9797
<precache>8192</precache>
9898
<sourceList>
9999
<source>
100100
<type>tcp-http</type>
101101
<MPEG2TS> <!-- Overwrite hub param same name flag if set. -->
102-
<fEnable>yes</fEnable> <!-- Enable MPEG2-TS analyzer. Overwrite hub param same name flag if set. -->
102+
<fEnable>no</fEnable> <!-- Enable MPEG2-TS analyzer. Overwrite hub param same name flag if set. -->
103103
</MPEG2TS>
104104
<sourceProfileName>tcp-http-default</sourceProfileName> <!-- Profile template. -->
105105
<tcp> <!-- For: tcp- and tcp-http. -->
106-
<remonteHostname>194.143.148.19:8081</remonteHostname>
106+
<remonteHostname>127.0.0.1:7088</remonteHostname>
107107
</tcp>
108108
<http>
109-
<urlPath>udp/239.16.150.1:1234</urlPath>
109+
<urlPath>udp/239.0.0.1:1234</urlPath>
110110
</http>
111111
</source>
112112
</sourceList>

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![Build-Ubuntu-latest Actions Status](https://github.com/rozhuk-im/msd/workflows/build-ubuntu-latest/badge.svg)](https://github.com/rozhuk-im/msd/actions)
55

66

7-
Rozhuk Ivan <rozhuk.im@gmail.com> 2011-2025
7+
Rozhuk Ivan <rozhuk.im@gmail.com> 2011-2026
88

99
msd - Multi stream daemon.
1010
Program for organizing IP TV streaming on the network via HTTP.

src/msd.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*-
2-
* Copyright (c) 2011-2025 Rozhuk Ivan <rozhuk.im@gmail.com>
2+
* Copyright (c) 2011-2026 Rozhuk Ivan <rozhuk.im@gmail.com>
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -520,6 +520,7 @@ main(int argc, char *argv[]) {
520520
const uint8_t *data;
521521
size_t data_size;
522522
tp_settings_t tp_s;
523+
tp_params_t tp_prms;
523524
http_srv_settings_t http_s;
524525

525526
error = read_file(cmd_line_data.cfg_file_name, 0, 0, 0,
@@ -556,18 +557,29 @@ main(int argc, char *argv[]) {
556557
sys_res_limits_xml(data, data_size);
557558
}
558559

560+
/* Thread pool. */
559561
/* Thread pool settings. */
560562
tp_settings_def(&tp_s);
561563
if (0 == MSD_CFG_GET_VAL_DATA(NULL, &data, &data_size,
562564
"threadPool", NULL)) {
563565
tp_settings_load_xml(data, data_size, &tp_s);
564566
}
565-
error = tp_create(&tp_s, &tp);
567+
/* Params. */
568+
memset(&tp_prms, 0x00, sizeof(tp_prms));
569+
strlcpy(tp_prms.name, "Events pool", sizeof(tp_prms.name));
570+
tp_prms.flags = TP_P_F_CLOEXEC;
571+
error = tp_create(&tp_s, &tp_prms, &tp);
566572
if (0 != error) {
567573
SYSLOG_ERR(LOG_CRIT, error, "tp_create().");
568574
goto err_out;
569575
}
570-
tp_threads_create(tp, 1);// XXX exit rewrite
576+
577+
/* Create and start threads. */
578+
error = tp_threads_create(tp);
579+
if (0 != error) {
580+
SYSLOG_ERR(LOG_CRIT, error, "tp_threads_create().");
581+
goto err_out;
582+
}
571583

572584

573585
error = str_hubs_bckt_create(tp, PACKAGE_NAME"/"PACKAGE_VERSION, &shbskt);
@@ -682,8 +694,10 @@ main(int argc, char *argv[]) {
682694
#endif
683695

684696
/* Receive and process packets. */
685-
tp_thread_attach_first(g_data.tp);
686-
tp_shutdown_wait(g_data.tp);
697+
error = tp_shutdown_wait(g_data.tp);
698+
if (0 != error) {
699+
SYSLOG_ERR(LOG_ERR, error, "tp_shutdown_wait().");
700+
}
687701

688702
/* Deinitialization... */
689703
http_srv_shutdown(g_data.http_srv); /* No more new clients. */

src/stream_hub.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*-
2-
* Copyright (c) 2012-2024 Rozhuk Ivan <rozhuk.im@gmail.com>
2+
* Copyright (c) 2012-2026 Rozhuk Ivan <rozhuk.im@gmail.com>
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -894,9 +894,9 @@ str_hub_cli_attach(str_hub_p str_hub, str_hub_cli_p strh_cli) {
894894

895895
sa_addr_port_to_str(&strh_cli->remonte_addr, straddr, sizeof(straddr), NULL);
896896
/* Tune socket. */
897-
error = skt_opts_apply_ex(tp_task_ident_get(strh_cli->tptask),
897+
error = skt_opts_apply(tp_task_ident_get(strh_cli->tptask),
898898
SO_F_TCP_ES_CONN_MASK, &str_hub->s.skt_opts, 0, NULL);
899-
SYSLOG_ERR(LOG_WARNING, error, "%s - %s: skt_opts_apply_ex().",
899+
SYSLOG_ERR(LOG_WARNING, error, "%s - %s: skt_opts_apply().",
900900
str_hub->name, straddr);
901901
syslog(LOG_INFO,
902902
"%s - %s: attached, cli_count = %zu, snd_block_min_size = %zu, precache = %zu.",

src/stream_src.c

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*-
2-
* Copyright (c) 2012-2025 Rozhuk Ivan <rozhuk.im@gmail.com>
2+
* Copyright (c) 2012-2026 Rozhuk Ivan <rozhuk.im@gmail.com>
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -59,6 +59,7 @@
5959
#include "proto/http.h"
6060
#include "crypto/hash/md5.h"
6161
#include "utils/xml.h"
62+
#include "utils/strh2num.h"
6263

6364
#include "stream_mpeg2ts.h"
6465
#include "stream_src.h"
@@ -729,11 +730,11 @@ str_src_start(str_src_p src) {
729730
}
730731
}
731732
/* Tune socket. */
732-
error = skt_opts_apply_ex(skt, SO_F_UDP_BIND_AF_MASK,
733+
error = skt_opts_apply(skt, SO_F_UDP_BIND_AF_MASK,
733734
&s->skt_opts, conn_udp->addr.ss_family, NULL);
734735
if (0 != error) {
735736
SYSLOG_ERR(LOG_ERR, error,
736-
"skt_opts_apply_ex(SO_F_UDP_BIND_AF_MASK) fail.");
737+
"skt_opts_apply(SO_F_UDP_BIND_AF_MASK) fail.");
737738
goto err_out;
738739
}
739740
/* Create IO task for socket. */
@@ -940,12 +941,12 @@ str_src_connected(tp_task_p tptask, int error, void *arg) {
940941
}
941942
/* Connected! */
942943
/* Tune socket. */
943-
error = skt_opts_apply_ex(tp_task_ident_get(tptask),
944+
error = skt_opts_apply(tp_task_ident_get(tptask),
944945
(SO_F_TCP_ES_CONN_MASK & ~SO_F_HALFCLOSE_RDWR),
945946
&src->s.skt_opts, 0, NULL);
946947
if (0 != error) {
947948
SYSLOG_ERR(LOG_NOTICE, error,
948-
"skt_opts_apply_ex(SO_F_TCP_ES_CONN_MASK & ~SO_F_HALFCLOSE_RDWR) fail.");
949+
"skt_opts_apply(SO_F_TCP_ES_CONN_MASK & ~SO_F_HALFCLOSE_RDWR) fail.");
949950
goto err_out;
950951
}
951952

@@ -1003,10 +1004,10 @@ str_src_send_http_req_done_cb(tp_task_p tptask, int error, io_buf_p buf __unused
10031004

10041005
tp_task_stop(tptask);
10051006

1006-
error = skt_opts_apply_ex(tp_task_ident_get(tptask),
1007+
error = skt_opts_apply(tp_task_ident_get(tptask),
10071008
SO_F_HALFCLOSE_WR, &src->s.skt_opts, 0, NULL);
10081009
SYSLOG_ERR(LOG_NOTICE, error,
1009-
"skt_opts_apply_ex(SO_F_HALFCLOSE_WR) fail, not fatal.");
1010+
"skt_opts_apply(SO_F_HALFCLOSE_WR) fail, not fatal.");
10101011

10111012
/* Convert to "ready to read notifier". */
10121013
tp_task_tp_cb_func_set(tptask, tp_task_notify_handler);
@@ -1134,6 +1135,35 @@ str_src_recv_http_cb(tp_task_p tptask, int error, uint32_t eof,
11341135
return (TP_TASK_CB_CONTINUE);
11351136
}
11361137

1138+
/*
1139+
* HexNumCRLF
1140+
* dataCRLF
1141+
* HexNum
1142+
*/
1143+
static int
1144+
http_data_chunked_size(const uint8_t *buf, const size_t buf_size,
1145+
size_t *chunk_size, size_t *chunk_marker_size) {
1146+
uint8_t *ptr_end;
1147+
1148+
if (NULL == buf || 5 > buf_size) /* 5 - min size: CRLF + num + CRLF */
1149+
return (EINVAL);
1150+
if ('\r' != buf[0] || '\n' != buf[1])
1151+
return (EINVAL);
1152+
ptr_end = mem_find_off(2, buf, buf_size, CRLF, 2);
1153+
if (NULL == ptr_end ||
1154+
3 > (ptr_end - buf))
1155+
return (EINVAL);
1156+
1157+
if (NULL != chunk_size) {
1158+
(*chunk_size) = ustrh2usize((buf + 2), (size_t)((ptr_end - (buf + 2))));
1159+
}
1160+
if (NULL != chunk_marker_size) {
1161+
(*chunk_marker_size) = (size_t)((ptr_end - buf) + 2);
1162+
}
1163+
1164+
return (0);
1165+
}
1166+
11371167
static int
11381168
str_src_recv_tcp_cb(tp_task_p tptask, int error, uint32_t eof,
11391169
size_t data2transfer_size, void *arg) {

0 commit comments

Comments
 (0)