-
Notifications
You must be signed in to change notification settings - Fork 0
/
on_socketclose.rs
49 lines (43 loc) · 1.81 KB
/
on_socketclose.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//function on_socketclose
fn on_socketclose(mut data: *mut libc::c_void) {
let mut ctx: *mut h2o_context_t = data as *mut h2o_context_t;
let mut conf: *mut config_t =
((*ctx).globalconf as *mut libc::c_char).offset(-0) as *mut config_t;
let mut prev_num_connections: libc::c_uint =
::std::intrinsics::atomic_xsub(&mut (*conf).state.num_connections,
1i32 as libc::c_uint);
if (*conf).num_threads != 1i32 as libc::c_uint {
if prev_num_connections == (*conf).max_connections {
/* ready to accept new connections. wake up the threads! */
let mut self_tid: pthread_t = pthread_self();
let mut i: libc::c_uint = 0;
i = 0i32 as libc::c_uint;
while i != (*conf).num_threads {
if *(*conf).thread_ids.offset(i as isize) != self_tid {
pthread_kill(*(*conf).thread_ids.offset(i as isize),
18i32);
}
i = i.wrapping_add(1)
}
}
};
}
/*
static void on_socketclose(void *data)
{
h2o_context_t *ctx = data;
struct config_t *conf = H2O_STRUCT_FROM_MEMBER(struct config_t, globalconf, ctx->globalconf);
unsigned prev_num_connections = __sync_fetch_and_sub(&conf->state.num_connections, 1);
if (conf->num_threads != 1) {
if (prev_num_connections == conf->max_connections) {
/* ready to accept new connections. wake up the threads! */
pthread_t self_tid = pthread_self();
unsigned i;
for (i = 0; i != conf->num_threads; ++i) {
if (conf->thread_ids[i] != self_tid)
pthread_kill(conf->thread_ids[i], SIGCONT);
}
}
}
}
*/