Merge "[Bugfix][T106BUG-571][AT]when sending RMII,it will have a probability of blocking"
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-at-factory/liblynq-at-factory.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-at-factory/liblynq-at-factory.cpp
index cc26db6..c82b119 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-at-factory/liblynq-at-factory.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-at-factory/liblynq-at-factory.cpp
@@ -561,12 +561,9 @@
int receive_data(int fd,char *buf_send,char *buf_recv, int send_len, int count)
{
- time_t time_start;
- time_t time_end;
ssize_t ret;
char *buf_cmp = NULL;
int corrent_cont = 0;
- time_start=time(NULL);
char reason_buf[32] = {0};
/*To prevent packet loss,Setting 50 opportunities*/
@@ -575,13 +572,6 @@
bzero(reason_buf,sizeof(reason_buf));
bzero(buf_recv, sizeof(buf_recv));
ret = recv(fd,buf_recv,1472,0);
- time_end=time(NULL);
- if(difftime(time_end,time_start)>2)
- {
- sprintf(reason_buf,"%d:time_out\n",count);
- ALOGD(reason_buf, strlen(reason_buf), Response);
- return -1;
- }
if(ret<0)
{
sprintf(reason_buf,"%d:recv_fail\n",count);
@@ -589,7 +579,7 @@
return -1;
}
- else if (ret < sizeof(buf_recv))
+ else if (ret < send_len)
{
continue;
}
@@ -679,6 +669,8 @@
int rgmii_socket_init(struct sockaddr_in* server_addr, const char * ip_addr)
{
int ser_socket = -1;
+ struct timeval timeout={1,0};
+ int ret;
server_addr->sin_family=AF_INET;
server_addr->sin_port = htons(100);
server_addr->sin_addr.s_addr = inet_addr(ip_addr);
@@ -689,9 +681,13 @@
{
return -1;
}
-
- struct timeval timeout={1,0};
- int ret;
+
+ ret = setsockopt(ser_socket, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(struct timeval));
+ if(ret < 0)
+ {
+ printf("set socket timeout init_failed\n");
+ return -1;
+ }
ret = bind(ser_socket,(struct sockaddr*)server_addr,sizeof(*server_addr));
if(ret< 0)
{
@@ -713,6 +709,7 @@
struct sockaddr_in ser_addr;
struct sockaddr_in cli_addr;
struct sockaddr_ll raw_addr;
+ struct timeval raw_timeout={2,0};
struct ifreq ser;
time_t start,end;
bzero(buf_init,sizeof(buf_init));
@@ -752,6 +749,14 @@
raw_addr.sll_protocol = htons(ETH_P_ALL);
raw_addr.sll_ifindex = if_nametoindex("eth0");
+ ret = setsockopt(raw_socket, SOL_SOCKET, SO_RCVTIMEO, &raw_timeout, sizeof(struct timeval));
+ if(ret < 0)
+ {
+ printf("set raw_socket timeout init_failed\n");
+ lynq_response_error(3);
+ return -1;
+ }
+
ret = bind(raw_socket, (struct sockaddr*)&raw_addr, sizeof(raw_addr));//bind network interface card
if(ret < 0)
{