unixSOCKET bufsize timeout放在配置文件里面
This commit is contained in:
@@ -52,7 +52,7 @@ $(TARGET):$(OBJECTS) $(OBJECTSCPP) $(LIB_FILE)
|
||||
#$(CCC) -shared $(CFLAGS) $(OBJECTS) $(LIB) -o $@
|
||||
$(CCC) $(CFLAGS) $(OBJECTS) $(OBJECTSCPP) $(LIB) $(LDDICTATOR) -o $@
|
||||
cp $(TARGET) ../bin/
|
||||
cp $(TARGET) /home/mesasoft/frag_rssb/
|
||||
# cp $(TARGET) /home/mesasoft/frag_rssb/
|
||||
|
||||
.c.o:
|
||||
#%.d:%.c
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
extern "C" {
|
||||
#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 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);
|
||||
|
||||
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_des = "MESA@iie rssb_maskey";
|
||||
|
||||
int FRAG_RSSB_VERSION_1_0_20181107 = 0;
|
||||
const char* frag_rssb_version_time_in = "2018-11-07";
|
||||
const char* frag_rssb_version_des_in = "alter json_log opt name for k";
|
||||
int FRAG_RSSB_VERSION_1_0_20181207 = 0;
|
||||
const char* frag_rssb_version_time_in = "2018-12-07";
|
||||
const char* frag_rssb_version_des_in = "unixsocket";
|
||||
void frag_rssb_history()
|
||||
{
|
||||
//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.05 v4.0//alter voip save_media frg_len>headerlen
|
||||
//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;
|
||||
@@ -771,14 +772,19 @@ int read_conf_and_init(const char* filename)
|
||||
|
||||
/*unix socket : backward data send*/
|
||||
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");
|
||||
if(-1!=rec_dest)
|
||||
{
|
||||
{
|
||||
for(i=0;i<g_frag_cfg.thread_num;i++)
|
||||
{
|
||||
memset(buf,0,sizeof(buf));
|
||||
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])
|
||||
{
|
||||
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(split_buf,0,sizeof(split_buf));
|
||||
rec_dest = MESA_load_profile_string_def(filename, "NETWORK", "UnixSocketSendDestAddr", conf_buf, sizeof(conf_buf),"");
|
||||
memset(split_buf,0,sizeof(split_buf));
|
||||
rec_dest = MESA_load_profile_string_def(filename, "NETWORK", "UnixSocketSendDestAddr", conf_buf, sizeof(conf_buf),"");
|
||||
if(-1!=rec_dest)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
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 len = 0;
|
||||
struct sockaddr_un un;
|
||||
struct timeval send_timeout;
|
||||
int send_buf_size = 1024*1024*4;
|
||||
|
||||
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_usec = 100000;
|
||||
send_timeout.tv_usec = timeout_us;
|
||||
memset(&un,0,sizeof(un));
|
||||
un.sun_family = AF_UNIX;
|
||||
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));
|
||||
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));
|
||||
return -1;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
extern "C" {
|
||||
#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 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);
|
||||
|
||||
Reference in New Issue
Block a user