Permalink
Browse files

Rollback to r371 to eliminate kqtest failure on Solaris

git-svn-id: svn://mark.heily.com/libkqueue/trunk@379 34a59efb-09c4-4dcf-b95f-994a32aba0d8
  • Loading branch information...
mheily
mheily committed Jan 15, 2011
1 parent cb863b5 commit 0045612635752c46691be35983beed932cd1817d
View
@@ -1,9 +1,6 @@
HEAD
------------------------------------------------------------------------
- * NOTE: r368 is the last version to work properly on Solaris.
- The HEAD fails the unit tests
-
* Add a counter that increments on each each kevent() call. When printing
debug information within kevent(), display the value of the counter.
This will be helpful when debugging a multithreaded program that may have
View
@@ -152,4 +152,4 @@ diff:
# Used for testing on a Solaris guest VM
#
solaris-test:
- make dist && scp -P 2222 libkqueue-1.0a.tar.gz localhost:/tmp && ssh -p 2222 localhost ". .profile ; cd /tmp ; rm -rf libkqueue-$(VERSION) ; gtar zxvf libkqueue-$(VERSION).tar.gz && cd libkqueue-$(VERSION) && ./configure && make && KQUEUE_DEBUG=yes make check"
+ make dist && scp -P 2222 libkqueue-1.0a.tar.gz localhost:/tmp && ssh -p 2222 localhost ". .profile ; cd /tmp ; rm -rf libkqueue-$(VERSION) ; gtar zxvf libkqueue-$(VERSION).tar.gz && cd libkqueue-$(VERSION) && ./configure && make && make check"
View
@@ -50,7 +50,7 @@ pre_configure_hook() {
post_configure_hook() {
finalize target "$target"
- kqueue="src/posix/kqueue.c"
+ kqueue=""
kevent="src/posix/kevent.c"
evfilt_signal="src/posix/signal.c"
evfilt_proc="src/$target/proc.c"
@@ -75,7 +75,7 @@ post_configure_hook() {
if [ $target = "solaris" ] ; then
cflags="$cflags -D__EXTENSIONS__"
- kqueue="$kqueue src/solaris/kqueue.c"
+ kqueue="src/solaris/kqueue.c"
kevent="src/solaris/kevent.c"
evfilt_timer="src/solaris/timer.c"
evfilt_user="src/solaris/user.c"
View
@@ -40,11 +40,6 @@
#define LIBKQUEUE 1
#endif
-#ifndef _WIN32
-#define __declspec(x) /* */
-#define dllexport 0
-#endif
-
struct timespec;
#define EVFILT_READ (-1)
@@ -175,10 +170,7 @@ struct kevent {
extern "C" {
#endif
-__declspec(dllexport)
int kqueue(void);
-
-__declspec(dllexport)
int kevent(int kq, const struct kevent *changelist, int nchanges,
struct kevent *eventlist, int nevents,
const struct timespec *timeout);
View
@@ -123,23 +123,17 @@ filter_unregister_all(struct kqueue *kq)
int
filter_socketpair(struct filter *filt)
{
+#ifndef _WIN32
int sockfd[2];
-#ifdef _WIN32
- if (_pipe(sockfd, 512, _O_BINARY) == -1) {
- dbg_puts("_pipe failed");
- return (-1);
- }
- /* FIXME: want nonblocking behavior for writer */
- filt->kf_wfd = sockfd[0];
- filt->kf_pfd = sockfd[1];
-#else
if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockfd) < 0)
return (-1);
fcntl(sockfd[0], F_SETFL, O_NONBLOCK);
filt->kf_wfd = sockfd[0];
filt->kf_pfd = sockfd[1];
+#else
+#warning FIXME function has no effect
#endif
return (0);
}
View
@@ -227,11 +227,10 @@ kevent_copyin(struct kqueue *kq, const struct kevent *src, int nchanges,
return (nret);
}
-VISIBLE_DECL(int,
+int VISIBLE
kevent(int kqfd, const struct kevent *changelist, int nchanges,
struct kevent *eventlist, int nevents,
const struct timespec *timeout)
-)
{
static unsigned int _kevent_counter = 0;
struct kqueue *kq;
View
@@ -156,7 +156,7 @@ knote_get_socket_type(struct knote *kn)
return (0);
break;
default:
- dbg_perror("getsockopt(3)");
+ dbg_printf("getsockopt(3) failed: %s", strerror(errno));
return (-1);
}
} else {
View
@@ -24,7 +24,10 @@
#include "private.h"
+#ifndef NDEBUG
int KQUEUE_DEBUG = 0;
+#endif
+
static RB_HEAD(kqt, kqueue) kqtree = RB_INITIALIZER(&kqtree);
static pthread_rwlock_t kqtree_mtx;
@@ -145,9 +148,14 @@ kqueue_get(int kq)
return (ent);
}
-VISIBLE_DECL(int, kqueue(void))
+int VISIBLE
+kqueue(void)
{
+#ifdef _WIN32
+ static int kqueue_id = 0;
+#endif
struct kqueue *kq;
+ int tmp;
kq = calloc(1, sizeof(*kq));
if (kq == NULL)
@@ -164,8 +172,21 @@ VISIBLE_DECL(int, kqueue(void))
KQUEUE_DEBUG = (getenv("KQUEUE_DEBUG") == NULL) ? 0 : 1;
#endif
+#ifdef _WIN32
+ pthread_rwlock_wrlock(&kqtree_mtx);
+ kqueue_id++;
+ pthread_rwlock_unlock(&kqtree_mtx);
+ kq->kq_sockfd[0] = kqueue_id;
+ kq->kq_sockfd[1] = kqueue_id;
+#else
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, kq->kq_sockfd) < 0)
+ goto errout_unlocked;
+#endif
+
+#ifdef kqueue_init_hook
if (kqueue_init_hook(kq) < 0)
goto errout_unlocked;
+#endif
pthread_rwlock_wrlock(&kqtree_mtx);
if (kqueue_gc() < 0)
@@ -183,7 +204,18 @@ VISIBLE_DECL(int, kqueue(void))
pthread_rwlock_unlock(&kqtree_mtx);
errout_unlocked:
- kqueue_free_hook(kq);
+ if (kq->kq_sockfd[0] != kq->kq_sockfd[1]) {
+ tmp = errno;
+#ifndef _WIN32
+ (void)close(kq->kq_sockfd[0]);
+ (void)close(kq->kq_sockfd[1]);
+#endif
+ errno = tmp;
+ }
+#if defined(__sun__)
+ if (kq->kq_port > 0)
+ close(kq->kq_port);
+#endif
free(kq);
return (-1);
}
View
@@ -43,9 +43,10 @@ struct evfilt_data;
/* Maximum events returnable in a single kevent() call */
#define MAX_KEVENT 512
+#ifndef NDEBUG
+
extern int KQUEUE_DEBUG;
-#ifndef NDEBUG
#define dbg_puts(str) do { \
if (KQUEUE_DEBUG) \
View
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2011 Mark Heily <mark@heily.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <errno.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <string.h>
-
-#include "private.h"
-
-int
-posix_kqueue_init(struct kqueue *kq)
-{
- if (socketpair(AF_UNIX, SOCK_STREAM, 0, kq->kq_sockfd) < 0) {
- dbg_perror("socketpair");
- kq->kq_sockfd[0] = -1;
- kq->kq_sockfd[1] = -1;
- return (-1);
- }
-
- return (0);
-}
-
-void
-posix_kqueue_free(struct kqueue *kq)
-{
- if (kq->kq_sockfd[0] != -1)
- (void) close(kq->kq_sockfd[0]);
- if (kq->kq_sockfd[1] != -1)
- (void) close(kq->kq_sockfd[1]);
-}
View
@@ -17,14 +17,7 @@
#ifndef _KQUEUE_POSIX_PLATFORM_H
#define _KQUEUE_POSIX_PLATFORM_H
-/*
- * Hooks and prototypes
- */
-#define kqueue_free_hook posix_kqueue_free
-void posix_kqueue_free(struct kqueue *);
-
-#define kqueue_init_hook posix_kqueue_init
-int posix_kqueue_init(struct kqueue *);
+#include "../../include/sys/event.h"
/*
* GCC-compatible atomic integer operations
@@ -33,7 +26,7 @@ int posix_kqueue_init(struct kqueue *);
#define atomic_dec(p) __sync_sub_and_fetch((p), 1)
#define CONSTRUCTOR int __attribute__ ((constructor))
-#define VISIBLE
+#define VISIBLE __attribute__((visibility("default")))
#define HIDDEN __attribute__((visibility("hidden")))
#include <signal.h>
@@ -44,9 +37,4 @@ int posix_kqueue_init(struct kqueue *);
#include <sys/socket.h>
#include <unistd.h>
-#define VISIBLE_DECL(t,x) t __attribute__((visibility("default"))) x
-
-#include "../../include/sys/event.h"
-
#endif /* ! _KQUEUE_POSIX_PLATFORM_H */
-
View
@@ -22,27 +22,20 @@
#include "sys/event.h"
#include "private.h"
-extern int posix_kqueue_init(struct kqueue *kq);
-extern void posix_kqueue_free(struct kqueue *kq);
-
void
solaris_kqueue_free(struct kqueue *kq)
{
- posix_kqueue_free(kq);
if (kq->kq_port > 0)
close(kq->kq_port);
}
int
solaris_kqueue_init(struct kqueue *kq)
{
- if (posix_kqueue_init(kq) < 0)
- return (-1);
if ((kq->kq_port = port_create()) < 0) {
dbg_perror("port_create(2)");
return (-1);
}
- dbg_printf("created event port: fd=%d", kq->kq_port);
TAILQ_INIT(&kq->kq_events);
return (0);
}
View
@@ -41,11 +41,9 @@
/*
* Hooks and prototypes
*/
-#undef kqueue_free_hook
#define kqueue_free_hook solaris_kqueue_free
void solaris_kqueue_free(struct kqueue *);
-#undef kqueue_init_hook
#define kqueue_init_hook solaris_kqueue_init
int solaris_kqueue_init(struct kqueue *);
Oops, something went wrong.

0 comments on commit 0045612

Please sign in to comment.