# This is a BitKeeper generated patch for the following project: # Project Name: DNS Relay 2.10 # This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas: # ChangeSet 1.2 -> 1.3 # src/cache.c 1.1 -> 1.2 # src/common.c 1.1 -> 1.2 # src/common.h 1.1 -> 1.2 # src/main.c 1.1 -> 1.2 # src/master.c 1.1 -> 1.2 # src/query.c 1.1 -> 1.2 # src/relay.c 1.1 -> 1.2 # src/tcp.c 1.1 -> 1.2 # # The following is the BitKeeper ChangeSet Log # -------------------------------------------- # 02/02/19 divert@adonix.(none) 1.3 # Changed so it compiles on NetBSD 1.5, this involved the following: # Changed the LinuxThread semaphore calls out for standard SYS V semaphores # Added some type casts on vsyslog calls # Moved some #include statements around # -------------------------------------------- # diff -Nru a/src/cache.c b/src/cache.c --- a/src/cache.c Tue Feb 19 21:04:48 2002 +++ b/src/cache.c Tue Feb 19 21:04:48 2002 @@ -198,7 +198,8 @@ * Ok, the packet is interesting for us. Let's put it into our * cache list. */ - sem_wait(&dnrd_sem); + semop(dnrd_sem, &sem_wait_op, 1); + /* sem_wait(&dnrd_sem); */ cx = create_cx(x, &query); append_cx(cx); @@ -208,7 +209,8 @@ cx->lastused = time(NULL); cx->expires = cx->lastused + ((cx->p->ancount > 0) ? CACHE_TIME : CACHE_NEGTIME); - sem_post(&dnrd_sem); + semop(dnrd_sem,&sem_post_op,1); + /* sem_post(&dnrd_sem); */ return (0); } diff -Nru a/src/common.c b/src/common.c --- a/src/common.c Tue Feb 19 21:04:48 2002 +++ b/src/common.c Tue Feb 19 21:04:48 2002 @@ -20,7 +20,6 @@ #include "common.h" #include -#include #include #include #include @@ -57,7 +56,11 @@ gid_t daemongid = 0; const char* version = "2.10"; int gotterminal = 1; /* 1 if attached to a terminal */ -sem_t dnrd_sem; /* Used for all thread synchronization */ +int dnrd_sem; /* Used for al lthread synchronization */ +struct sembuf sem_wait_op = {0, -1, 0}; +struct sembuf sem_post_op = {0, 1, 0}; + +/* sem_t dnrd_sem; Used for all thread synchronization */ /* * This is the address we listen on. It gets initialized to INADDR_ANY, @@ -66,6 +69,8 @@ */ #if defined(__sun__) struct sockaddr_in recv_addr = { AF_INET, 53, { { {0, 0, 0, 0} } } }; +#elif defined(__bsd__) +struct sockaddr_in recv_addr = { 16, AF_INET, 53, { INADDR_ANY } }; #else struct sockaddr_in recv_addr = { AF_INET, 53, { INADDR_ANY } }; #endif @@ -136,7 +141,7 @@ if (fmt[strlen(fmt) - 1] != '\n') fprintf(stderr, "\n"); } else { - vsyslog(type, fmt, ap); + vsyslog(type, (char*)fmt, ap); } va_end(ap); } @@ -163,7 +168,7 @@ if (fmt[strlen(fmt) - 1] != '\n') fprintf(stderr, "\n"); } else { - vsyslog(LOG_DEBUG, fmt, ap); + vsyslog(LOG_DEBUG, (char*)fmt, ap); } va_end(ap); } @@ -181,7 +186,8 @@ int i; /* Only let one process run this code) */ - sem_wait(&dnrd_sem); + semop(dnrd_sem,&sem_wait_op,1); + /* sem_wait(&dnrd_sem); */ log_debug("Shutting down...\n"); if (isock >= 0) close(isock); diff -Nru a/src/common.h b/src/common.h --- a/src/common.h Tue Feb 19 21:04:48 2002 +++ b/src/common.h Tue Feb 19 21:04:48 2002 @@ -23,9 +23,18 @@ #ifndef _DNRD_COMMON_H_ #define _DNRD_COMMON_H_ +#include +#include +#include +#include #include #include -#include +#include +/* + * removal of nonportable LinuxThreads + * + * #include + */ #define MAX_SERV 5 /* maximum number of DNS servers */ @@ -50,7 +59,20 @@ extern gid_t daemongid; /* to switch to once daemonised */ extern int gotterminal; extern char master_param[200]; -extern sem_t dnrd_sem; /* Used for all thread synchronization */ + +/* + * removal of non portable LinuxThreads + */ + +/* extern sem_t dnrd_sem; Used for all thread synchronization */ + +extern int dnrd_sem; /* Used for all thread sychronization */ + +#define SEMKEY1 ((key_t) 400L) +#define NSEMS 1 + +extern struct sembuf sem_wait_op; +extern struct sembuf sem_post_op; /* kill any currently running copies of dnrd */ int kill_current(); diff -Nru a/src/main.c b/src/main.c --- a/src/main.c Tue Feb 19 21:04:48 2002 +++ b/src/main.c Tue Feb 19 21:04:48 2002 @@ -18,9 +18,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "relay.h" -#include "cache.h" -#include "common.h" #include "args.h" #include "sig.h" #include "master.h" @@ -30,15 +27,18 @@ #include #include #include +#include #include #include #include -#include #include #include #include #include #include +#include "relay.h" +#include "cache.h" +#include "common.h" /* * main() - startup the program. @@ -84,7 +84,7 @@ */ parse_args(argc, argv); - openlog(progname, LOG_PID, LOG_DAEMON); + openlog((char*)progname, LOG_PID, LOG_DAEMON); /* * Kill any currently running copies of the program. @@ -94,7 +94,9 @@ /* * Setup the thread synchronization semaphore */ - if (sem_init(&dnrd_sem, 0, 1) == -1) { + +/* if (sem_init(&dnrd_sem, 0, 1) == -1) { */ + if ( (dnrd_sem = semget(SEMKEY1,NSEMS,IPC_CREAT | 0666)) < 0 ) { log_msg(LOG_ERR, "Couldn't initialize semaphore"); cleanexit(-1); } diff -Nru a/src/master.c b/src/master.c --- a/src/master.c Tue Feb 19 21:04:48 2002 +++ b/src/master.c Tue Feb 19 21:04:48 2002 @@ -194,7 +194,8 @@ log_msg(LOG_NOTICE, "resetting master DNS"); - sem_wait(&dnrd_sem); + semop(dnrd_sem,&sem_wait_op,1); + /* sem_wait(&dnrd_sem); */ for (i = 0; i < dbc; i++) { free_dnsrec(dbv[i]); @@ -209,7 +210,8 @@ dbc = 0; dbmax = 0; - sem_post(&dnrd_sem); + semop(dnrd_sem, &sem_post_op, 1); + /* sem_post(&dnrd_sem); */ return (0); } diff -Nru a/src/query.c b/src/query.c --- a/src/query.c Tue Feb 19 21:04:48 2002 +++ b/src/query.c Tue Feb 19 21:04:48 2002 @@ -23,7 +23,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "query.h" #include "common.h" #include #include @@ -34,6 +33,7 @@ #include #include #endif /* DEBUG */ +#include "query.h" /* * This is the data structure used to store DNS queries that haven't been diff -Nru a/src/relay.c b/src/relay.c --- a/src/relay.c Tue Feb 19 21:04:48 2002 +++ b/src/relay.c Tue Feb 19 21:04:48 2002 @@ -18,22 +18,22 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "query.h" -#include "relay.h" -#include "cache.h" #include "common.h" -#include "tcp.h" -#include "udp.h" -#include "master.h" #include #include #include #include #include -#include #include -#include +#include +#include #include +#include "query.h" +#include "relay.h" +#include "cache.h" +#include "tcp.h" +#include "udp.h" +#include "master.h" static time_t send_time = 0; static int send_count = 0; diff -Nru a/src/tcp.c b/src/tcp.c --- a/src/tcp.c Tue Feb 19 21:04:48 2002 +++ b/src/tcp.c Tue Feb 19 21:04:48 2002 @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include