-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
101 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule liblcb
updated
28 files
+14 −0 | .github/FUNDING.yml | |
+2 −3 | CMakeLists.txt | |
+0 −13 | README | |
+11 −7 | include/al/hw.h | |
+1 −1 | include/proto/http_server_auth.h | |
+2 −1 | include/utils/cmd_line_daemon.h | |
+0 −109 | include/utils/log.h | |
+33 −0 | include/utils/macro.h | |
+5 −5 | lib.project | |
+2 −2 | liblcb.workspace | |
+29 −0 | readme.md | |
+6 −3 | src/net/socket.c | |
+4 −1 | src/net/socket_options.c | |
+25 −17 | src/proto/dns_resolv.c | |
+7 −8 | src/proto/http_client.c | |
+66 −74 | src/proto/http_server.c | |
+13 −24 | src/proto/http_server_auth.c | |
+29 −29 | src/proto/radius_client.c | |
+11 −11 | src/proto/sap_rcvr.c | |
+48 −41 | src/proto/upnp_ssdp.c | |
+49 −45 | src/threadpool/threadpool.c | |
+2 −3 | src/threadpool/threadpool_msg_sys.c | |
+2 −7 | src/threadpool/threadpool_task.c | |
+52 −23 | src/utils/cmd_line_daemon.c | |
+0 −212 | src/utils/log.c | |
+8 −10 | src/utils/ring_buffer.c | |
+26 −27 | tests/threadpool/main.c | |
+2 −3 | tests/threadpool/test-threadpool.project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/*- | ||
* Copyright (c) 2012-2023 Rozhuk Ivan <[email protected]> | ||
* Copyright (c) 2012-2024 Rozhuk Ivan <[email protected]> | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
|
@@ -50,6 +50,7 @@ | |
#include <unistd.h> /* close, write, sysconf */ | ||
#include <fcntl.h> /* open, fcntl */ | ||
#include <signal.h> /* SIGNAL constants. */ | ||
#include <syslog.h> | ||
|
||
|
||
#include "utils/mem_utils.h" | ||
|
@@ -65,7 +66,6 @@ | |
#include "threadpool/threadpool_task.h" | ||
#include "utils/buf_str.h" | ||
#include "utils/sys.h" | ||
#include "utils/log.h" | ||
#include "proto/http_server.h" | ||
#include "utils/info.h" | ||
#include "utils/cmd_line_daemon.h" | ||
|
@@ -277,7 +277,6 @@ msd_src_conn_profile_load(const uint8_t *data, size_t data_size, void *conn) { | |
int | ||
main(int argc, char *argv[]) { | ||
int error = 0; | ||
int log_fd = -1; | ||
uint8_t *cfg_file_buf = NULL; | ||
size_t tm, cfg_file_buf_size = 0; | ||
tp_p tp; | ||
|
@@ -293,60 +292,49 @@ main(int argc, char *argv[]) { | |
} | ||
if (0 != cmd_line_data.daemon) { | ||
make_daemon(); | ||
openlog(PACKAGE_NAME, | ||
(LOG_NDELAY | LOG_PID | ((0 != cmd_line_data.verbose) ? LOG_PERROR : 0)), | ||
LOG_DAEMON); | ||
} else { | ||
openlog(PACKAGE_NAME, | ||
(LOG_NDELAY | LOG_PID | LOG_PERROR), LOG_USER); | ||
} | ||
setlogmask(LOG_UPTO(cmd_line_data.log_level)); | ||
|
||
{ // process config file | ||
{ /* Process config file. */ | ||
const uint8_t *data; | ||
char strbuf[1024]; | ||
size_t data_size; | ||
tp_settings_t tp_s; | ||
http_srv_cli_ccb_t ccb; | ||
http_srv_settings_t http_s; | ||
|
||
g_log_fd = (uintptr_t)open("/dev/stderr", (O_WRONLY | O_APPEND)); | ||
error = read_file(cmd_line_data.cfg_file_name, 0, 0, 0, | ||
CFG_FILE_MAX_SIZE, &cfg_file_buf, &cfg_file_buf_size); | ||
if (0 != error) { | ||
LOG_ERR(error, "config read_file()"); | ||
SYSLOG_ERR(LOG_CRIT, error, "config read_file()."); | ||
goto err_out; | ||
} | ||
if (0 != xml_get_val_args(cfg_file_buf, cfg_file_buf_size, | ||
NULL, NULL, NULL, NULL, NULL, | ||
(const uint8_t*)"msd", NULL)) { | ||
LOG_INFO("Config file XML format invalid."); | ||
syslog(LOG_CRIT, "Config file XML format invalid."); | ||
goto err_out; | ||
} | ||
|
||
/* Log file */ | ||
if (0 == cmd_line_data.verbose && | ||
0 == MSD_CFG_GET_VAL_DATA(NULL, &data, &data_size, | ||
"log", "file", NULL)) { | ||
if (sizeof(strbuf) > data_size) { | ||
memcpy(strbuf, data, data_size); | ||
strbuf[data_size] = 0; | ||
log_fd = open(strbuf, | ||
(O_WRONLY | O_APPEND | O_CREAT), 0644); | ||
if (-1 == log_fd) { | ||
LOG_ERR(errno, "Fail to open log file."); | ||
} | ||
} else { | ||
LOG_ERR(EINVAL, "Log file name too long."); | ||
} | ||
} else if (0 != cmd_line_data.verbose) { | ||
log_fd = open("/dev/stdout", (O_WRONLY | O_APPEND)); | ||
} | ||
close((int)g_log_fd); | ||
g_log_fd = (uintptr_t)log_fd; | ||
fd_set_nonblocking(g_log_fd, 1); | ||
log_write("\n\n\n\n", 4); | ||
LOG_INFO(PACKAGE_STRING": started"); | ||
/* Log level. */ | ||
if (0 == MSD_CFG_GET_VAL_UINT(NULL, (uint32_t*)&cmd_line_data.log_level, | ||
"log", "level", NULL)) { | ||
setlogmask(LOG_UPTO(cmd_line_data.log_level)); | ||
} | ||
syslog(LOG_NOTICE, PACKAGE_STRING": started!"); | ||
#ifdef DEBUG | ||
LOG_INFO("Build: "__DATE__" "__TIME__", DEBUG"); | ||
syslog(LOG_INFO, "Build: "__DATE__" "__TIME__", DEBUG."); | ||
#else | ||
LOG_INFO("Build: "__DATE__" "__TIME__", Release"); | ||
syslog(LOG_INFO, "Build: "__DATE__" "__TIME__", Release."); | ||
#endif | ||
LOG_INFO_FMT("CPU count: %d", get_cpu_count()); | ||
LOG_INFO_FMT("descriptor table size: %d (max files)", getdtablesize()); | ||
syslog(LOG_INFO, "CPU count: %d.", get_cpu_count()); | ||
syslog(LOG_INFO, "Descriptor table size: %d (max files).", getdtablesize()); | ||
|
||
|
||
/* System resource limits. */ | ||
if (0 == MSD_CFG_GET_VAL_DATA(NULL, &data, &data_size, | ||
|
@@ -362,16 +350,16 @@ main(int argc, char *argv[]) { | |
} | ||
error = tp_create(&tp_s, &tp); | ||
if (0 != error) { | ||
LOG_ERR(error, "tp_create()"); | ||
SYSLOG_ERR(LOG_CRIT, error, "tp_create()."); | ||
goto err_out; | ||
} | ||
tp_threads_create(tp, 1);// XXX exit rewrite | ||
tp_threads_create(tp, 1); /* XXX exit rewrite. */ | ||
|
||
|
||
/* HTTP server settings. */ | ||
/* Read from config. */ | ||
if (0 != MSD_CFG_GET_VAL_DATA(NULL, &data, &data_size, "HTTP", NULL)) { | ||
LOG_INFO("No HTTP server settings, nothink to do..."); | ||
syslog(LOG_NOTICE, "No HTTP server settings, nothink to do..."); | ||
goto err_out; | ||
} | ||
http_srv_def_settings(1, PACKAGE_NAME"/"PACKAGE_VERSION, 1, &http_s); | ||
|
@@ -385,7 +373,7 @@ main(int argc, char *argv[]) { | |
NULL, &ccb, &http_s, &g_data, | ||
&g_data.http_srv); | ||
if (0 != error) { | ||
LOG_ERR(error, "http_srv_xml_load_start()"); | ||
SYSLOG_ERR(LOG_CRIT, error, "http_srv_xml_load_start()."); | ||
goto err_out; | ||
} | ||
|
||
|
@@ -411,9 +399,10 @@ main(int argc, char *argv[]) { | |
error = str_hubs_bckt_create(tp, PACKAGE_NAME"/"PACKAGE_VERSION, &g_data.hub_params, | ||
&g_data.src_params, &g_data.shbskt); | ||
if (0 != error) { | ||
LOG_ERR(error, "str_hubs_bckt_create()"); | ||
SYSLOG_ERR(LOG_CRIT, error, "str_hubs_bckt_create()."); | ||
goto err_out; | ||
} | ||
free(cfg_file_buf); | ||
} /* Done with config. */ | ||
|
||
|
||
|
@@ -446,9 +435,8 @@ main(int argc, char *argv[]) { | |
} | ||
|
||
tp_destroy(tp); | ||
LOG_INFO("exiting."); | ||
close((int)g_data.log_fd); | ||
free(cfg_file_buf); | ||
syslog(LOG_NOTICE, "Exiting."); | ||
closelog(); | ||
|
||
err_out: | ||
return (error); | ||
|
@@ -469,7 +457,7 @@ msd_http_srv_hub_attach(http_srv_cli_p cli, uint8_t *hub_name, size_t hub_name_s | |
tp_task_p tptask; | ||
uintptr_t skt; | ||
|
||
LOGD_EV("..."); | ||
SYSLOGD_EX(LOG_DEBUG, "..."); | ||
|
||
if (NULL == cli || NULL == hub_name) | ||
return (EINVAL); | ||
|
@@ -491,7 +479,7 @@ msd_http_srv_hub_attach(http_srv_cli_p cli, uint8_t *hub_name, size_t hub_name_s | |
} | ||
strh_cli = str_hub_cli_alloc(skt, (const char*)ptm, tm); | ||
if (NULL == strh_cli) { | ||
LOG_ERR(ENOMEM, "str_hub_cli_alloc()"); | ||
syslog(LOG_ERR, "str_hub_cli_alloc()."); | ||
return (ENOMEM); | ||
} | ||
/* | ||
|
@@ -508,14 +496,14 @@ msd_http_srv_hub_attach(http_srv_cli_p cli, uint8_t *hub_name, size_t hub_name_s | |
sa_copy(&strh_cli->remonte_addr, &strh_cli->xreal_addr); | ||
} | ||
|
||
LOGD_INFO_FMT("%s - : attach...", hub_name); | ||
SYSLOGD_EX(LOG_DEBUG, "%s - : attach...", hub_name); | ||
error = str_hub_cli_attach(g_data.shbskt, strh_cli, hub_name, hub_name_size, | ||
src_conn_params); | ||
/* Do not read/write to stream hub client, stream hub is new owner! */ | ||
if (0 != error) { | ||
strh_cli->skt = (uintptr_t)-1; | ||
str_hub_cli_destroy(NULL, strh_cli); | ||
LOG_ERR(error, "str_hub_cli_attach()"); | ||
SYSLOG_ERR(LOG_ERR, error, "str_hub_cli_attach()."); | ||
} else { | ||
tp_task_flags_del(tptask, TP_TASK_F_CLOSE_ON_DESTROY); | ||
http_srv_cli_free(cli); | ||
|
@@ -533,7 +521,7 @@ msd_http_req_url_parse(http_srv_req_p req, struct sockaddr_storage *ssaddr, | |
char straddr[STR_ADDR_LEN], ifname[(IFNAMSIZ + 1)]; | ||
struct sockaddr_storage ss; | ||
|
||
LOGD_EV("..."); | ||
SYSLOGD_EX(LOG_DEBUG, "..."); | ||
|
||
if (NULL == req || NULL == hub_name || 0 == hub_name_size) | ||
return (500); | ||
|
@@ -613,7 +601,7 @@ msd_http_srv_on_req_rcv_cb(http_srv_cli_p cli, void *udata __unused, | |
static const char *cttype = "Content-Type: text/plain\r\n" | ||
"Pragma: no-cache"; | ||
|
||
LOGD_EV("..."); | ||
SYSLOGD_EX(LOG_DEBUG, "..."); | ||
|
||
if (HTTP_REQ_METHOD_GET != req->line.method_code && | ||
HTTP_REQ_METHOD_HEAD != req->line.method_code) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/*- | ||
* Copyright (c) 2012 - 2021 Rozhuk Ivan <[email protected]> | ||
* Copyright (c) 2012-2024 Rozhuk Ivan <[email protected]> | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
|
@@ -57,7 +57,6 @@ | |
#include "proto/http_server.h" | ||
#include "stream_sys.h" | ||
#include "utils/info.h" | ||
#include "utils/log.h" | ||
#include "msd_lite_stat_text.h" | ||
|
||
|
||
|
Oops, something went wrong.