Commit 75de2e40 authored by Haruki NAOI's avatar Haruki NAOI

Add: fail safe for VNF and PNF out of sync.

(cherry picked from commit e9c7c1aae5e61848f0290284ca83d3529553122b)
parent c218facf
......@@ -36,6 +36,7 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <pthread.h>
#include <sys/ioctl.h>
#endif
#include "vnf.h"
#ifdef PHY_RM
......@@ -594,6 +595,7 @@ int nfapi_vnf_start(nfapi_vnf_config_t* config)
int cell_id = 0;
char Buffer[64];
char cell[64];
int attr;
vnf_info* vnf = (vnf_info*)(config->user_data);
vnf_p7_info* p7_vnf = vnf->p7_vnfs;
......@@ -606,6 +608,9 @@ int nfapi_vnf_start(nfapi_vnf_config_t* config)
strcat(Buffer, cell);
init_server_eventfd(vnf_p7->fapi_1ms_fd_list, 1, Buffer);
attr=1; /* non blocking */
ioctl(vnf_p7->fapi_1ms_fd_list[0], FIONBIO, &attr);
vnf_p7->maxfd = vnf_p7->fapi_1ms_fd_list[0];
......
......@@ -388,6 +388,13 @@ int nfapi_vnf_p7_time(nfapi_vnf_p7_config_t* config){
uint8_t buf_1ms[32];
struct sockaddr_in addr;
int sock_1ms;
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 1200;
fd_set fds, readfds;
int retval;
int ret;
static int sync = 0;
sock_1ms = socket(AF_INET,SOCK_DGRAM,0);
addr.sin_family = AF_INET;
......@@ -395,6 +402,9 @@ int nfapi_vnf_p7_time(nfapi_vnf_p7_config_t* config){
addr.sin_addr.s_addr = INADDR_ANY;
bind(sock_1ms, (struct sockaddr *) &addr,sizeof(addr));
FD_ZERO(&readfds);
FD_SET(vnf_p7->fapi_1ms_fd_list[0], &readfds);
clock_gettime(CLOCK_MONOTONIC, &sf_start);
//long millisecond = sf_start.tv_nsec / 1e6;
sf_start = timespec_add(sf_start, sf_duration);
......@@ -450,7 +460,27 @@ int nfapi_vnf_p7_time(nfapi_vnf_p7_config_t* config){
sf_duration.tv_nsec = 1000000;
}
#ifndef UDP_1MS
recv(vnf_p7->fapi_1ms_fd_list[0], &data, sizeof(data), 0);
memcpy(&fds, &readfds, sizeof(fd_set));
if(!sync) {
retval = select(vnf_p7->fapi_1ms_fd_list[0]+1, &fds, NULL, NULL, NULL);
}
else {
retval = select(vnf_p7->fapi_1ms_fd_list[0]+1, &fds, NULL, NULL, &tv);
}
if(retval == 1) {
while(1) {
ret = recv(vnf_p7->fapi_1ms_fd_list[0], &data, sizeof(data), 0);
if(ret < 1) {
break;
}
}
}
else {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "recv timeout sfnsf = 0x%x\n", curr->sfn_sf);
}
sync = 1;
#else
recv(sock_1ms,buf_1ms,sizeof(buf_1ms),0);
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment