<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);"> 偶然情况下recvfrom函数出现了不正常的情况,目前还没有复现。</span>
Post part of the code and the information in the log price.
struct timeval tv_out;tv_out.tv_sec = 120;tv_out.tv_usec = 0;setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv_out, sizeof(tv_out)); udp_media_cond = 1; while(udp_media_cond) { memset(buf, 0, sizeof(buf)); memset(temp, 0, sizeof(temp)); len = recvfrom(sockfd, buf, sizeof(buf), 0, (struct sockaddr *)&client_addr_from, &fromlen); if (0 >= len) { syslog(LOG_DEBUG, "DEBUG:recv data error!"); syslog(LOG_DEBUG, "DEBUG:uid is '%s', port is '%d'.", uid, port); if (EAGAIN == errno) { syslog(LOG_DEBUG, "DEBUG: EAGAIN!"); //return 0; } } buf[len] = '\0';}
Printing in logs:
Oct 27 12:26:16 32f32c8c-8c75-4249-bbf2-afa068de9aaf server_debug:[2218]: DEBUG:recv data error!Oct 27 12:26:16 32f32c8c-8c75-4249-bbf2-afa068de9aaf server_debug:[2218]: DEBUG:uid is '00060110', port is '5500'.Oct 27 12:26:16 32f32c8c-8c75-4249-bbf2-afa068de9aaf server_debug:[2218]: DEBUG: EAGAIN!Oct 27 12:26:16 32f32c8c-8c75-4249-bbf2-afa068de9aaf server_debug:[2218]: DEBUG:recv data error!Oct 27 12:26:16 32f32c8c-8c75-4249-bbf2-afa068de9aaf server_debug:[2218]: DEBUG:uid is '00060110', port is '5500'.Oct 27 12:26:16 32f32c8c-8c75-4249-bbf2-afa068de9aaf server_debug:[2218]: DEBUG:recv data error!Oct 27 12:26:16 32f32c8c-8c75-4249-bbf2-afa068de9aaf server_debug:[2218]: DEBUG:uid is '00060110', port is '5500'.Oct 27 12:26:16 32f32c8c-8c75-4249-bbf2-afa068de9aaf server_debug:[2218]: DEBUG:recv data error!Oct 27 12:26:16 32f32c8c-8c75-4249-bbf2-afa068de9aaf server_debug:[2218]: DEBUG:uid is '00060110', port is '5500'.Oct 27 12:26:16 32f32c8c-8c75-4249-bbf2-afa068de9aaf server_debug:[2218]: DEBUG:recv data error!Oct 27 12:26:16 32f32c8c-8c75-4249-bbf2-afa068de9aaf server_debug:[2218]: DEBUG:uid is '00060110', port is '5500'.
More than a dozen pieces of data are printed at the end.
Oct 27 12:26:16 32f32c8c-8c75-4249-bbf2-afa068de9aaf rsyslogd-2177: imuxsock begins to drop messages from pid 2218 due to rate-limitingOct 27 12:26:22 32f32c8c-8c75-4249-bbf2-afa068de9aaf rsyslogd-2177: imuxsock lost 176521 messages from pid 2218 due to rate-limiting
Normally, these prints are not available.
Oct 27 12:26:16 32f32c8c-8c75-4249-bbf2-afa068de9aaf server_debug:[2218]: DEBUG: EAGAIN!
It took 2 minutes to receive no data.
Crazy print
Oct 27 12:26:16 32f32c8c-8c75-4249-bbf2-afa068de9aaf server_debug:[2218]: DEBUG:recv data error!Oct 27 12:26:16 32f32c8c-8c75-4249-bbf2-afa068de9aaf server_debug:[2218]: DEBUG:uid is '00060110', port is '5500'.
It is abnormal. Unless the data is accepted, the data accepted each time is empty.
This thread finally died. After a while
Oct 27 12:26:22 32f32c8c-8c75-4249-bbf2-afa068de9aaf server_debug:[2218]: DEBUG:recv data error!Oct 27 12:26:22 32f32c8c-8c75-4249-bbf2-afa068de9aaf rsyslogd-2177: imuxsock begins to drop messages from pid 2218 due to rate-limitingOct 27 12:26:29 32f32c8c-8c75-4249-bbf2-afa068de9aaf rsyslogd-2177: imuxsock lost 3408 messages from pid 2218 due to rate-limitingOct 27 12:26:29 32f32c8c-8c75-4249-bbf2-afa068de9aaf server_debug:[2218]: DEBUG:recv data error!Oct 27 12:26:29 32f32c8c-8c75-4249-bbf2-afa068de9aaf server_debug:[2218]: DEBUG:uid is '00060001', port is '5501'.Oct 27 12:26:29 32f32c8c-8c75-4249-bbf2-afa068de9aaf server_debug:[2218]: DEBUG: EAGAIN!
The main thread does not receive any data, or the client does not send the data (the possibility is very small), and the thread has no printing.
Recvfrom problem record