Commit Graph

665 Commits

Author SHA1 Message Date
mheily
5933ba024c Use tracing_mutex_t instead of pthread_mutex_t for knote and kqueue locks.
Fix a locking bug in Linux kevent_copyout().

Fix and enable the knote_lock() and knote_unlock() macros.

Implement tracing_mutex_destroy().



git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@494 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-29 03:59:59 +00:00
mheily
e138f4a4c9 Add tracing mutexes to debug.h.
/*
 * Tracing mutexes are a thin wrapper around the pthread_mutex_t 
 * datatype that tracks and reports when a mutex is locked or unlocked.
 * It also allows you to assert that a mutex has (or has not) been locked
 * by calling tracing_mutex_assert().
 */



git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@493 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-29 03:28:07 +00:00
marius
c4573236fa Some changes to the 'new' ref-count mechanism of knote - please elaborate
Fixed a race condition within windows timers using the ref count mechanism

git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@492 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-28 12:01:04 +00:00
mheily
fcc95e5a18 Re-enable the knote mutex and reference counter.
Improve the knote reference counting mechanism.

New function knote_delete().

Rename 'flags' to 'kn_flags' in struct knote.

Rename 'mtx' to 'kn_mtx' in struct knote.

Rename 'kntree_ent' to 'kn_entries' in struct knote.

Add a knote flag named 'KNFL_KNOTE_DELETED' to indicate that a knote has been deleted. With reference counting, this becomes necessary.



git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@491 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-27 03:30:31 +00:00
marius
731410fef0 EVFILT_USER implementation on windows
Change VS Solution structure to be more well-arranged

git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@490 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-26 20:12:28 +00:00
marius
3ea5de4571 Updated VS Solution and CMakeLists.txt to reflect latest changes
Added annotation to timer bug on windows
Fixed a wrong visibility in the static build of libkqueue

git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@489 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-26 19:26:38 +00:00
mheily
4f0126ebc8 Commit a missing file that was accidentally ommited.
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@488 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-25 23:21:07 +00:00
mheily
1b4e9d4af8 Partial implementation of EVFILT_READ on Windows.
Switch to using IOCP as the synchronization mechanism on Windows instead of emulating pthread condition variables.

git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@487 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-25 02:50:54 +00:00
mheily
04ca8661f7 Change the EVFILT_READ test to use TCP sockets instead of UNIX domain sockets,
so the tests can be run on Windows.

Fix a bug on Linux where epoll() will not return EPOLLHUP when a TCP socket
is closed. Instead, it will return POLLIN with zero bytes in the protocol
buffer.



git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@486 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-24 02:56:17 +00:00
mheily
9bbb71b801 Fix various build issues on MinGW.
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@485 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-23 18:27:10 +00:00
mheily
74b37975ae By default, kevent() will serialize the copyout() and copyin() functions so that only one thread can operate on a kevent structure. This is controlled by the SERIALIZE_KEVENT macro. This temporarily
restores the behavior from libkqueue 1.0 to give us time to implement
fine-grained locking properly.

New functions: kqueue_lock() and kqueue_unlock().


git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@484 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-18 01:41:26 +00:00
marius
86b1fbb760 EVTFILT_TIMER working on windows
Added binary files on windows to svn:ignore

git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@483 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-17 19:34:34 +00:00
marius
dc2761332f Added CMakeLists.txt for libkqueue and tests
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@482 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-16 08:57:12 +00:00
marius
c4a997e8d5 Add option for static library build activated by defining MAKE_STATIC
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@481 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-16 08:54:17 +00:00
mheily
89f858788f Testing SVN post-commit hook
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@480 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-14 01:12:48 +00:00
mheily
cee1de5c60 Test commit, trying a post-commit email notify hook
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@479 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-14 00:58:03 +00:00
mheily
252e29883a Test commit, trying a post-commit email notify hook
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@478 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-14 00:56:09 +00:00
mheily
d417316168 Document test failure on SunOS
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@477 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-14 00:53:06 +00:00
mheily
a00bd06d97 Use calloc() instead of malloc() to avoid the use of uninitialized memory.
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@476 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-14 00:42:11 +00:00
mheily
650452c28f Fix format string type mismatch
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@475 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-14 00:25:27 +00:00
mheily
09aa72ecd1 Provide missing atomic_ptr_cas definition on some platforms.
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@474 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-14 00:21:11 +00:00
marius
9abd0fc49c Made libkqueue compile on windows again - functionality still broken on this platform
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@473 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-13 17:35:34 +00:00
marius
0abf2a781a Fixed a bug within kevent_copyin_one() causing a knote mutex to be used after releasing the knote
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@472 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-13 17:24:19 +00:00
marius
3a1f03e6ae Added clean initialization and destruction to mutex used within a knote.
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@471 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-13 17:23:13 +00:00
marius
0fb0ab9c2b Test commit as marius@
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@470 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-13 01:14:30 +00:00
mheily
e045e4a70c Fix incorrect "nfds" argument supplied to pselect(2)
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@469 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-11 03:17:37 +00:00
mheily
0d4298cce9 Fix conditional that invokes linux_kevent_wait_hires()
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@468 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-09 02:55:07 +00:00
mheily
10ec7ad485 Add a test for high-resolution kevent() calls on Linux
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@467 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-09 01:24:59 +00:00
mheily
4e607edd42 Support regular files with EVFILT_READ, fixes the dispatch_read test in libdispatch
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@466 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-06 02:49:48 +00:00
mheily
844e70a5f2 Disable debugging if KQUEUE_DEBUG is an empty string
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@465 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-06 01:51:39 +00:00
mheily
855362d95f Split socket.c into two separate files: read.c and write.c. This means that EVFILT_READ and EVFILT_WRITE are now completely separate filters.
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@464 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-05 22:22:48 +00:00
mheily
2b21880288 Move knote_get_socket_type() into linux/socket.c.
Partial support for EVFILT_READ with regular files.



