summaryrefslogtreecommitdiff
path: root/ext/socket
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2023-10-19 14:14:31 +0900
committerYusuke Endoh <mame@ruby-lang.org>2023-10-24 12:22:53 +0900
commitc08020254ef841c9ca233445e6cd1d0cf49e2756 (patch)
treef99c4fe0c08db9b8a5f316b9b07f254346a0277a /ext/socket
parentacd774263c17889d81e940ca7d1c935c9109c7b7 (diff)
Indent critical regions with blocks
Cosmetic change per ko1's preference
Diffstat (limited to 'ext/socket')
-rw-r--r--ext/socket/raddrinfo.c52
1 files changed, 29 insertions, 23 deletions
diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c
index 74f2f19fab..8e52251980 100644
--- a/ext/socket/raddrinfo.c
+++ b/ext/socket/raddrinfo.c
@@ -418,15 +418,17 @@ do_getaddrinfo(void *ptr)
int need_free = 0;
rb_nativethread_lock_lock(&arg->lock);
- arg->err = err;
- if (arg->cancelled) {
- freeaddrinfo(arg->ai);
- }
- else {
- arg->done = 1;
- rb_native_cond_signal(&arg->cond);
+ {
+ arg->err = err;
+ if (arg->cancelled) {
+ freeaddrinfo(arg->ai);
+ }
+ else {
+ arg->done = 1;
+ rb_native_cond_signal(&arg->cond);
+ }
+ if (--arg->refcount == 0) need_free = 1;
}
- if (--arg->refcount == 0) need_free = 1;
rb_nativethread_lock_unlock(&arg->lock);
if (need_free) free_getaddrinfo_arg(arg);
@@ -451,8 +453,10 @@ cancel_getaddrinfo(void *ptr)
{
struct getaddrinfo_arg *arg = (struct getaddrinfo_arg *)ptr;
rb_nativethread_lock_lock(&arg->lock);
- arg->cancelled = 1;
- rb_native_cond_signal(&arg->cond);
+ {
+ arg->cancelled = 1;
+ rb_native_cond_signal(&arg->cond);
+ }
rb_nativethread_lock_unlock(&arg->lock);
}
@@ -489,20 +493,22 @@ start:
int need_free = 0;
rb_nativethread_lock_lock(&arg->lock);
- if (arg->done) {
- err = arg->err;
- if (err == 0) *ai = arg->ai;
- }
- else if (arg->cancelled) {
- err = EAGAIN;
- }
- else {
- // If already interrupted, rb_thread_call_without_gvl2 may return without calling wait_getaddrinfo.
- // In this case, it could be !arg->done && !arg->cancelled.
- arg->cancelled = 1; // to make do_getaddrinfo call freeaddrinfo
- retry = 1;
+ {
+ if (arg->done) {
+ err = arg->err;
+ if (err == 0) *ai = arg->ai;
+ }
+ else if (arg->cancelled) {
+ err = EAGAIN;
+ }
+ else {
+ // If already interrupted, rb_thread_call_without_gvl2 may return without calling wait_getaddrinfo.
+ // In this case, it could be !arg->done && !arg->cancelled.
+ arg->cancelled = 1; // to make do_getaddrinfo call freeaddrinfo
+ retry = 1;
+ }
+ if (--arg->refcount == 0) need_free = 1;
}
- if (--arg->refcount == 0) need_free = 1;
rb_nativethread_lock_unlock(&arg->lock);
if (need_free) free_getaddrinfo_arg(arg);