Make syslogd work, even if it can only open klog and not udp or vice versa
(but not neither)
This commit is contained in:
parent
f219efb41e
commit
753e119f18
@ -67,6 +67,10 @@
|
|||||||
** Extensive rewriting by G. Falzoni <gfalzoni@inwind.it> for porting to Minix
|
** Extensive rewriting by G. Falzoni <gfalzoni@inwind.it> for porting to Minix
|
||||||
**
|
**
|
||||||
** $Log$
|
** $Log$
|
||||||
|
** Revision 1.2 2006/04/04 14:18:16 beng
|
||||||
|
** Make syslogd work, even if it can only open klog and not udp or vice versa
|
||||||
|
** (but not neither)
|
||||||
|
**
|
||||||
** Revision 1.1 2006/04/03 13:07:42 beng
|
** Revision 1.1 2006/04/03 13:07:42 beng
|
||||||
** Kick out usyslogd in favour of syslogd Giovanni's syslogd port
|
** Kick out usyslogd in favour of syslogd Giovanni's syslogd port
|
||||||
**
|
**
|
||||||
@ -834,10 +838,7 @@ int main(int argc, char **argv)
|
|||||||
alarm(TIMERINTVL);
|
alarm(TIMERINTVL);
|
||||||
|
|
||||||
/* Open UDP device */
|
/* Open UDP device */
|
||||||
if ((nfd = open(udpdev, O_NONBLOCK | O_RDONLY)) < 0) {
|
nfd = open(udpdev, O_NONBLOCK | O_RDONLY);
|
||||||
logerror("UDP device not open");
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Configures the UDP device */
|
/* Configures the UDP device */
|
||||||
udpopt.nwuo_flags = NWUO_SHARED | NWUO_LP_SET | NWUO_EN_LOC |
|
udpopt.nwuo_flags = NWUO_SHARED | NWUO_LP_SET | NWUO_EN_LOC |
|
||||||
@ -847,7 +848,7 @@ int main(int argc, char **argv)
|
|||||||
port == 0 ? sp->s_port : htons(port);
|
port == 0 ? sp->s_port : htons(port);
|
||||||
udpopt.nwuo_remaddr = udpopt.nwuo_locaddr = htonl(0x7F000001L);
|
udpopt.nwuo_remaddr = udpopt.nwuo_locaddr = htonl(0x7F000001L);
|
||||||
|
|
||||||
while (ioctl(nfd, NWIOSUDPOPT, &udpopt) < 0 ||
|
while (nfd >= 0 && ioctl(nfd, NWIOSUDPOPT, &udpopt) < 0 ||
|
||||||
ioctl(nfd, NWIOGUDPOPT, &udpopt) < 0) {
|
ioctl(nfd, NWIOGUDPOPT, &udpopt) < 0) {
|
||||||
if (errno == EAGAIN) {
|
if (errno == EAGAIN) {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
@ -858,8 +859,10 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Open kernel log device */
|
/* Open kernel log device */
|
||||||
if ((kfd = open("/dev/klog", O_NONBLOCK | O_RDONLY)) < 0) {
|
kfd = open("/dev/klog", O_NONBLOCK | O_RDONLY);
|
||||||
logerror("Open /dev/klog failed");
|
|
||||||
|
if(kfd < 0 && nfd < 0) {
|
||||||
|
logerror("open /dev/klog and udp device failed - can't log anything");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -872,15 +875,15 @@ int main(int argc, char **argv)
|
|||||||
for (;;) { /* Main loop */
|
for (;;) { /* Main loop */
|
||||||
|
|
||||||
FD_ZERO(&fdset); /* Setup descriptors for select */
|
FD_ZERO(&fdset); /* Setup descriptors for select */
|
||||||
FD_SET(nfd, &fdset);
|
if(nfd >= 0) FD_SET(nfd, &fdset);
|
||||||
FD_SET(kfd, &fdset);
|
if(kfd >= 0) FD_SET(kfd, &fdset);
|
||||||
|
|
||||||
if (select(fdmax, &fdset, NULL, NULL, NULL) <= 0) {
|
if (select(fdmax, &fdset, NULL, NULL, NULL) <= 0) {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (FD_ISSET(nfd, &fdset)) {
|
if (nfd >= 0 && FD_ISSET(nfd, &fdset)) {
|
||||||
|
|
||||||
/* Read a message from application programs */
|
/* Read a message from application programs */
|
||||||
len = read(nfd, line, MAXLINE);
|
len = read(nfd, line, MAXLINE);
|
||||||
@ -899,7 +902,7 @@ int main(int argc, char **argv)
|
|||||||
die(-1);
|
die(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (FD_ISSET(kfd, &fdset)) {
|
if (kfd >= 0 && FD_ISSET(kfd, &fdset)) {
|
||||||
static char linebuf[5*1024];
|
static char linebuf[5*1024];
|
||||||
|
|
||||||
/* Read a message from kernel (klog) */
|
/* Read a message from kernel (klog) */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user