unixSOCKET bufsize timeout放在配置文件里面
This commit is contained in:
@@ -18,9 +18,13 @@ MsgPort=22080
|
|||||||
#unix-domain socket file path <20><>send frag
|
#unix-domain socket file path <20><>send frag
|
||||||
UnixSocketSendSrcAddr=/home/mesasoft/frag_rssb/un_send
|
UnixSocketSendSrcAddr=/home/mesasoft/frag_rssb/un_send
|
||||||
UnixSocketSendDestAddr=/home/mcger/un_recv;/home/audiorecognition/aufilter/un_recv
|
UnixSocketSendDestAddr=/home/mcger/un_recv;/home/audiorecognition/aufilter/un_recv
|
||||||
|
#unix-domain socket param, unit:MB us
|
||||||
|
UnixSocketSendBufSize=4
|
||||||
|
UnixSocketSendTimeout=10000
|
||||||
#udp socket recv port <20><>recv response msg
|
#udp socket recv port <20><>recv response msg
|
||||||
UnixSocketRecvAddr=/home/mesasoft/frag_rssb/un_recv
|
UnixSocketRecvAddr=/home/mesasoft/frag_rssb/un_recv
|
||||||
|
|
||||||
|
|
||||||
#udp socket:send frag
|
#udp socket:send frag
|
||||||
UdpSendIP=127.0.0.1;127.0.0.1;
|
UdpSendIP=127.0.0.1;127.0.0.1;
|
||||||
UdpSendIPNum=2
|
UdpSendIPNum=2
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
time:20181207
|
||||||
|
UNIXSOCKET<EFBFBD><EFBFBD><EFBFBD><EFBFBD>buf timeout<75>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
********************************************************
|
||||||
time:20180927
|
time:20180927
|
||||||
1.<2E><><EFBFBD><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
1.<2E><><EFBFBD><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
********************************************************
|
********************************************************
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ $(TARGET):$(OBJECTS) $(OBJECTSCPP) $(LIB_FILE)
|
|||||||
#$(CCC) -shared $(CFLAGS) $(OBJECTS) $(LIB) -o $@
|
#$(CCC) -shared $(CFLAGS) $(OBJECTS) $(LIB) -o $@
|
||||||
$(CCC) $(CFLAGS) $(OBJECTS) $(OBJECTSCPP) $(LIB) $(LDDICTATOR) -o $@
|
$(CCC) $(CFLAGS) $(OBJECTS) $(OBJECTSCPP) $(LIB) $(LDDICTATOR) -o $@
|
||||||
cp $(TARGET) ../bin/
|
cp $(TARGET) ../bin/
|
||||||
cp $(TARGET) /home/mesasoft/frag_rssb/
|
# cp $(TARGET) /home/mesasoft/frag_rssb/
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
#%.d:%.c
|
#%.d:%.c
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int init_unix_socket(const char* file_name);
|
int init_unix_socket(const char* file_name, int timeout_us, int bufsize);
|
||||||
int unix_socket_send(int sockfd, struct sockaddr_un *dest_un, const char*data, int datalen);
|
int unix_socket_send(int sockfd, struct sockaddr_un *dest_un, const char*data, int datalen);
|
||||||
int init_recv_udp_socket(uint16_t port);
|
int init_recv_udp_socket(uint16_t port);
|
||||||
int recv_udp_socket_recv(int sockfd, uint32_t *src_ip, uint8_t *buf, uint32_t buf_size);
|
int recv_udp_socket_recv(int sockfd, uint32_t *src_ip, uint8_t *buf, uint32_t buf_size);
|
||||||
|
|||||||
Binary file not shown.
20
src/main.c
20
src/main.c
@@ -42,9 +42,9 @@ const char* frag_rssb_version = "2018-08-13T09:00:00";
|
|||||||
const char* frag_rssb_version_time = "2018-08-13T09:00:00";
|
const char* frag_rssb_version_time = "2018-08-13T09:00:00";
|
||||||
const char* frag_rssb_version_des = "MESA@iie rssb_maskey";
|
const char* frag_rssb_version_des = "MESA@iie rssb_maskey";
|
||||||
|
|
||||||
int FRAG_RSSB_VERSION_1_0_20181107 = 0;
|
int FRAG_RSSB_VERSION_1_0_20181207 = 0;
|
||||||
const char* frag_rssb_version_time_in = "2018-11-07";
|
const char* frag_rssb_version_time_in = "2018-12-07";
|
||||||
const char* frag_rssb_version_des_in = "alter json_log opt name for k";
|
const char* frag_rssb_version_des_in = "unixsocket";
|
||||||
void frag_rssb_history()
|
void frag_rssb_history()
|
||||||
{
|
{
|
||||||
//2015.11.15 v1.0 create the project
|
//2015.11.15 v1.0 create the project
|
||||||
@@ -223,6 +223,7 @@ void frag_rssb_history()
|
|||||||
//2018.11.02 v4.0//add timer_on
|
//2018.11.02 v4.0//add timer_on
|
||||||
//2018.11.05 v4.0//alter voip save_media frg_len>headerlen
|
//2018.11.05 v4.0//alter voip save_media frg_len>headerlen
|
||||||
//2018.11.07 v4.0//alter json_log opt name for k
|
//2018.11.07 v4.0//alter json_log opt name for k
|
||||||
|
//2018.12.07 v4.0//unixsocket set bufsize timeout in configure
|
||||||
}
|
}
|
||||||
|
|
||||||
frag_rssb_parameter_t g_frag_run;
|
frag_rssb_parameter_t g_frag_run;
|
||||||
@@ -771,14 +772,19 @@ int read_conf_and_init(const char* filename)
|
|||||||
|
|
||||||
/*unix socket : backward data send*/
|
/*unix socket : backward data send*/
|
||||||
memset(conf_buf,0,sizeof(conf_buf));
|
memset(conf_buf,0,sizeof(conf_buf));
|
||||||
|
int bufsize = 0;
|
||||||
|
int timeout_us = 0;
|
||||||
|
MESA_load_profile_int_def(filename, "NETWORK", "UnixSocketSendBufSize", &bufsize, 4);
|
||||||
|
bufsize *= 1024*1024;
|
||||||
|
MESA_load_profile_int_def(filename, "NETWORK", "UnixSocketSendTimeout", &timeout_us, 1000);
|
||||||
rec_dest = MESA_load_profile_string_def(filename, "NETWORK", "UnixSocketSendSrcAddr", conf_buf, sizeof(conf_buf),"/home/mesasoft/frag_rssb/un_sender");
|
rec_dest = MESA_load_profile_string_def(filename, "NETWORK", "UnixSocketSendSrcAddr", conf_buf, sizeof(conf_buf),"/home/mesasoft/frag_rssb/un_sender");
|
||||||
if(-1!=rec_dest)
|
if(-1!=rec_dest)
|
||||||
{
|
{
|
||||||
for(i=0;i<g_frag_cfg.thread_num;i++)
|
for(i=0;i<g_frag_cfg.thread_num;i++)
|
||||||
{
|
{
|
||||||
memset(buf,0,sizeof(buf));
|
memset(buf,0,sizeof(buf));
|
||||||
snprintf(buf,sizeof(buf),"%s_%02d",conf_buf,i);
|
snprintf(buf,sizeof(buf),"%s_%02d",conf_buf,i);
|
||||||
g_frag_run.send_fd[i] = init_unix_socket(buf);
|
g_frag_run.send_fd[i] = init_unix_socket(buf,timeout_us,bufsize);
|
||||||
if(-1==g_frag_run.send_fd[i])
|
if(-1==g_frag_run.send_fd[i])
|
||||||
{
|
{
|
||||||
printf("[%s] init_unix_socket error.\n", FRAG_REASSEMBLY_MODULE_NAME);
|
printf("[%s] init_unix_socket error.\n", FRAG_REASSEMBLY_MODULE_NAME);
|
||||||
@@ -789,8 +795,8 @@ int read_conf_and_init(const char* filename)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
memset(conf_buf,0,sizeof(conf_buf));
|
memset(conf_buf,0,sizeof(conf_buf));
|
||||||
memset(split_buf,0,sizeof(split_buf));
|
memset(split_buf,0,sizeof(split_buf));
|
||||||
rec_dest = MESA_load_profile_string_def(filename, "NETWORK", "UnixSocketSendDestAddr", conf_buf, sizeof(conf_buf),"");
|
rec_dest = MESA_load_profile_string_def(filename, "NETWORK", "UnixSocketSendDestAddr", conf_buf, sizeof(conf_buf),"");
|
||||||
if(-1!=rec_dest)
|
if(-1!=rec_dest)
|
||||||
{
|
{
|
||||||
g_frag_cfg.send_dest_addr_num = string_split(conf_buf, split_buf, DEST_MAXNUM, ';');
|
g_frag_cfg.send_dest_addr_num = string_split(conf_buf, split_buf, DEST_MAXNUM, ';');
|
||||||
|
|||||||
@@ -136,13 +136,12 @@ void input_udp_clear(int sockfd)
|
|||||||
close(sockfd);
|
close(sockfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
int init_unix_socket(const char* file_name)
|
int init_unix_socket(const char* file_name, int timeout_us, int bufsize)
|
||||||
{
|
{
|
||||||
int sockfd = -1;
|
int sockfd = -1;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
struct sockaddr_un un;
|
struct sockaddr_un un;
|
||||||
struct timeval send_timeout;
|
struct timeval send_timeout;
|
||||||
int send_buf_size = 1024*1024*4;
|
|
||||||
|
|
||||||
if(strlen(file_name)+8>sizeof(un.sun_path))
|
if(strlen(file_name)+8>sizeof(un.sun_path))
|
||||||
{
|
{
|
||||||
@@ -157,7 +156,7 @@ int init_unix_socket(const char* file_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
send_timeout.tv_sec = 0;
|
send_timeout.tv_sec = 0;
|
||||||
send_timeout.tv_usec = 100000;
|
send_timeout.tv_usec = timeout_us;
|
||||||
memset(&un,0,sizeof(un));
|
memset(&un,0,sizeof(un));
|
||||||
un.sun_family = AF_UNIX;
|
un.sun_family = AF_UNIX;
|
||||||
if(-1==setsockopt(sockfd,SOL_SOCKET,SO_SNDTIMEO,&send_timeout,sizeof(send_timeout)))
|
if(-1==setsockopt(sockfd,SOL_SOCKET,SO_SNDTIMEO,&send_timeout,sizeof(send_timeout)))
|
||||||
@@ -165,7 +164,7 @@ int init_unix_socket(const char* file_name)
|
|||||||
printf("Set Unix-domain socket error:%s\n",strerror(errno));
|
printf("Set Unix-domain socket error:%s\n",strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(-1==setsockopt(sockfd,SOL_SOCKET,SO_SNDBUF,&send_buf_size,sizeof(send_buf_size)))
|
if(-1==setsockopt(sockfd,SOL_SOCKET,SO_SNDBUF,&bufsize,sizeof(bufsize)))
|
||||||
{
|
{
|
||||||
printf("Set Unix-domain socket error:%s\n",strerror(errno));
|
printf("Set Unix-domain socket error:%s\n",strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int init_unix_socket(const char* file_name);
|
int init_unix_socket(const char* file_name, int timeout_us, int bufsize);
|
||||||
int unix_socket_send(int sockfd, struct sockaddr_un *dest_un, const char*data, int datalen);
|
int unix_socket_send(int sockfd, struct sockaddr_un *dest_un, const char*data, int datalen);
|
||||||
int init_recv_udp_socket(uint16_t port);
|
int init_recv_udp_socket(uint16_t port);
|
||||||
int recv_udp_socket_recv(int sockfd, uint32_t *src_ip, uint8_t *buf, uint32_t buf_size);
|
int recv_udp_socket_recv(int sockfd, uint32_t *src_ip, uint8_t *buf, uint32_t buf_size);
|
||||||
|
|||||||
Reference in New Issue
Block a user