[Asterisk-cvs] asterisk acl.c,1.8,1.9
markster at lists.digium.com
markster at lists.digium.com
Tue Oct 21 22:47:24 CDT 2003
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv4193
Modified Files:
acl.c
Log Message:
Route fixes for OpenBSD (bug #415)
Index: acl.c
===================================================================
RCS file: /usr/cvsroot/asterisk/acl.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- acl.c 22 Oct 2003 03:10:34 -0000 1.8
+++ acl.c 22 Oct 2003 04:13:25 -0000 1.9
@@ -30,6 +30,7 @@
#include <netinet/ip.h>
#include <sys/ioctl.h>
#ifdef __OpenBSD__
+#include <fcntl.h>
#include <net/route.h>
static ast_mutex_t routeseq_lock = AST_MUTEX_INITIALIZER;
@@ -172,7 +173,7 @@
char m_space[512];
} m_rtmsg;
char *cp, *p = ast_strdupa(inet_ntoa(*them));
- int i, l, s, seq;
+ int i, l, s, seq, flags;
pid_t pid = getpid();
static int routeseq; /* Protected by "routeseq_lock" mutex */
@@ -197,6 +198,8 @@
ast_log(LOG_ERROR, "Error opening routing socket\n");
return -1;
}
+ flags = fcntl(s, F_GETFL);
+ fcntl(s, F_SETFL, flags | O_NONBLOCK);
if (write(s, (char *)&m_rtmsg, m_rtmsg.m_rtm.rtm_msglen) < 0) {
ast_log(LOG_ERROR, "Error writing to routing socket: %s\n", strerror(errno));
close(s);
@@ -205,11 +208,13 @@
do {
l = read(s, (char *)&m_rtmsg, sizeof(m_rtmsg));
} while (l > 0 && (m_rtmsg.m_rtm.rtm_seq != 1 || m_rtmsg.m_rtm.rtm_pid != pid));
- close(s);
if (l < 0) {
- ast_log(LOG_ERROR, "Error reading from routing socket\n");
+ if (errno != EAGAIN)
+ ast_log(LOG_ERROR, "Error reading from routing socket\n");
+ close(s);
return -1;
}
+ close(s);
if (m_rtmsg.m_rtm.rtm_version != RTM_VERSION) {
ast_log(LOG_ERROR, "Unsupported route socket protocol version\n");
More information about the svn-commits
mailing list