Skip to content

Commit

Permalink
fixes wavy::kernel kqueue
Browse files Browse the repository at this point in the history
  • Loading branch information
frsyuki committed Apr 10, 2010
1 parent 23edcb7 commit e79eff0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions mpsrc/wavy_kernel_kqueue.h
Expand Up @@ -75,18 +75,18 @@ class kernel {
int alloc_xident()
{
for(unsigned int i=0; i < MP_WAVY_KERNEL_KQUEUE_XIDENT_MAX*2; ++i) {
unsigned int ident = __sync_fetch_and_add(&m_xident_index, 1) % MP_WAVY_KERNEL_KQUEUE_XIDENT_MAX;
if(__sync_bool_compare_and_swap(&m_xident[ident], false, true)) {
return ident;
unsigned int x = __sync_fetch_and_add(&m_xident_index, 1) % MP_WAVY_KERNEL_KQUEUE_XIDENT_MAX;
if(__sync_bool_compare_and_swap(&m_xident[x], false, true)) {
return m_fdmax + x;
}
}
errno = EMFILE;
return -1;
}

bool free_xident(int ident)
bool free_xident(int xident)
{
bool* xv = m_xident + ident;
bool* xv = m_xident + (xident - m_fdmax);
// FIXME cas?
if(*xv) {
*xv = false;
Expand Down
3 changes: 1 addition & 2 deletions mpsrc/wavy_loop.cc
Expand Up @@ -242,14 +242,12 @@ void loop_impl::thread_main()
int ident = ke.ident();

if(ident == m_out->ident()) {

m_out->poll_event();
lk.unlock();

m_kernel.reactivate(ke);

} else {

lk.unlock();

event_impl e(this, ke);
Expand Down Expand Up @@ -315,6 +313,7 @@ void loop_impl::run_once()
lk.unlock();

int num = m_kernel.wait(&m_backlog, 1000);

if(num <= 0) {
if(num == 0 || errno == EINTR || errno == EAGAIN) {
m_pollable = true;
Expand Down
3 changes: 2 additions & 1 deletion mpsrc/wavy_timer.cc
Expand Up @@ -35,7 +35,8 @@ int loop::add_timer(const timespec* value, const timespec* interval,

static inline struct timespec sec2spec(double sec)
{
struct timespec spec = { (time_t)sec, (long)(sec * 1e9) };
struct timespec spec = {
sec, ((sec - (double)(time_t)sec) * 1e9) };
return spec;
}

Expand Down

0 comments on commit e79eff0

Please sign in to comment.