diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-03-19 18:29:15 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-03-19 18:32:52 -0700 |
commit | 0ef079617b7d71cc26574247918c4a3e18454b21 (patch) | |
tree | 0cc2af91bf34336e608ca60ff391a8180ea24278 | |
parent | f8b8b3f73d238d4c29368b4a0f768c5afb03d43d (diff) | |
download | kgio-0ef079617b7d71cc26574247918c4a3e18454b21.tar.gz |
Don't force people to rely on global flags, there may be blocking parts of an otherwise non-blocking program...
-rw-r--r-- | ext/kgio/accept.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ext/kgio/accept.c b/ext/kgio/accept.c index 2026a78..b8efba5 100644 --- a/ext/kgio/accept.c +++ b/ext/kgio/accept.c @@ -16,6 +16,7 @@ static int accept4_flags = SOCK_CLOEXEC | SOCK_NONBLOCK; struct accept_args { int fd; + int flags; struct sockaddr *addr; socklen_t *addrlen; }; @@ -58,10 +59,10 @@ static VALUE xaccept(void *ptr) struct accept_args *a = ptr; int rv; - rv = accept_fn(a->fd, a->addr, a->addrlen, accept4_flags); + rv = accept_fn(a->fd, a->addr, a->addrlen, a->flags); if (rv == -1 && errno == ENOSYS && accept_fn != my_accept4) { accept_fn = my_accept4; - rv = accept_fn(a->fd, a->addr, a->addrlen, accept4_flags); + rv = accept_fn(a->fd, a->addr, a->addrlen, a->flags); } return (VALUE)rv; @@ -151,6 +152,7 @@ my_accept(VALUE accept_io, VALUE klass, a.fd = my_fileno(accept_io); a.addr = addr; a.addrlen = addrlen; + a.flags = accept4_flags; retry: client = thread_accept(&a, nonblock); if (client == -1) { |