git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@463 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-04-05 21:17:21 +00:00
mheily
50bb5cb827 WORKAROUND: signalfd(2) flags are broken on kernels older than Linux 2.6.27
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@458 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-03-19 14:28:29 +00:00
mheily
c8762ecddb Fix another 32-bit compilation issue
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@457 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-03-19 14:11:59 +00:00
jocke
8ce2f93c30 Reverting to using port_getn, but checking nget even in case of error, as events might have been returned. See http://code.google.com/p/gdnsd/source/browse/branches/current/gdnsd/libgdnsd/libev/ev_port.c?spec=svn878&r=878 as well as related links for background...
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@456 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-03-15 09:30:39 +00:00
jocke
b1ddd1f071 Try using port_get rather than port_getn as we seem to sometime get lost wakeups for user events, there are a few problems reported for port_getn (http://bugs.opensolaris.org/view_bug.do?bug_id=6268715, http://mail.opensolaris.org/pipermail/networking-discuss/2009-August/011979.html, ...) - will use this for stress testing and see if it fixes the problem.
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@455 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-03-15 08:34:57 +00:00
mheily
543ba08bf2 Document a Linux bug
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@454 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-03-12 17:01:51 +00:00
mheily
6b6ead7801 Move all debugging macros to a single debug.h header to allow them to be reused in other projects
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@452 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-03-07 04:46:46 +00:00
mheily
311318db25 Fix a build failure on Linux
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@451 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-03-07 04:24:03 +00:00
jocke
1e3117304f Remove superfluous newline in debug
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@450 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-03-03 13:41:32 +00:00
jocke
1bda0408db Make sure that EV_RECEIPT events also calls kn_modify(), as we may get NOTE_TRIGGER updates there that needs to trigger e.g. timers.
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@449 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-03-03 07:05:01 +00:00
jocke
adb6951527 Temporarily disable alloc cache, as it is not threadsafe unless each thread has called mem_init(), which is hard to ensure. The problem is that a different thread may call knote_free() which never before called mem_init(), and then we make libdispatch crash in its internals... Will try to stabilize all libdispatch tests before trying to reenable this...
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@448 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-03-02 16:31:21 +00:00
jocke
2f1fc4353d Additional debug for port_associate.
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@447 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-03-02 13:22:39 +00:00
jocke
6f1f8d9c78 Use same formatting for dbg_perror as for the other dbg_xxx functions.
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@446 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-03-02 13:20:59 +00:00
jocke
46a437e3d7 Properly return number of available from fd on Solaris in evfilt_socket_copyout.
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@445 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-03-02 10:37:08 +00:00
jocke
0b50f2ac45 Added xcode project for convenience for edit/navigation/etc
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@444 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-03-02 08:47:07 +00:00
jocke
96365c3031 Make sure we don't 'return' non-initialized events when running with KQUEUE_DEBUG by initializing rv properly (it would generate incorrect debug logs if nevents == 0), tuning debug output slightly.
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@443 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-02-28 14:45:20 +00:00
jocke
e558ed245c Properly return number of times a timer have been triggered
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@442 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-02-28 09:26:14 +00:00
jocke
d058d2be8a Only map in memory enough to keep the possible set of file descriptors (rlim_max for RLIMIT_NOFILE) rather than MAX_INT, drastically decreases the needed amount of VM backing availble (allowing it to run on also swap-impaired machines). This should be correct, as the kq_id refers to an fd and we can't have more fd:s than this.
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@441 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-02-23 17:11:47 +00:00
jocke
2070c271dd Honor CC environment variable as the first pick in the compiler list, temporarily commented out the test for it being executable as it doesn't work properly when CC is set due to how finalize() checks for being empty
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@440 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
2011-02-23 16:48:57 +00:00