mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
Have all visible internal function names end with an underscore.
We haven't had a convention for naming internal functions in -internal.h versus naming visible functions in include/**.h. This patch changes every function declared in a -internal.h file to be named ending with an underscore. Static function names are unaffected, since there's no risk of calling them from outside Libevent. This is an automatic conversion. The script that produced was made by running the following script over the output of ctags --c-kinds=pf -o - *-internal.h | cut -f 1 | sort| uniq (GNU ctags was required.) ===== #!/usr/bin/perl -w -n use strict; BEGIN { print "#!/usr/bin/perl -w -i -p\n\n"; } chomp; my $ident = $_; next if ($ident =~ /_$/); next if ($ident =~ /^TAILQ/); my $better = "${ident}_"; print "s/(?<![A-Za-z0-9_])$ident(?![A-Za-z0-9_])/$better/g;\n"; === And then running the script below that it generated over all === the .c and .h files again #!/usr/bin/perl -w -i -p s/(?<![A-Za-z0-9_])bufferevent_async_can_connect(?![A-Za-z0-9_])/bufferevent_async_can_connect_/g; s/(?<![A-Za-z0-9_])bufferevent_async_connect(?![A-Za-z0-9_])/bufferevent_async_connect_/g; s/(?<![A-Za-z0-9_])bufferevent_async_new(?![A-Za-z0-9_])/bufferevent_async_new_/g; s/(?<![A-Za-z0-9_])bufferevent_async_set_connected(?![A-Za-z0-9_])/bufferevent_async_set_connected_/g; s/(?<![A-Za-z0-9_])bufferevent_decref(?![A-Za-z0-9_])/bufferevent_decref_/g; s/(?<![A-Za-z0-9_])bufferevent_disable_hard(?![A-Za-z0-9_])/bufferevent_disable_hard_/g; s/(?<![A-Za-z0-9_])bufferevent_enable_locking(?![A-Za-z0-9_])/bufferevent_enable_locking_/g; s/(?<![A-Za-z0-9_])bufferevent_incref(?![A-Za-z0-9_])/bufferevent_incref_/g; s/(?<![A-Za-z0-9_])bufferevent_init_common(?![A-Za-z0-9_])/bufferevent_init_common_/g; s/(?<![A-Za-z0-9_])bufferevent_remove_from_rate_limit_group_internal(?![A-Za-z0-9_])/bufferevent_remove_from_rate_limit_group_internal_/g; s/(?<![A-Za-z0-9_])bufferevent_suspend_read(?![A-Za-z0-9_])/bufferevent_suspend_read_/g; s/(?<![A-Za-z0-9_])bufferevent_suspend_write(?![A-Za-z0-9_])/bufferevent_suspend_write_/g; s/(?<![A-Za-z0-9_])bufferevent_unsuspend_read(?![A-Za-z0-9_])/bufferevent_unsuspend_read_/g; s/(?<![A-Za-z0-9_])bufferevent_unsuspend_write(?![A-Za-z0-9_])/bufferevent_unsuspend_write_/g; s/(?<![A-Za-z0-9_])evbuffer_commit_read(?![A-Za-z0-9_])/evbuffer_commit_read_/g; s/(?<![A-Za-z0-9_])evbuffer_commit_write(?![A-Za-z0-9_])/evbuffer_commit_write_/g; s/(?<![A-Za-z0-9_])evbuffer_invoke_callbacks(?![A-Za-z0-9_])/evbuffer_invoke_callbacks_/g; s/(?<![A-Za-z0-9_])evbuffer_launch_read(?![A-Za-z0-9_])/evbuffer_launch_read_/g; s/(?<![A-Za-z0-9_])evbuffer_launch_write(?![A-Za-z0-9_])/evbuffer_launch_write_/g; s/(?<![A-Za-z0-9_])evbuffer_overlapped_new(?![A-Za-z0-9_])/evbuffer_overlapped_new_/g; s/(?<![A-Za-z0-9_])evbuffer_set_parent(?![A-Za-z0-9_])/evbuffer_set_parent_/g; s/(?<![A-Za-z0-9_])event_active_nolock(?![A-Za-z0-9_])/event_active_nolock_/g; s/(?<![A-Za-z0-9_])event_base_add_virtual(?![A-Za-z0-9_])/event_base_add_virtual_/g; s/(?<![A-Za-z0-9_])event_base_assert_ok(?![A-Za-z0-9_])/event_base_assert_ok_/g; s/(?<![A-Za-z0-9_])event_base_del_virtual(?![A-Za-z0-9_])/event_base_del_virtual_/g; s/(?<![A-Za-z0-9_])event_base_get_deferred_cb_queue(?![A-Za-z0-9_])/event_base_get_deferred_cb_queue_/g; s/(?<![A-Za-z0-9_])event_base_get_iocp(?![A-Za-z0-9_])/event_base_get_iocp_/g; s/(?<![A-Za-z0-9_])event_base_start_iocp(?![A-Za-z0-9_])/event_base_start_iocp_/g; s/(?<![A-Za-z0-9_])event_base_stop_iocp(?![A-Za-z0-9_])/event_base_stop_iocp_/g; s/(?<![A-Za-z0-9_])event_changelist_add(?![A-Za-z0-9_])/event_changelist_add_/g; s/(?<![A-Za-z0-9_])event_changelist_del(?![A-Za-z0-9_])/event_changelist_del_/g; s/(?<![A-Za-z0-9_])event_changelist_freemem(?![A-Za-z0-9_])/event_changelist_freemem_/g; s/(?<![A-Za-z0-9_])event_changelist_init(?![A-Za-z0-9_])/event_changelist_init_/g; s/(?<![A-Za-z0-9_])event_changelist_remove_all(?![A-Za-z0-9_])/event_changelist_remove_all_/g; s/(?<![A-Za-z0-9_])event_deferred_cb_cancel(?![A-Za-z0-9_])/event_deferred_cb_cancel_/g; s/(?<![A-Za-z0-9_])event_deferred_cb_init(?![A-Za-z0-9_])/event_deferred_cb_init_/g; s/(?<![A-Za-z0-9_])event_deferred_cb_queue_init(?![A-Za-z0-9_])/event_deferred_cb_queue_init_/g; s/(?<![A-Za-z0-9_])event_deferred_cb_schedule(?![A-Za-z0-9_])/event_deferred_cb_schedule_/g; s/(?<![A-Za-z0-9_])event_get_win32_extension_fns(?![A-Za-z0-9_])/event_get_win32_extension_fns_/g; s/(?<![A-Za-z0-9_])event_iocp_activate_overlapped(?![A-Za-z0-9_])/event_iocp_activate_overlapped_/g; s/(?<![A-Za-z0-9_])event_iocp_port_associate(?![A-Za-z0-9_])/event_iocp_port_associate_/g; s/(?<![A-Za-z0-9_])event_iocp_port_launch(?![A-Za-z0-9_])/event_iocp_port_launch_/g; s/(?<![A-Za-z0-9_])event_iocp_shutdown(?![A-Za-z0-9_])/event_iocp_shutdown_/g; s/(?<![A-Za-z0-9_])event_overlapped_init(?![A-Za-z0-9_])/event_overlapped_init_/g; s/(?<![A-Za-z0-9_])evhttp_connection_connect(?![A-Za-z0-9_])/evhttp_connection_connect_/g; s/(?<![A-Za-z0-9_])evhttp_connection_fail(?![A-Za-z0-9_])/evhttp_connection_fail_/g; s/(?<![A-Za-z0-9_])evhttp_connection_reset(?![A-Za-z0-9_])/evhttp_connection_reset_/g; s/(?<![A-Za-z0-9_])evhttp_parse_firstline(?![A-Za-z0-9_])/evhttp_parse_firstline_/g; s/(?<![A-Za-z0-9_])evhttp_parse_headers(?![A-Za-z0-9_])/evhttp_parse_headers_/g; s/(?<![A-Za-z0-9_])evhttp_response_code(?![A-Za-z0-9_])/evhttp_response_code_/g; s/(?<![A-Za-z0-9_])evhttp_send_page(?![A-Za-z0-9_])/evhttp_send_page_/g; s/(?<![A-Za-z0-9_])evhttp_start_read(?![A-Za-z0-9_])/evhttp_start_read_/g; s/(?<![A-Za-z0-9_])EVLOCK_TRY_LOCK(?![A-Za-z0-9_])/EVLOCK_TRY_LOCK_/g; s/(?<![A-Za-z0-9_])evmap_check_integrity(?![A-Za-z0-9_])/evmap_check_integrity_/g; s/(?<![A-Za-z0-9_])evmap_delete_all(?![A-Za-z0-9_])/evmap_delete_all_/g; s/(?<![A-Za-z0-9_])evmap_foreach_event(?![A-Za-z0-9_])/evmap_foreach_event_/g; s/(?<![A-Za-z0-9_])evmap_io_active(?![A-Za-z0-9_])/evmap_io_active_/g; s/(?<![A-Za-z0-9_])evmap_io_add(?![A-Za-z0-9_])/evmap_io_add_/g; s/(?<![A-Za-z0-9_])evmap_io_clear(?![A-Za-z0-9_])/evmap_io_clear_/g; s/(?<![A-Za-z0-9_])evmap_io_del(?![A-Za-z0-9_])/evmap_io_del_/g; s/(?<![A-Za-z0-9_])evmap_io_get_fdinfo(?![A-Za-z0-9_])/evmap_io_get_fdinfo_/g; s/(?<![A-Za-z0-9_])evmap_io_initmap(?![A-Za-z0-9_])/evmap_io_initmap_/g; s/(?<![A-Za-z0-9_])evmap_reinit(?![A-Za-z0-9_])/evmap_reinit_/g; s/(?<![A-Za-z0-9_])evmap_signal_active(?![A-Za-z0-9_])/evmap_signal_active_/g; s/(?<![A-Za-z0-9_])evmap_signal_add(?![A-Za-z0-9_])/evmap_signal_add_/g; s/(?<![A-Za-z0-9_])evmap_signal_clear(?![A-Za-z0-9_])/evmap_signal_clear_/g; s/(?<![A-Za-z0-9_])evmap_signal_del(?![A-Za-z0-9_])/evmap_signal_del_/g; s/(?<![A-Za-z0-9_])evmap_signal_initmap(?![A-Za-z0-9_])/evmap_signal_initmap_/g; s/(?<![A-Za-z0-9_])evrpc_hook_associate_meta(?![A-Za-z0-9_])/evrpc_hook_associate_meta_/g; s/(?<![A-Za-z0-9_])evrpc_hook_context_free(?![A-Za-z0-9_])/evrpc_hook_context_free_/g; s/(?<![A-Za-z0-9_])evrpc_hook_meta_new(?![A-Za-z0-9_])/evrpc_hook_meta_new_/g; s/(?<![A-Za-z0-9_])evrpc_reqstate_free(?![A-Za-z0-9_])/evrpc_reqstate_free_/g; s/(?<![A-Za-z0-9_])evsig_dealloc(?![A-Za-z0-9_])/evsig_dealloc_/g; s/(?<![A-Za-z0-9_])evsig_init(?![A-Za-z0-9_])/evsig_init_/g; s/(?<![A-Za-z0-9_])evsig_set_base(?![A-Za-z0-9_])/evsig_set_base_/g; s/(?<![A-Za-z0-9_])ev_token_bucket_get_tick(?![A-Za-z0-9_])/ev_token_bucket_get_tick_/g; s/(?<![A-Za-z0-9_])ev_token_bucket_init(?![A-Za-z0-9_])/ev_token_bucket_init_/g; s/(?<![A-Za-z0-9_])ev_token_bucket_update(?![A-Za-z0-9_])/ev_token_bucket_update_/g; s/(?<![A-Za-z0-9_])evutil_accept4(?![A-Za-z0-9_])/evutil_accept4_/g; s/(?<![A-Za-z0-9_])evutil_addrinfo_append(?![A-Za-z0-9_])/evutil_addrinfo_append_/g; s/(?<![A-Za-z0-9_])evutil_adjust_hints_for_addrconfig(?![A-Za-z0-9_])/evutil_adjust_hints_for_addrconfig_/g; s/(?<![A-Za-z0-9_])evutil_ersatz_socketpair(?![A-Za-z0-9_])/evutil_ersatz_socketpair_/g; s/(?<![A-Za-z0-9_])evutil_eventfd(?![A-Za-z0-9_])/evutil_eventfd_/g; s/(?<![A-Za-z0-9_])evutil_format_sockaddr_port(?![A-Za-z0-9_])/evutil_format_sockaddr_port_/g; s/(?<![A-Za-z0-9_])evutil_getaddrinfo_async(?![A-Za-z0-9_])/evutil_getaddrinfo_async_/g; s/(?<![A-Za-z0-9_])evutil_getaddrinfo_common(?![A-Za-z0-9_])/evutil_getaddrinfo_common_/g; s/(?<![A-Za-z0-9_])evutil_getenv(?![A-Za-z0-9_])/evutil_getenv_/g; s/(?<![A-Za-z0-9_])evutil_hex_char_to_int(?![A-Za-z0-9_])/evutil_hex_char_to_int_/g; s/(?<![A-Za-z0-9_])EVUTIL_ISALNUM(?![A-Za-z0-9_])/EVUTIL_ISALNUM_/g; s/(?<![A-Za-z0-9_])EVUTIL_ISALPHA(?![A-Za-z0-9_])/EVUTIL_ISALPHA_/g; s/(?<![A-Za-z0-9_])EVUTIL_ISDIGIT(?![A-Za-z0-9_])/EVUTIL_ISDIGIT_/g; s/(?<![A-Za-z0-9_])EVUTIL_ISLOWER(?![A-Za-z0-9_])/EVUTIL_ISLOWER_/g; s/(?<![A-Za-z0-9_])EVUTIL_ISPRINT(?![A-Za-z0-9_])/EVUTIL_ISPRINT_/g; s/(?<![A-Za-z0-9_])EVUTIL_ISSPACE(?![A-Za-z0-9_])/EVUTIL_ISSPACE_/g; s/(?<![A-Za-z0-9_])EVUTIL_ISUPPER(?![A-Za-z0-9_])/EVUTIL_ISUPPER_/g; s/(?<![A-Za-z0-9_])EVUTIL_ISXDIGIT(?![A-Za-z0-9_])/EVUTIL_ISXDIGIT_/g; s/(?<![A-Za-z0-9_])evutil_load_windows_system_library(?![A-Za-z0-9_])/evutil_load_windows_system_library_/g; s/(?<![A-Za-z0-9_])evutil_make_internal_pipe(?![A-Za-z0-9_])/evutil_make_internal_pipe_/g; s/(?<![A-Za-z0-9_])evutil_new_addrinfo(?![A-Za-z0-9_])/evutil_new_addrinfo_/g; s/(?<![A-Za-z0-9_])evutil_open_closeonexec(?![A-Za-z0-9_])/evutil_open_closeonexec_/g; s/(?<![A-Za-z0-9_])evutil_read_file(?![A-Za-z0-9_])/evutil_read_file_/g; s/(?<![A-Za-z0-9_])evutil_resolve(?![A-Za-z0-9_])/evutil_resolve_/g; s/(?<![A-Za-z0-9_])evutil_set_evdns_getaddrinfo_fn(?![A-Za-z0-9_])/evutil_set_evdns_getaddrinfo_fn_/g; s/(?<![A-Za-z0-9_])evutil_sockaddr_is_loopback(?![A-Za-z0-9_])/evutil_sockaddr_is_loopback_/g; s/(?<![A-Za-z0-9_])evutil_socket(?![A-Za-z0-9_])/evutil_socket_/g; s/(?<![A-Za-z0-9_])evutil_socket_connect(?![A-Za-z0-9_])/evutil_socket_connect_/g; s/(?<![A-Za-z0-9_])evutil_socket_finished_connecting(?![A-Za-z0-9_])/evutil_socket_finished_connecting_/g; s/(?<![A-Za-z0-9_])EVUTIL_TOLOWER(?![A-Za-z0-9_])/EVUTIL_TOLOWER_/g; s/(?<![A-Za-z0-9_])EVUTIL_TOUPPER(?![A-Za-z0-9_])/EVUTIL_TOUPPER_/g; s/(?<![A-Za-z0-9_])evutil_tv_to_msec(?![A-Za-z0-9_])/evutil_tv_to_msec_/g; s/(?<![A-Za-z0-9_])evutil_usleep(?![A-Za-z0-9_])/evutil_usleep_/g; s/(?<![A-Za-z0-9_])ht_improve_hash(?![A-Za-z0-9_])/ht_improve_hash_/g; s/(?<![A-Za-z0-9_])ht_string_hash(?![A-Za-z0-9_])/ht_string_hash_/g; s/(?<![A-Za-z0-9_])min_heap_adjust(?![A-Za-z0-9_])/min_heap_adjust_/g; s/(?<![A-Za-z0-9_])min_heap_ctor(?![A-Za-z0-9_])/min_heap_ctor_/g; s/(?<![A-Za-z0-9_])min_heap_dtor(?![A-Za-z0-9_])/min_heap_dtor_/g; s/(?<![A-Za-z0-9_])min_heap_elem_init(?![A-Za-z0-9_])/min_heap_elem_init_/g; s/(?<![A-Za-z0-9_])min_heap_elt_is_top(?![A-Za-z0-9_])/min_heap_elt_is_top_/g; s/(?<![A-Za-z0-9_])min_heap_empty(?![A-Za-z0-9_])/min_heap_empty_/g; s/(?<![A-Za-z0-9_])min_heap_erase(?![A-Za-z0-9_])/min_heap_erase_/g; s/(?<![A-Za-z0-9_])min_heap_pop(?![A-Za-z0-9_])/min_heap_pop_/g; s/(?<![A-Za-z0-9_])min_heap_push(?![A-Za-z0-9_])/min_heap_push_/g; s/(?<![A-Za-z0-9_])min_heap_reserve(?![A-Za-z0-9_])/min_heap_reserve_/g; s/(?<![A-Za-z0-9_])min_heap_size(?![A-Za-z0-9_])/min_heap_size_/g; s/(?<![A-Za-z0-9_])min_heap_top(?![A-Za-z0-9_])/min_heap_top_/g;
This commit is contained in:
parent
c9635349ec
commit
8ac3c4c25b
@ -261,7 +261,7 @@ arc4_seed_proc_sys_kernel_random_uuid(void)
|
||||
unsigned char entropy[64];
|
||||
int bytes, n, i, nybbles;
|
||||
for (bytes = 0; bytes<ADD_ENTROPY; ) {
|
||||
fd = evutil_open_closeonexec("/proc/sys/kernel/random/uuid", O_RDONLY, 0);
|
||||
fd = evutil_open_closeonexec_("/proc/sys/kernel/random/uuid", O_RDONLY, 0);
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
n = read(fd, buf, sizeof(buf));
|
||||
@ -270,8 +270,8 @@ arc4_seed_proc_sys_kernel_random_uuid(void)
|
||||
return -1;
|
||||
memset(entropy, 0, sizeof(entropy));
|
||||
for (i=nybbles=0; i<n; ++i) {
|
||||
if (EVUTIL_ISXDIGIT(buf[i])) {
|
||||
int nyb = evutil_hex_char_to_int(buf[i]);
|
||||
if (EVUTIL_ISXDIGIT_(buf[i])) {
|
||||
int nyb = evutil_hex_char_to_int_(buf[i]);
|
||||
if (nybbles & 1) {
|
||||
entropy[nybbles/2] |= nyb;
|
||||
} else {
|
||||
@ -305,7 +305,7 @@ arc4_seed_urandom(void)
|
||||
size_t n;
|
||||
|
||||
for (i = 0; filenames[i]; ++i) {
|
||||
fd = evutil_open_closeonexec(filenames[i], O_RDONLY, 0);
|
||||
fd = evutil_open_closeonexec_(filenames[i], O_RDONLY, 0);
|
||||
if (fd<0)
|
||||
continue;
|
||||
n = read_all(fd, buf, sizeof(buf));
|
||||
|
46
buffer.c
46
buffer.c
@ -402,9 +402,9 @@ int
|
||||
evbuffer_defer_callbacks(struct evbuffer *buffer, struct event_base *base)
|
||||
{
|
||||
EVBUFFER_LOCK(buffer);
|
||||
buffer->cb_queue = event_base_get_deferred_cb_queue(base);
|
||||
buffer->cb_queue = event_base_get_deferred_cb_queue_(base);
|
||||
buffer->deferred_cbs = 1;
|
||||
event_deferred_cb_init(&buffer->deferred,
|
||||
event_deferred_cb_init_(&buffer->deferred,
|
||||
evbuffer_deferred_callback, buffer);
|
||||
EVBUFFER_UNLOCK(buffer);
|
||||
return 0;
|
||||
@ -435,7 +435,7 @@ evbuffer_enable_locking(struct evbuffer *buf, void *lock)
|
||||
}
|
||||
|
||||
void
|
||||
evbuffer_set_parent(struct evbuffer *buf, struct bufferevent *bev)
|
||||
evbuffer_set_parent_(struct evbuffer *buf, struct bufferevent *bev)
|
||||
{
|
||||
EVBUFFER_LOCK(buf);
|
||||
buf->parent = bev;
|
||||
@ -501,7 +501,7 @@ evbuffer_run_callbacks(struct evbuffer *buffer, int running_deferred)
|
||||
}
|
||||
|
||||
void
|
||||
evbuffer_invoke_callbacks(struct evbuffer *buffer)
|
||||
evbuffer_invoke_callbacks_(struct evbuffer *buffer)
|
||||
{
|
||||
if (LIST_EMPTY(&buffer->callbacks)) {
|
||||
buffer->n_add_for_cb = buffer->n_del_for_cb = 0;
|
||||
@ -513,9 +513,9 @@ evbuffer_invoke_callbacks(struct evbuffer *buffer)
|
||||
return;
|
||||
evbuffer_incref_and_lock_(buffer);
|
||||
if (buffer->parent)
|
||||
bufferevent_incref(buffer->parent);
|
||||
bufferevent_incref_(buffer->parent);
|
||||
EVBUFFER_UNLOCK(buffer);
|
||||
event_deferred_cb_schedule(buffer->cb_queue, &buffer->deferred);
|
||||
event_deferred_cb_schedule_(buffer->cb_queue, &buffer->deferred);
|
||||
}
|
||||
|
||||
evbuffer_run_callbacks(buffer, 0);
|
||||
@ -534,7 +534,7 @@ evbuffer_deferred_callback(struct deferred_cb *cb, void *arg)
|
||||
evbuffer_run_callbacks(buffer, 1);
|
||||
evbuffer_decref_and_unlock_(buffer);
|
||||
if (parent)
|
||||
bufferevent_decref(parent);
|
||||
bufferevent_decref_(parent);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -567,7 +567,7 @@ evbuffer_decref_and_unlock_(struct evbuffer *buffer)
|
||||
}
|
||||
evbuffer_remove_all_callbacks(buffer);
|
||||
if (buffer->deferred_cbs)
|
||||
event_deferred_cb_cancel(buffer->cb_queue, &buffer->deferred);
|
||||
event_deferred_cb_cancel_(buffer->cb_queue, &buffer->deferred);
|
||||
|
||||
EVBUFFER_UNLOCK(buffer);
|
||||
if (buffer->own_lock)
|
||||
@ -770,7 +770,7 @@ okay:
|
||||
buf->total_len += added;
|
||||
buf->n_add_for_cb += added;
|
||||
result = 0;
|
||||
evbuffer_invoke_callbacks(buf);
|
||||
evbuffer_invoke_callbacks_(buf);
|
||||
|
||||
done:
|
||||
EVBUFFER_UNLOCK(buf);
|
||||
@ -982,8 +982,8 @@ evbuffer_add_buffer(struct evbuffer *outbuf, struct evbuffer *inbuf)
|
||||
inbuf->n_del_for_cb += in_total_len;
|
||||
outbuf->n_add_for_cb += in_total_len;
|
||||
|
||||
evbuffer_invoke_callbacks(inbuf);
|
||||
evbuffer_invoke_callbacks(outbuf);
|
||||
evbuffer_invoke_callbacks_(inbuf);
|
||||
evbuffer_invoke_callbacks_(outbuf);
|
||||
|
||||
done:
|
||||
EVBUFFER_UNLOCK2(inbuf, outbuf);
|
||||
@ -1026,7 +1026,7 @@ evbuffer_add_buffer_reference(struct evbuffer *outbuf, struct evbuffer *inbuf)
|
||||
APPEND_CHAIN_MULTICAST(outbuf, inbuf);
|
||||
|
||||
outbuf->n_add_for_cb += in_total_len;
|
||||
evbuffer_invoke_callbacks(outbuf);
|
||||
evbuffer_invoke_callbacks_(outbuf);
|
||||
|
||||
done:
|
||||
EVBUFFER_UNLOCK2(inbuf, outbuf);
|
||||
@ -1072,8 +1072,8 @@ evbuffer_prepend_buffer(struct evbuffer *outbuf, struct evbuffer *inbuf)
|
||||
inbuf->n_del_for_cb += in_total_len;
|
||||
outbuf->n_add_for_cb += in_total_len;
|
||||
|
||||
evbuffer_invoke_callbacks(inbuf);
|
||||
evbuffer_invoke_callbacks(outbuf);
|
||||
evbuffer_invoke_callbacks_(inbuf);
|
||||
evbuffer_invoke_callbacks_(outbuf);
|
||||
done:
|
||||
EVBUFFER_UNLOCK2(inbuf, outbuf);
|
||||
return result;
|
||||
@ -1139,7 +1139,7 @@ evbuffer_drain(struct evbuffer *buf, size_t len)
|
||||
|
||||
buf->n_del_for_cb += len;
|
||||
/* Tell someone about changes in this buffer */
|
||||
evbuffer_invoke_callbacks(buf);
|
||||
evbuffer_invoke_callbacks_(buf);
|
||||
|
||||
done:
|
||||
EVBUFFER_UNLOCK(buf);
|
||||
@ -1311,8 +1311,8 @@ evbuffer_remove_buffer(struct evbuffer *src, struct evbuffer *dst,
|
||||
src->n_del_for_cb += nread;
|
||||
|
||||
if (nread) {
|
||||
evbuffer_invoke_callbacks(dst);
|
||||
evbuffer_invoke_callbacks(src);
|
||||
evbuffer_invoke_callbacks_(dst);
|
||||
evbuffer_invoke_callbacks_(src);
|
||||
}
|
||||
result = (int)nread;/*XXXX should change return type */
|
||||
|
||||
@ -1778,7 +1778,7 @@ evbuffer_add(struct evbuffer *buf, const void *data_in, size_t datlen)
|
||||
buf->n_add_for_cb += datlen;
|
||||
|
||||
out:
|
||||
evbuffer_invoke_callbacks(buf);
|
||||
evbuffer_invoke_callbacks_(buf);
|
||||
result = 0;
|
||||
done:
|
||||
EVBUFFER_UNLOCK(buf);
|
||||
@ -1852,7 +1852,7 @@ evbuffer_prepend(struct evbuffer *buf, const void *data, size_t datlen)
|
||||
buf->n_add_for_cb += (size_t)chain->misalign;
|
||||
|
||||
out:
|
||||
evbuffer_invoke_callbacks(buf);
|
||||
evbuffer_invoke_callbacks_(buf);
|
||||
result = 0;
|
||||
done:
|
||||
EVBUFFER_UNLOCK(buf);
|
||||
@ -2341,7 +2341,7 @@ evbuffer_read(struct evbuffer *buf, evutil_socket_t fd, int howmuch)
|
||||
buf->n_add_for_cb += n;
|
||||
|
||||
/* Tell someone about changes in this buffer */
|
||||
evbuffer_invoke_callbacks(buf);
|
||||
evbuffer_invoke_callbacks_(buf);
|
||||
result = n;
|
||||
done:
|
||||
EVBUFFER_UNLOCK(buf);
|
||||
@ -2807,7 +2807,7 @@ evbuffer_add_vprintf(struct evbuffer *buf, const char *fmt, va_list ap)
|
||||
buf->n_add_for_cb += sz;
|
||||
|
||||
advance_last_with_data(buf);
|
||||
evbuffer_invoke_callbacks(buf);
|
||||
evbuffer_invoke_callbacks_(buf);
|
||||
result = sz;
|
||||
goto done;
|
||||
}
|
||||
@ -2865,7 +2865,7 @@ evbuffer_add_reference(struct evbuffer *outbuf,
|
||||
evbuffer_chain_insert(outbuf, chain);
|
||||
outbuf->n_add_for_cb += datlen;
|
||||
|
||||
evbuffer_invoke_callbacks(outbuf);
|
||||
evbuffer_invoke_callbacks_(outbuf);
|
||||
|
||||
result = 0;
|
||||
done:
|
||||
@ -3159,7 +3159,7 @@ evbuffer_add_file_segment(struct evbuffer *buf,
|
||||
buf->n_add_for_cb += length;
|
||||
evbuffer_chain_insert(buf, chain);
|
||||
|
||||
evbuffer_invoke_callbacks(buf);
|
||||
evbuffer_invoke_callbacks_(buf);
|
||||
|
||||
EVBUFFER_UNLOCK(buf);
|
||||
|
||||
|
@ -94,7 +94,7 @@ pin_release(struct evbuffer_overlapped *eo, unsigned flag)
|
||||
}
|
||||
|
||||
void
|
||||
evbuffer_commit_read(struct evbuffer *evbuf, ev_ssize_t nBytes)
|
||||
evbuffer_commit_read_(struct evbuffer *evbuf, ev_ssize_t nBytes)
|
||||
{
|
||||
struct evbuffer_overlapped *buf = upcast_evbuffer(evbuf);
|
||||
struct evbuffer_chain **chainp;
|
||||
@ -129,13 +129,13 @@ evbuffer_commit_read(struct evbuffer *evbuf, ev_ssize_t nBytes)
|
||||
evbuf->total_len += nBytes;
|
||||
evbuf->n_add_for_cb += nBytes;
|
||||
|
||||
evbuffer_invoke_callbacks(evbuf);
|
||||
evbuffer_invoke_callbacks_(evbuf);
|
||||
|
||||
evbuffer_decref_and_unlock_(evbuf);
|
||||
}
|
||||
|
||||
void
|
||||
evbuffer_commit_write(struct evbuffer *evbuf, ev_ssize_t nBytes)
|
||||
evbuffer_commit_write_(struct evbuffer *evbuf, ev_ssize_t nBytes)
|
||||
{
|
||||
struct evbuffer_overlapped *buf = upcast_evbuffer(evbuf);
|
||||
|
||||
@ -149,7 +149,7 @@ evbuffer_commit_write(struct evbuffer *evbuf, ev_ssize_t nBytes)
|
||||
}
|
||||
|
||||
struct evbuffer *
|
||||
evbuffer_overlapped_new(evutil_socket_t fd)
|
||||
evbuffer_overlapped_new_(evutil_socket_t fd)
|
||||
{
|
||||
struct evbuffer_overlapped *evo;
|
||||
|
||||
@ -168,7 +168,7 @@ evbuffer_overlapped_new(evutil_socket_t fd)
|
||||
}
|
||||
|
||||
int
|
||||
evbuffer_launch_write(struct evbuffer *buf, ev_ssize_t at_most,
|
||||
evbuffer_launch_write_(struct evbuffer *buf, ev_ssize_t at_most,
|
||||
struct event_overlapped *ol)
|
||||
{
|
||||
struct evbuffer_overlapped *buf_o = upcast_evbuffer(buf);
|
||||
@ -242,7 +242,7 @@ done:
|
||||
}
|
||||
|
||||
int
|
||||
evbuffer_launch_read(struct evbuffer *buf, size_t at_most,
|
||||
evbuffer_launch_read_(struct evbuffer *buf, size_t at_most,
|
||||
struct event_overlapped *ol)
|
||||
{
|
||||
struct evbuffer_overlapped *buf_o = upcast_evbuffer(buf);
|
||||
|
@ -279,52 +279,52 @@ extern const struct bufferevent_ops bufferevent_ops_async;
|
||||
#endif
|
||||
|
||||
/** Initialize the shared parts of a bufferevent. */
|
||||
int bufferevent_init_common(struct bufferevent_private *, struct event_base *, const struct bufferevent_ops *, enum bufferevent_options options);
|
||||
int bufferevent_init_common_(struct bufferevent_private *, struct event_base *, const struct bufferevent_ops *, enum bufferevent_options options);
|
||||
|
||||
/** For internal use: temporarily stop all reads on bufev, until the conditions
|
||||
* in 'what' are over. */
|
||||
void bufferevent_suspend_read(struct bufferevent *bufev, bufferevent_suspend_flags what);
|
||||
void bufferevent_suspend_read_(struct bufferevent *bufev, bufferevent_suspend_flags what);
|
||||
/** For internal use: clear the conditions 'what' on bufev, and re-enable
|
||||
* reading if there are no conditions left. */
|
||||
void bufferevent_unsuspend_read(struct bufferevent *bufev, bufferevent_suspend_flags what);
|
||||
void bufferevent_unsuspend_read_(struct bufferevent *bufev, bufferevent_suspend_flags what);
|
||||
|
||||
/** For internal use: temporarily stop all writes on bufev, until the conditions
|
||||
* in 'what' are over. */
|
||||
void bufferevent_suspend_write(struct bufferevent *bufev, bufferevent_suspend_flags what);
|
||||
void bufferevent_suspend_write_(struct bufferevent *bufev, bufferevent_suspend_flags what);
|
||||
/** For internal use: clear the conditions 'what' on bufev, and re-enable
|
||||
* writing if there are no conditions left. */
|
||||
void bufferevent_unsuspend_write(struct bufferevent *bufev, bufferevent_suspend_flags what);
|
||||
void bufferevent_unsuspend_write_(struct bufferevent *bufev, bufferevent_suspend_flags what);
|
||||
|
||||
#define bufferevent_wm_suspend_read(b) \
|
||||
bufferevent_suspend_read((b), BEV_SUSPEND_WM)
|
||||
bufferevent_suspend_read_((b), BEV_SUSPEND_WM)
|
||||
#define bufferevent_wm_unsuspend_read(b) \
|
||||
bufferevent_unsuspend_read((b), BEV_SUSPEND_WM)
|
||||
bufferevent_unsuspend_read_((b), BEV_SUSPEND_WM)
|
||||
|
||||
/*
|
||||
Disable a bufferevent. Equivalent to bufferevent_disable(), but
|
||||
first resets 'connecting' flag to force EV_WRITE down for sure.
|
||||
|
||||
XXXX this method will go away in the future; try not to add new users.
|
||||
See comment in evhttp_connection_reset() for discussion.
|
||||
See comment in evhttp_connection_reset_() for discussion.
|
||||
|
||||
@param bufev the bufferevent to be disabled
|
||||
@param event any combination of EV_READ | EV_WRITE.
|
||||
@return 0 if successful, or -1 if an error occurred
|
||||
@see bufferevent_disable()
|
||||
*/
|
||||
int bufferevent_disable_hard(struct bufferevent *bufev, short event);
|
||||
int bufferevent_disable_hard_(struct bufferevent *bufev, short event);
|
||||
|
||||
/** Internal: Set up locking on a bufferevent. If lock is set, use it.
|
||||
* Otherwise, use a new lock. */
|
||||
int bufferevent_enable_locking(struct bufferevent *bufev, void *lock);
|
||||
int bufferevent_enable_locking_(struct bufferevent *bufev, void *lock);
|
||||
/** Internal: Increment the reference count on bufev. */
|
||||
void bufferevent_incref(struct bufferevent *bufev);
|
||||
void bufferevent_incref_(struct bufferevent *bufev);
|
||||
/** Internal: Lock bufev and increase its reference count.
|
||||
* unlocking it otherwise. */
|
||||
void bufferevent_incref_and_lock_(struct bufferevent *bufev);
|
||||
/** Internal: Decrement the reference count on bufev. Returns 1 if it freed
|
||||
* the bufferevent.*/
|
||||
int bufferevent_decref(struct bufferevent *bufev);
|
||||
int bufferevent_decref_(struct bufferevent *bufev);
|
||||
/** Internal: Drop the reference count on bufev, freeing as necessary, and
|
||||
* unlocking it otherwise. Returns 1 if it freed the bufferevent. */
|
||||
int bufferevent_decref_and_unlock_(struct bufferevent *bufev);
|
||||
|
@ -64,7 +64,7 @@ static void bufferevent_cancel_all_(struct bufferevent *bev);
|
||||
|
||||
|
||||
void
|
||||
bufferevent_suspend_read(struct bufferevent *bufev, bufferevent_suspend_flags what)
|
||||
bufferevent_suspend_read_(struct bufferevent *bufev, bufferevent_suspend_flags what)
|
||||
{
|
||||
struct bufferevent_private *bufev_private =
|
||||
EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
|
||||
@ -76,7 +76,7 @@ bufferevent_suspend_read(struct bufferevent *bufev, bufferevent_suspend_flags wh
|
||||
}
|
||||
|
||||
void
|
||||
bufferevent_unsuspend_read(struct bufferevent *bufev, bufferevent_suspend_flags what)
|
||||
bufferevent_unsuspend_read_(struct bufferevent *bufev, bufferevent_suspend_flags what)
|
||||
{
|
||||
struct bufferevent_private *bufev_private =
|
||||
EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
|
||||
@ -88,7 +88,7 @@ bufferevent_unsuspend_read(struct bufferevent *bufev, bufferevent_suspend_flags
|
||||
}
|
||||
|
||||
void
|
||||
bufferevent_suspend_write(struct bufferevent *bufev, bufferevent_suspend_flags what)
|
||||
bufferevent_suspend_write_(struct bufferevent *bufev, bufferevent_suspend_flags what)
|
||||
{
|
||||
struct bufferevent_private *bufev_private =
|
||||
EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
|
||||
@ -100,7 +100,7 @@ bufferevent_suspend_write(struct bufferevent *bufev, bufferevent_suspend_flags w
|
||||
}
|
||||
|
||||
void
|
||||
bufferevent_unsuspend_write(struct bufferevent *bufev, bufferevent_suspend_flags what)
|
||||
bufferevent_unsuspend_write_(struct bufferevent *bufev, bufferevent_suspend_flags what)
|
||||
{
|
||||
struct bufferevent_private *bufev_private =
|
||||
EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
|
||||
@ -210,9 +210,9 @@ bufferevent_run_deferred_callbacks_unlocked(struct deferred_cb *_, void *arg)
|
||||
|
||||
#define SCHEDULE_DEFERRED(bevp) \
|
||||
do { \
|
||||
bufferevent_incref(&(bevp)->bev); \
|
||||
event_deferred_cb_schedule( \
|
||||
event_base_get_deferred_cb_queue((bevp)->bev.ev_base), \
|
||||
bufferevent_incref_(&(bevp)->bev); \
|
||||
event_deferred_cb_schedule_( \
|
||||
event_base_get_deferred_cb_queue_((bevp)->bev.ev_base), \
|
||||
&(bevp)->deferred); \
|
||||
} while (0)
|
||||
|
||||
@ -270,7 +270,7 @@ bufferevent_run_eventcb_(struct bufferevent *bufev, short what)
|
||||
}
|
||||
|
||||
int
|
||||
bufferevent_init_common(struct bufferevent_private *bufev_private,
|
||||
bufferevent_init_common_(struct bufferevent_private *bufev_private,
|
||||
struct event_base *base,
|
||||
const struct bufferevent_ops *ops,
|
||||
enum bufferevent_options options)
|
||||
@ -309,7 +309,7 @@ bufferevent_init_common(struct bufferevent_private *bufev_private,
|
||||
|
||||
#ifndef EVENT__DISABLE_THREAD_SUPPORT
|
||||
if (options & BEV_OPT_THREADSAFE) {
|
||||
if (bufferevent_enable_locking(bufev, NULL) < 0) {
|
||||
if (bufferevent_enable_locking_(bufev, NULL) < 0) {
|
||||
/* cleanup */
|
||||
evbuffer_free(bufev->input);
|
||||
evbuffer_free(bufev->output);
|
||||
@ -326,19 +326,19 @@ bufferevent_init_common(struct bufferevent_private *bufev_private,
|
||||
}
|
||||
if (options & BEV_OPT_DEFER_CALLBACKS) {
|
||||
if (options & BEV_OPT_UNLOCK_CALLBACKS)
|
||||
event_deferred_cb_init(&bufev_private->deferred,
|
||||
event_deferred_cb_init_(&bufev_private->deferred,
|
||||
bufferevent_run_deferred_callbacks_unlocked,
|
||||
bufev_private);
|
||||
else
|
||||
event_deferred_cb_init(&bufev_private->deferred,
|
||||
event_deferred_cb_init_(&bufev_private->deferred,
|
||||
bufferevent_run_deferred_callbacks_locked,
|
||||
bufev_private);
|
||||
}
|
||||
|
||||
bufev_private->options = options;
|
||||
|
||||
evbuffer_set_parent(bufev->input, bufev);
|
||||
evbuffer_set_parent(bufev->output, bufev);
|
||||
evbuffer_set_parent_(bufev->input, bufev);
|
||||
evbuffer_set_parent_(bufev->output, bufev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -500,7 +500,7 @@ bufferevent_settimeout(struct bufferevent *bufev,
|
||||
|
||||
|
||||
int
|
||||
bufferevent_disable_hard(struct bufferevent *bufev, short event)
|
||||
bufferevent_disable_hard_(struct bufferevent *bufev, short event)
|
||||
{
|
||||
int r = 0;
|
||||
struct bufferevent_private *bufev_private =
|
||||
@ -653,7 +653,7 @@ bufferevent_decref_and_unlock_(struct bufferevent *bufev)
|
||||
|
||||
if (bufev_private->rate_limiting) {
|
||||
if (bufev_private->rate_limiting->group)
|
||||
bufferevent_remove_from_rate_limit_group_internal(bufev,0);
|
||||
bufferevent_remove_from_rate_limit_group_internal_(bufev,0);
|
||||
if (event_initialized(&bufev_private->rate_limiting->refill_bucket_event))
|
||||
event_del(&bufev_private->rate_limiting->refill_bucket_event);
|
||||
event_debug_unassign(&bufev_private->rate_limiting->refill_bucket_event);
|
||||
@ -683,13 +683,13 @@ bufferevent_decref_and_unlock_(struct bufferevent *bufev)
|
||||
* It would probably save us some headaches.
|
||||
*/
|
||||
if (underlying)
|
||||
bufferevent_decref(underlying);
|
||||
bufferevent_decref_(underlying);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
bufferevent_decref(struct bufferevent *bufev)
|
||||
bufferevent_decref_(struct bufferevent *bufev)
|
||||
{
|
||||
BEV_LOCK(bufev);
|
||||
return bufferevent_decref_and_unlock_(bufev);
|
||||
@ -705,7 +705,7 @@ bufferevent_free(struct bufferevent *bufev)
|
||||
}
|
||||
|
||||
void
|
||||
bufferevent_incref(struct bufferevent *bufev)
|
||||
bufferevent_incref_(struct bufferevent *bufev)
|
||||
{
|
||||
struct bufferevent_private *bufev_private =
|
||||
EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
|
||||
@ -716,7 +716,7 @@ bufferevent_incref(struct bufferevent *bufev)
|
||||
}
|
||||
|
||||
int
|
||||
bufferevent_enable_locking(struct bufferevent *bufev, void *lock)
|
||||
bufferevent_enable_locking_(struct bufferevent *bufev, void *lock)
|
||||
{
|
||||
#ifdef EVENT__DISABLE_THREAD_SUPPORT
|
||||
return -1;
|
||||
@ -745,7 +745,7 @@ bufferevent_enable_locking(struct bufferevent *bufev, void *lock)
|
||||
evbuffer_enable_locking(bufev->output, lock);
|
||||
|
||||
if (underlying && !BEV_UPCAST(underlying)->lock)
|
||||
bufferevent_enable_locking(underlying, lock);
|
||||
bufferevent_enable_locking_(underlying, lock);
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
|
@ -143,7 +143,7 @@ bev_async_del_write(struct bufferevent_async *beva)
|
||||
|
||||
if (beva->write_added) {
|
||||
beva->write_added = 0;
|
||||
event_base_del_virtual(bev->ev_base);
|
||||
event_base_del_virtual_(bev->ev_base);
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,7 +154,7 @@ bev_async_del_read(struct bufferevent_async *beva)
|
||||
|
||||
if (beva->read_added) {
|
||||
beva->read_added = 0;
|
||||
event_base_del_virtual(bev->ev_base);
|
||||
event_base_del_virtual_(bev->ev_base);
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ bev_async_add_write(struct bufferevent_async *beva)
|
||||
|
||||
if (!beva->write_added) {
|
||||
beva->write_added = 1;
|
||||
event_base_add_virtual(bev->ev_base);
|
||||
event_base_add_virtual_(bev->ev_base);
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ bev_async_add_read(struct bufferevent_async *beva)
|
||||
|
||||
if (!beva->read_added) {
|
||||
beva->read_added = 1;
|
||||
event_base_add_virtual(bev->ev_base);
|
||||
event_base_add_virtual_(bev->ev_base);
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,10 +211,10 @@ bev_async_consider_writing(struct bufferevent_async *beva)
|
||||
}
|
||||
|
||||
/* XXXX doesn't respect low-water mark very well. */
|
||||
bufferevent_incref(bev);
|
||||
if (evbuffer_launch_write(bev->output, at_most,
|
||||
bufferevent_incref_(bev);
|
||||
if (evbuffer_launch_write_(bev->output, at_most,
|
||||
&beva->write_overlapped)) {
|
||||
bufferevent_decref(bev);
|
||||
bufferevent_decref_(bev);
|
||||
beva->ok = 0;
|
||||
bufferevent_run_eventcb_(bev, BEV_EVENT_ERROR);
|
||||
} else {
|
||||
@ -266,11 +266,11 @@ bev_async_consider_reading(struct bufferevent_async *beva)
|
||||
return;
|
||||
}
|
||||
|
||||
bufferevent_incref(bev);
|
||||
if (evbuffer_launch_read(bev->input, at_most, &beva->read_overlapped)) {
|
||||
bufferevent_incref_(bev);
|
||||
if (evbuffer_launch_read_(bev->input, at_most, &beva->read_overlapped)) {
|
||||
beva->ok = 0;
|
||||
bufferevent_run_eventcb_(bev, BEV_EVENT_ERROR);
|
||||
bufferevent_decref(bev);
|
||||
bufferevent_decref_(bev);
|
||||
} else {
|
||||
beva->read_in_progress = at_most;
|
||||
bufferevent_decrement_read_buckets_(&beva->bev, at_most);
|
||||
@ -427,14 +427,14 @@ connect_complete(struct event_overlapped *eo, ev_uintptr_t key,
|
||||
setsockopt(sock, SOL_SOCKET, SO_UPDATE_CONNECT_CONTEXT, NULL, 0);
|
||||
|
||||
if (ok)
|
||||
bufferevent_async_set_connected(bev);
|
||||
bufferevent_async_set_connected_(bev);
|
||||
else
|
||||
bev_async_set_wsa_error(bev, eo);
|
||||
|
||||
bufferevent_run_eventcb_(bev,
|
||||
ok? BEV_EVENT_CONNECTED : BEV_EVENT_ERROR);
|
||||
|
||||
event_base_del_virtual(bev->ev_base);
|
||||
event_base_del_virtual_(bev->ev_base);
|
||||
|
||||
bufferevent_decref_and_unlock_(bev);
|
||||
}
|
||||
@ -451,7 +451,7 @@ read_complete(struct event_overlapped *eo, ev_uintptr_t key,
|
||||
EVUTIL_ASSERT(bev_a->read_in_progress);
|
||||
|
||||
amount_unread = bev_a->read_in_progress - nbytes;
|
||||
evbuffer_commit_read(bev->input, nbytes);
|
||||
evbuffer_commit_read_(bev->input, nbytes);
|
||||
bev_a->read_in_progress = 0;
|
||||
if (amount_unread)
|
||||
bufferevent_decrement_read_buckets_(&bev_a->bev, -amount_unread);
|
||||
@ -492,7 +492,7 @@ write_complete(struct event_overlapped *eo, ev_uintptr_t key,
|
||||
EVUTIL_ASSERT(bev_a->write_in_progress);
|
||||
|
||||
amount_unwritten = bev_a->write_in_progress - nbytes;
|
||||
evbuffer_commit_write(bev->output, nbytes);
|
||||
evbuffer_commit_write_(bev->output, nbytes);
|
||||
bev_a->write_in_progress = 0;
|
||||
|
||||
if (amount_unwritten)
|
||||
@ -525,7 +525,7 @@ write_complete(struct event_overlapped *eo, ev_uintptr_t key,
|
||||
}
|
||||
|
||||
struct bufferevent *
|
||||
bufferevent_async_new(struct event_base *base,
|
||||
bufferevent_async_new_(struct event_base *base,
|
||||
evutil_socket_t fd, int options)
|
||||
{
|
||||
struct bufferevent_async *bev_a;
|
||||
@ -534,10 +534,10 @@ bufferevent_async_new(struct event_base *base,
|
||||
|
||||
options |= BEV_OPT_THREADSAFE;
|
||||
|
||||
if (!(iocp = event_base_get_iocp(base)))
|
||||
if (!(iocp = event_base_get_iocp_(base)))
|
||||
return NULL;
|
||||
|
||||
if (fd >= 0 && event_iocp_port_associate(iocp, fd, 1)<0) {
|
||||
if (fd >= 0 && event_iocp_port_associate_(iocp, fd, 1)<0) {
|
||||
int err = GetLastError();
|
||||
/* We may have alrady associated this fd with a port.
|
||||
* Let's hope it's this port, and that the error code
|
||||
@ -550,26 +550,26 @@ bufferevent_async_new(struct event_base *base,
|
||||
return NULL;
|
||||
|
||||
bev = &bev_a->bev.bev;
|
||||
if (!(bev->input = evbuffer_overlapped_new(fd))) {
|
||||
if (!(bev->input = evbuffer_overlapped_new_(fd))) {
|
||||
mm_free(bev_a);
|
||||
return NULL;
|
||||
}
|
||||
if (!(bev->output = evbuffer_overlapped_new(fd))) {
|
||||
if (!(bev->output = evbuffer_overlapped_new_(fd))) {
|
||||
evbuffer_free(bev->input);
|
||||
mm_free(bev_a);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (bufferevent_init_common(&bev_a->bev, base, &bufferevent_ops_async,
|
||||
if (bufferevent_init_common_(&bev_a->bev, base, &bufferevent_ops_async,
|
||||
options)<0)
|
||||
goto err;
|
||||
|
||||
evbuffer_add_cb(bev->input, be_async_inbuf_callback, bev);
|
||||
evbuffer_add_cb(bev->output, be_async_outbuf_callback, bev);
|
||||
|
||||
event_overlapped_init(&bev_a->connect_overlapped, connect_complete);
|
||||
event_overlapped_init(&bev_a->read_overlapped, read_complete);
|
||||
event_overlapped_init(&bev_a->write_overlapped, write_complete);
|
||||
event_overlapped_init_(&bev_a->connect_overlapped, connect_complete);
|
||||
event_overlapped_init_(&bev_a->read_overlapped, read_complete);
|
||||
event_overlapped_init_(&bev_a->write_overlapped, write_complete);
|
||||
|
||||
bev_a->ok = fd >= 0;
|
||||
if (bev_a->ok)
|
||||
@ -582,7 +582,7 @@ err:
|
||||
}
|
||||
|
||||
void
|
||||
bufferevent_async_set_connected(struct bufferevent *bev)
|
||||
bufferevent_async_set_connected_(struct bufferevent *bev)
|
||||
{
|
||||
struct bufferevent_async *bev_async = upcast(bev);
|
||||
bev_async->ok = 1;
|
||||
@ -592,13 +592,13 @@ bufferevent_async_set_connected(struct bufferevent *bev)
|
||||
}
|
||||
|
||||
int
|
||||
bufferevent_async_can_connect(struct bufferevent *bev)
|
||||
bufferevent_async_can_connect_(struct bufferevent *bev)
|
||||
{
|
||||
const struct win32_extension_fns *ext =
|
||||
event_get_win32_extension_fns();
|
||||
event_get_win32_extension_fns_();
|
||||
|
||||
if (BEV_IS_ASYNC(bev) &&
|
||||
event_base_get_iocp(bev->ev_base) &&
|
||||
event_base_get_iocp_(bev->ev_base) &&
|
||||
ext && ext->ConnectEx)
|
||||
return 1;
|
||||
|
||||
@ -606,14 +606,14 @@ bufferevent_async_can_connect(struct bufferevent *bev)
|
||||
}
|
||||
|
||||
int
|
||||
bufferevent_async_connect(struct bufferevent *bev, evutil_socket_t fd,
|
||||
bufferevent_async_connect_(struct bufferevent *bev, evutil_socket_t fd,
|
||||
const struct sockaddr *sa, int socklen)
|
||||
{
|
||||
BOOL rc;
|
||||
struct bufferevent_async *bev_async = upcast(bev);
|
||||
struct sockaddr_storage ss;
|
||||
const struct win32_extension_fns *ext =
|
||||
event_get_win32_extension_fns();
|
||||
event_get_win32_extension_fns_();
|
||||
|
||||
EVUTIL_ASSERT(ext && ext->ConnectEx && fd >= 0 && sa != NULL);
|
||||
|
||||
@ -638,15 +638,15 @@ bufferevent_async_connect(struct bufferevent *bev, evutil_socket_t fd,
|
||||
WSAGetLastError() != WSAEINVAL)
|
||||
return -1;
|
||||
|
||||
event_base_add_virtual(bev->ev_base);
|
||||
bufferevent_incref(bev);
|
||||
event_base_add_virtual_(bev->ev_base);
|
||||
bufferevent_incref_(bev);
|
||||
rc = ext->ConnectEx(fd, sa, socklen, NULL, 0, NULL,
|
||||
&bev_async->connect_overlapped.overlapped);
|
||||
if (rc || WSAGetLastError() == ERROR_IO_PENDING)
|
||||
return 0;
|
||||
|
||||
event_base_del_virtual(bev->ev_base);
|
||||
bufferevent_decref(bev);
|
||||
event_base_del_virtual_(bev->ev_base);
|
||||
bufferevent_decref_(bev);
|
||||
|
||||
return -1;
|
||||
}
|
||||
@ -664,9 +664,9 @@ be_async_ctrl(struct bufferevent *bev, enum bufferevent_ctrl_op op,
|
||||
|
||||
if (data->fd == evbuffer_overlapped_get_fd_(bev->input))
|
||||
return 0;
|
||||
if (!(iocp = event_base_get_iocp(bev->ev_base)))
|
||||
if (!(iocp = event_base_get_iocp_(bev->ev_base)))
|
||||
return -1;
|
||||
if (event_iocp_port_associate(iocp, data->fd, 1) < 0)
|
||||
if (event_iocp_port_associate_(iocp, data->fd, 1) < 0)
|
||||
return -1;
|
||||
evbuffer_overlapped_set_fd_(bev->input, data->fd);
|
||||
evbuffer_overlapped_set_fd_(bev->output, data->fd);
|
||||
|
@ -182,13 +182,13 @@ bufferevent_filter_new(struct bufferevent *underlying,
|
||||
if (!bufev_f)
|
||||
return NULL;
|
||||
|
||||
if (bufferevent_init_common(&bufev_f->bev, underlying->ev_base,
|
||||
if (bufferevent_init_common_(&bufev_f->bev, underlying->ev_base,
|
||||
&bufferevent_ops_filter, tmp_options) < 0) {
|
||||
mm_free(bufev_f);
|
||||
return NULL;
|
||||
}
|
||||
if (options & BEV_OPT_THREADSAFE) {
|
||||
bufferevent_enable_locking(downcast(bufev_f), NULL);
|
||||
bufferevent_enable_locking_(downcast(bufev_f), NULL);
|
||||
}
|
||||
|
||||
bufev_f->underlying = underlying;
|
||||
@ -205,10 +205,10 @@ bufferevent_filter_new(struct bufferevent *underlying,
|
||||
bufferevent_filtered_outbuf_cb, bufev_f);
|
||||
|
||||
bufferevent_init_generic_timeout_cbs_(downcast(bufev_f));
|
||||
bufferevent_incref(underlying);
|
||||
bufferevent_incref_(underlying);
|
||||
|
||||
bufferevent_enable(underlying, EV_READ|EV_WRITE);
|
||||
bufferevent_suspend_read(underlying, BEV_SUSPEND_FILT_READ);
|
||||
bufferevent_suspend_read_(underlying, BEV_SUSPEND_FILT_READ);
|
||||
|
||||
return downcast(bufev_f);
|
||||
}
|
||||
@ -222,7 +222,7 @@ be_filter_destruct(struct bufferevent *bev)
|
||||
bevf->free_context(bevf->context);
|
||||
|
||||
if (bevf->bev.options & BEV_OPT_CLOSE_ON_FREE) {
|
||||
/* Yes, there is also a decref in bufferevent_decref.
|
||||
/* Yes, there is also a decref in bufferevent_decref_.
|
||||
* That decref corresponds to the incref when we set
|
||||
* underlying for the first time. This decref is an
|
||||
* extra one to remove the last reference.
|
||||
@ -238,7 +238,7 @@ be_filter_destruct(struct bufferevent *bev)
|
||||
if (bevf->underlying->errorcb == be_filter_eventcb)
|
||||
bufferevent_setcb(bevf->underlying,
|
||||
NULL, NULL, NULL, NULL);
|
||||
bufferevent_unsuspend_read(bevf->underlying,
|
||||
bufferevent_unsuspend_read_(bevf->underlying,
|
||||
BEV_SUSPEND_FILT_READ);
|
||||
}
|
||||
}
|
||||
@ -255,7 +255,7 @@ be_filter_enable(struct bufferevent *bev, short event)
|
||||
|
||||
if (event & EV_READ) {
|
||||
BEV_RESET_GENERIC_READ_TIMEOUT(bev);
|
||||
bufferevent_unsuspend_read(bevf->underlying,
|
||||
bufferevent_unsuspend_read_(bevf->underlying,
|
||||
BEV_SUSPEND_FILT_READ);
|
||||
}
|
||||
return 0;
|
||||
@ -269,7 +269,7 @@ be_filter_disable(struct bufferevent *bev, short event)
|
||||
BEV_DEL_GENERIC_WRITE_TIMEOUT(bev);
|
||||
if (event & EV_READ) {
|
||||
BEV_DEL_GENERIC_READ_TIMEOUT(bev);
|
||||
bufferevent_suspend_read(bevf->underlying,
|
||||
bufferevent_suspend_read_(bevf->underlying,
|
||||
BEV_SUSPEND_FILT_READ);
|
||||
}
|
||||
return 0;
|
||||
|
@ -377,7 +377,7 @@ static int
|
||||
start_reading(struct bufferevent_openssl *bev_ssl)
|
||||
{
|
||||
if (bev_ssl->underlying) {
|
||||
bufferevent_unsuspend_read(bev_ssl->underlying,
|
||||
bufferevent_unsuspend_read_(bev_ssl->underlying,
|
||||
BEV_SUSPEND_FILT_READ);
|
||||
return 0;
|
||||
} else {
|
||||
@ -416,7 +416,7 @@ stop_reading(struct bufferevent_openssl *bev_ssl)
|
||||
if (bev_ssl->write_blocked_on_read)
|
||||
return;
|
||||
if (bev_ssl->underlying) {
|
||||
bufferevent_suspend_read(bev_ssl->underlying,
|
||||
bufferevent_suspend_read_(bev_ssl->underlying,
|
||||
BEV_SUSPEND_FILT_READ);
|
||||
} else {
|
||||
struct bufferevent *bev = &bev_ssl->bev.bev;
|
||||
@ -1174,7 +1174,7 @@ be_openssl_destruct(struct bufferevent *bev)
|
||||
if (bev_ssl->underlying->errorcb == be_openssl_eventcb)
|
||||
bufferevent_setcb(bev_ssl->underlying,
|
||||
NULL,NULL,NULL,NULL);
|
||||
bufferevent_unsuspend_read(bev_ssl->underlying,
|
||||
bufferevent_unsuspend_read_(bev_ssl->underlying,
|
||||
BEV_SUSPEND_FILT_READ);
|
||||
}
|
||||
}
|
||||
@ -1272,7 +1272,7 @@ bufferevent_openssl_new_impl(struct event_base *base,
|
||||
|
||||
bev_p = &bev_ssl->bev;
|
||||
|
||||
if (bufferevent_init_common(bev_p, base,
|
||||
if (bufferevent_init_common_(bev_p, base,
|
||||
&bufferevent_ops_openssl, tmp_options) < 0)
|
||||
goto err;
|
||||
|
||||
@ -1287,11 +1287,11 @@ bufferevent_openssl_new_impl(struct event_base *base,
|
||||
be_openssl_outbuf_cb, bev_ssl);
|
||||
|
||||
if (options & BEV_OPT_THREADSAFE)
|
||||
bufferevent_enable_locking(&bev_ssl->bev.bev, NULL);
|
||||
bufferevent_enable_locking_(&bev_ssl->bev.bev, NULL);
|
||||
|
||||
if (underlying) {
|
||||
bufferevent_init_generic_timeout_cbs_(&bev_ssl->bev.bev);
|
||||
bufferevent_incref(underlying);
|
||||
bufferevent_incref_(underlying);
|
||||
}
|
||||
|
||||
bev_ssl->state = state;
|
||||
@ -1322,7 +1322,7 @@ bufferevent_openssl_new_impl(struct event_base *base,
|
||||
bufferevent_setwatermark(underlying, EV_READ, 0, 0);
|
||||
bufferevent_enable(underlying, EV_READ|EV_WRITE);
|
||||
if (state == BUFFEREVENT_SSL_OPEN)
|
||||
bufferevent_suspend_read(underlying,
|
||||
bufferevent_suspend_read_(underlying,
|
||||
BEV_SUSPEND_FILT_READ);
|
||||
} else {
|
||||
bev_ssl->bev.bev.enabled = EV_READ|EV_WRITE;
|
||||
|
@ -94,7 +94,7 @@ bufferevent_pair_elt_new(struct event_base *base,
|
||||
struct bufferevent_pair *bufev;
|
||||
if (! (bufev = mm_calloc(1, sizeof(struct bufferevent_pair))))
|
||||
return NULL;
|
||||
if (bufferevent_init_common(&bufev->bev, base, &bufferevent_ops_pair,
|
||||
if (bufferevent_init_common_(&bufev->bev, base, &bufferevent_ops_pair,
|
||||
options)) {
|
||||
mm_free(bufev);
|
||||
return NULL;
|
||||
@ -130,7 +130,7 @@ bufferevent_pair_new(struct event_base *base, int options,
|
||||
|
||||
if (options & BEV_OPT_THREADSAFE) {
|
||||
/*XXXX check return */
|
||||
bufferevent_enable_locking(downcast(bufev2), bufev1->bev.lock);
|
||||
bufferevent_enable_locking_(downcast(bufev2), bufev1->bev.lock);
|
||||
}
|
||||
|
||||
bufev1->partner = bufev2;
|
||||
|
@ -47,7 +47,7 @@
|
||||
#include "event-internal.h"
|
||||
|
||||
int
|
||||
ev_token_bucket_init(struct ev_token_bucket *bucket,
|
||||
ev_token_bucket_init_(struct ev_token_bucket *bucket,
|
||||
const struct ev_token_bucket_cfg *cfg,
|
||||
ev_uint32_t current_tick,
|
||||
int reinitialize)
|
||||
@ -71,7 +71,7 @@ ev_token_bucket_init(struct ev_token_bucket *bucket,
|
||||
}
|
||||
|
||||
int
|
||||
ev_token_bucket_update(struct ev_token_bucket *bucket,
|
||||
ev_token_bucket_update_(struct ev_token_bucket *bucket,
|
||||
const struct ev_token_bucket_cfg *cfg,
|
||||
ev_uint32_t current_tick)
|
||||
{
|
||||
@ -117,14 +117,14 @@ bufferevent_update_buckets(struct bufferevent_private *bev)
|
||||
struct timeval now;
|
||||
unsigned tick;
|
||||
event_base_gettimeofday_cached(bev->bev.ev_base, &now);
|
||||
tick = ev_token_bucket_get_tick(&now, bev->rate_limiting->cfg);
|
||||
tick = ev_token_bucket_get_tick_(&now, bev->rate_limiting->cfg);
|
||||
if (tick != bev->rate_limiting->limit.last_updated)
|
||||
ev_token_bucket_update(&bev->rate_limiting->limit,
|
||||
ev_token_bucket_update_(&bev->rate_limiting->limit,
|
||||
bev->rate_limiting->cfg, tick);
|
||||
}
|
||||
|
||||
ev_uint32_t
|
||||
ev_token_bucket_get_tick(const struct timeval *tv,
|
||||
ev_token_bucket_get_tick_(const struct timeval *tv,
|
||||
const struct ev_token_bucket_cfg *cfg)
|
||||
{
|
||||
/* This computation uses two multiplies and a divide. We could do
|
||||
@ -235,10 +235,10 @@ bufferevent_get_rlim_max_(struct bufferevent_private *bev, int is_write)
|
||||
* particular bufferevent while suspending the whole
|
||||
* group. */
|
||||
if (is_write)
|
||||
bufferevent_suspend_write(&bev->bev,
|
||||
bufferevent_suspend_write_(&bev->bev,
|
||||
BEV_SUSPEND_BW_GROUP);
|
||||
else
|
||||
bufferevent_suspend_read(&bev->bev,
|
||||
bufferevent_suspend_read_(&bev->bev,
|
||||
BEV_SUSPEND_BW_GROUP);
|
||||
share = 0;
|
||||
} else {
|
||||
@ -281,14 +281,14 @@ bufferevent_decrement_read_buckets_(struct bufferevent_private *bev, ev_ssize_t
|
||||
if (bev->rate_limiting->cfg) {
|
||||
bev->rate_limiting->limit.read_limit -= bytes;
|
||||
if (bev->rate_limiting->limit.read_limit <= 0) {
|
||||
bufferevent_suspend_read(&bev->bev, BEV_SUSPEND_BW);
|
||||
bufferevent_suspend_read_(&bev->bev, BEV_SUSPEND_BW);
|
||||
if (event_add(&bev->rate_limiting->refill_bucket_event,
|
||||
&bev->rate_limiting->cfg->tick_timeout) < 0)
|
||||
r = -1;
|
||||
} else if (bev->read_suspended & BEV_SUSPEND_BW) {
|
||||
if (!(bev->write_suspended & BEV_SUSPEND_BW))
|
||||
event_del(&bev->rate_limiting->refill_bucket_event);
|
||||
bufferevent_unsuspend_read(&bev->bev, BEV_SUSPEND_BW);
|
||||
bufferevent_unsuspend_read_(&bev->bev, BEV_SUSPEND_BW);
|
||||
}
|
||||
}
|
||||
|
||||
@ -319,14 +319,14 @@ bufferevent_decrement_write_buckets_(struct bufferevent_private *bev, ev_ssize_t
|
||||
if (bev->rate_limiting->cfg) {
|
||||
bev->rate_limiting->limit.write_limit -= bytes;
|
||||
if (bev->rate_limiting->limit.write_limit <= 0) {
|
||||
bufferevent_suspend_write(&bev->bev, BEV_SUSPEND_BW);
|
||||
bufferevent_suspend_write_(&bev->bev, BEV_SUSPEND_BW);
|
||||
if (event_add(&bev->rate_limiting->refill_bucket_event,
|
||||
&bev->rate_limiting->cfg->tick_timeout) < 0)
|
||||
r = -1;
|
||||
} else if (bev->write_suspended & BEV_SUSPEND_BW) {
|
||||
if (!(bev->read_suspended & BEV_SUSPEND_BW))
|
||||
event_del(&bev->rate_limiting->refill_bucket_event);
|
||||
bufferevent_unsuspend_write(&bev->bev, BEV_SUSPEND_BW);
|
||||
bufferevent_unsuspend_write_(&bev->bev, BEV_SUSPEND_BW);
|
||||
}
|
||||
}
|
||||
|
||||
@ -354,15 +354,15 @@ bev_group_suspend_reading_(struct bufferevent_rate_limit_group *g)
|
||||
g->read_suspended = 1;
|
||||
g->pending_unsuspend_read = 0;
|
||||
|
||||
/* Note that in this loop we call EVLOCK_TRY_LOCK instead of BEV_LOCK,
|
||||
/* Note that in this loop we call EVLOCK_TRY_LOCK_ instead of BEV_LOCK,
|
||||
to prevent a deadlock. (Ordinarily, the group lock nests inside
|
||||
the bufferevent locks. If we are unable to lock any individual
|
||||
bufferevent, it will find out later when it looks at its limit
|
||||
and sees that its group is suspended.
|
||||
*/
|
||||
LIST_FOREACH(bev, &g->members, rate_limiting->next_in_group) {
|
||||
if (EVLOCK_TRY_LOCK(bev->lock)) {
|
||||
bufferevent_suspend_read(&bev->bev,
|
||||
if (EVLOCK_TRY_LOCK_(bev->lock)) {
|
||||
bufferevent_suspend_read_(&bev->bev,
|
||||
BEV_SUSPEND_BW_GROUP);
|
||||
EVLOCK_UNLOCK(bev->lock, 0);
|
||||
}
|
||||
@ -379,8 +379,8 @@ bev_group_suspend_writing_(struct bufferevent_rate_limit_group *g)
|
||||
g->write_suspended = 1;
|
||||
g->pending_unsuspend_write = 0;
|
||||
LIST_FOREACH(bev, &g->members, rate_limiting->next_in_group) {
|
||||
if (EVLOCK_TRY_LOCK(bev->lock)) {
|
||||
bufferevent_suspend_write(&bev->bev,
|
||||
if (EVLOCK_TRY_LOCK_(bev->lock)) {
|
||||
bufferevent_suspend_write_(&bev->bev,
|
||||
BEV_SUSPEND_BW_GROUP);
|
||||
EVLOCK_UNLOCK(bev->lock, 0);
|
||||
}
|
||||
@ -405,22 +405,22 @@ bev_refill_callback_(evutil_socket_t fd, short what, void *arg)
|
||||
|
||||
/* First, update the bucket */
|
||||
event_base_gettimeofday_cached(bev->bev.ev_base, &now);
|
||||
tick = ev_token_bucket_get_tick(&now,
|
||||
tick = ev_token_bucket_get_tick_(&now,
|
||||
bev->rate_limiting->cfg);
|
||||
ev_token_bucket_update(&bev->rate_limiting->limit,
|
||||
ev_token_bucket_update_(&bev->rate_limiting->limit,
|
||||
bev->rate_limiting->cfg,
|
||||
tick);
|
||||
|
||||
/* Now unsuspend any read/write operations as appropriate. */
|
||||
if ((bev->read_suspended & BEV_SUSPEND_BW)) {
|
||||
if (bev->rate_limiting->limit.read_limit > 0)
|
||||
bufferevent_unsuspend_read(&bev->bev, BEV_SUSPEND_BW);
|
||||
bufferevent_unsuspend_read_(&bev->bev, BEV_SUSPEND_BW);
|
||||
else
|
||||
again = 1;
|
||||
}
|
||||
if ((bev->write_suspended & BEV_SUSPEND_BW)) {
|
||||
if (bev->rate_limiting->limit.write_limit > 0)
|
||||
bufferevent_unsuspend_write(&bev->bev, BEV_SUSPEND_BW);
|
||||
bufferevent_unsuspend_write_(&bev->bev, BEV_SUSPEND_BW);
|
||||
else
|
||||
again = 1;
|
||||
}
|
||||
@ -489,8 +489,8 @@ bev_group_unsuspend_reading_(struct bufferevent_rate_limit_group *g)
|
||||
|
||||
g->read_suspended = 0;
|
||||
FOREACH_RANDOM_ORDER({
|
||||
if (EVLOCK_TRY_LOCK(bev->lock)) {
|
||||
bufferevent_unsuspend_read(&bev->bev,
|
||||
if (EVLOCK_TRY_LOCK_(bev->lock)) {
|
||||
bufferevent_unsuspend_read_(&bev->bev,
|
||||
BEV_SUSPEND_BW_GROUP);
|
||||
EVLOCK_UNLOCK(bev->lock, 0);
|
||||
} else {
|
||||
@ -508,8 +508,8 @@ bev_group_unsuspend_writing_(struct bufferevent_rate_limit_group *g)
|
||||
g->write_suspended = 0;
|
||||
|
||||
FOREACH_RANDOM_ORDER({
|
||||
if (EVLOCK_TRY_LOCK(bev->lock)) {
|
||||
bufferevent_unsuspend_write(&bev->bev,
|
||||
if (EVLOCK_TRY_LOCK_(bev->lock)) {
|
||||
bufferevent_unsuspend_write_(&bev->bev,
|
||||
BEV_SUSPEND_BW_GROUP);
|
||||
EVLOCK_UNLOCK(bev->lock, 0);
|
||||
} else {
|
||||
@ -533,8 +533,8 @@ bev_group_refill_callback_(evutil_socket_t fd, short what, void *arg)
|
||||
|
||||
LOCK_GROUP(g);
|
||||
|
||||
tick = ev_token_bucket_get_tick(&now, &g->rate_limit_cfg);
|
||||
ev_token_bucket_update(&g->rate_limit, &g->rate_limit_cfg, tick);
|
||||
tick = ev_token_bucket_get_tick_(&now, &g->rate_limit_cfg);
|
||||
ev_token_bucket_update_(&g->rate_limit, &g->rate_limit_cfg, tick);
|
||||
|
||||
if (g->pending_unsuspend_read ||
|
||||
(g->read_suspended && (g->rate_limit.read_limit >= g->min_share))) {
|
||||
@ -572,8 +572,8 @@ bufferevent_set_rate_limit(struct bufferevent *bev,
|
||||
if (bevp->rate_limiting) {
|
||||
rlim = bevp->rate_limiting;
|
||||
rlim->cfg = NULL;
|
||||
bufferevent_unsuspend_read(bev, BEV_SUSPEND_BW);
|
||||
bufferevent_unsuspend_write(bev, BEV_SUSPEND_BW);
|
||||
bufferevent_unsuspend_read_(bev, BEV_SUSPEND_BW);
|
||||
bufferevent_unsuspend_write_(bev, BEV_SUSPEND_BW);
|
||||
if (event_initialized(&rlim->refill_bucket_event))
|
||||
event_del(&rlim->refill_bucket_event);
|
||||
}
|
||||
@ -582,7 +582,7 @@ bufferevent_set_rate_limit(struct bufferevent *bev,
|
||||
}
|
||||
|
||||
event_base_gettimeofday_cached(bev->ev_base, &now);
|
||||
tick = ev_token_bucket_get_tick(&now, cfg);
|
||||
tick = ev_token_bucket_get_tick_(&now, cfg);
|
||||
|
||||
if (bevp->rate_limiting && bevp->rate_limiting->cfg == cfg) {
|
||||
/* no-op */
|
||||
@ -600,7 +600,7 @@ bufferevent_set_rate_limit(struct bufferevent *bev,
|
||||
reinit = rlim->cfg != NULL;
|
||||
|
||||
rlim->cfg = cfg;
|
||||
ev_token_bucket_init(&rlim->limit, cfg, tick, reinit);
|
||||
ev_token_bucket_init_(&rlim->limit, cfg, tick, reinit);
|
||||
|
||||
if (reinit) {
|
||||
EVUTIL_ASSERT(event_initialized(&rlim->refill_bucket_event));
|
||||
@ -610,15 +610,15 @@ bufferevent_set_rate_limit(struct bufferevent *bev,
|
||||
bev_refill_callback_, bevp);
|
||||
|
||||
if (rlim->limit.read_limit > 0) {
|
||||
bufferevent_unsuspend_read(bev, BEV_SUSPEND_BW);
|
||||
bufferevent_unsuspend_read_(bev, BEV_SUSPEND_BW);
|
||||
} else {
|
||||
bufferevent_suspend_read(bev, BEV_SUSPEND_BW);
|
||||
bufferevent_suspend_read_(bev, BEV_SUSPEND_BW);
|
||||
suspended=1;
|
||||
}
|
||||
if (rlim->limit.write_limit > 0) {
|
||||
bufferevent_unsuspend_write(bev, BEV_SUSPEND_BW);
|
||||
bufferevent_unsuspend_write_(bev, BEV_SUSPEND_BW);
|
||||
} else {
|
||||
bufferevent_suspend_write(bev, BEV_SUSPEND_BW);
|
||||
bufferevent_suspend_write_(bev, BEV_SUSPEND_BW);
|
||||
suspended = 1;
|
||||
}
|
||||
|
||||
@ -641,7 +641,7 @@ bufferevent_rate_limit_group_new(struct event_base *base,
|
||||
ev_uint32_t tick;
|
||||
|
||||
event_base_gettimeofday_cached(base, &now);
|
||||
tick = ev_token_bucket_get_tick(&now, cfg);
|
||||
tick = ev_token_bucket_get_tick_(&now, cfg);
|
||||
|
||||
g = mm_calloc(1, sizeof(struct bufferevent_rate_limit_group));
|
||||
if (!g)
|
||||
@ -649,7 +649,7 @@ bufferevent_rate_limit_group_new(struct event_base *base,
|
||||
memcpy(&g->rate_limit_cfg, cfg, sizeof(g->rate_limit_cfg));
|
||||
LIST_INIT(&g->members);
|
||||
|
||||
ev_token_bucket_init(&g->rate_limit, cfg, tick, 0);
|
||||
ev_token_bucket_init_(&g->rate_limit, cfg, tick, 0);
|
||||
|
||||
event_assign(&g->master_refill_event, base, -1, EV_PERSIST,
|
||||
bev_group_refill_callback_, g);
|
||||
@ -765,9 +765,9 @@ bufferevent_add_to_rate_limit_group(struct bufferevent *bev,
|
||||
UNLOCK_GROUP(g);
|
||||
|
||||
if (rsuspend)
|
||||
bufferevent_suspend_read(bev, BEV_SUSPEND_BW_GROUP);
|
||||
bufferevent_suspend_read_(bev, BEV_SUSPEND_BW_GROUP);
|
||||
if (wsuspend)
|
||||
bufferevent_suspend_write(bev, BEV_SUSPEND_BW_GROUP);
|
||||
bufferevent_suspend_write_(bev, BEV_SUSPEND_BW_GROUP);
|
||||
|
||||
BEV_UNLOCK(bev);
|
||||
return 0;
|
||||
@ -776,11 +776,11 @@ bufferevent_add_to_rate_limit_group(struct bufferevent *bev,
|
||||
int
|
||||
bufferevent_remove_from_rate_limit_group(struct bufferevent *bev)
|
||||
{
|
||||
return bufferevent_remove_from_rate_limit_group_internal(bev, 1);
|
||||
return bufferevent_remove_from_rate_limit_group_internal_(bev, 1);
|
||||
}
|
||||
|
||||
int
|
||||
bufferevent_remove_from_rate_limit_group_internal(struct bufferevent *bev,
|
||||
bufferevent_remove_from_rate_limit_group_internal_(struct bufferevent *bev,
|
||||
int unsuspend)
|
||||
{
|
||||
struct bufferevent_private *bevp =
|
||||
@ -796,8 +796,8 @@ bufferevent_remove_from_rate_limit_group_internal(struct bufferevent *bev,
|
||||
UNLOCK_GROUP(g);
|
||||
}
|
||||
if (unsuspend) {
|
||||
bufferevent_unsuspend_read(bev, BEV_SUSPEND_BW_GROUP);
|
||||
bufferevent_unsuspend_write(bev, BEV_SUSPEND_BW_GROUP);
|
||||
bufferevent_unsuspend_read_(bev, BEV_SUSPEND_BW_GROUP);
|
||||
bufferevent_unsuspend_write_(bev, BEV_SUSPEND_BW_GROUP);
|
||||
}
|
||||
BEV_UNLOCK(bev);
|
||||
return 0;
|
||||
@ -958,14 +958,14 @@ bufferevent_decrement_read_limit(struct bufferevent *bev, ev_ssize_t decr)
|
||||
|
||||
new_limit = (bevp->rate_limiting->limit.read_limit -= decr);
|
||||
if (old_limit > 0 && new_limit <= 0) {
|
||||
bufferevent_suspend_read(bev, BEV_SUSPEND_BW);
|
||||
bufferevent_suspend_read_(bev, BEV_SUSPEND_BW);
|
||||
if (event_add(&bevp->rate_limiting->refill_bucket_event,
|
||||
&bevp->rate_limiting->cfg->tick_timeout) < 0)
|
||||
r = -1;
|
||||
} else if (old_limit <= 0 && new_limit > 0) {
|
||||
if (!(bevp->write_suspended & BEV_SUSPEND_BW))
|
||||
event_del(&bevp->rate_limiting->refill_bucket_event);
|
||||
bufferevent_unsuspend_read(bev, BEV_SUSPEND_BW);
|
||||
bufferevent_unsuspend_read_(bev, BEV_SUSPEND_BW);
|
||||
}
|
||||
|
||||
BEV_UNLOCK(bev);
|
||||
@ -987,14 +987,14 @@ bufferevent_decrement_write_limit(struct bufferevent *bev, ev_ssize_t decr)
|
||||
|
||||
new_limit = (bevp->rate_limiting->limit.write_limit -= decr);
|
||||
if (old_limit > 0 && new_limit <= 0) {
|
||||
bufferevent_suspend_write(bev, BEV_SUSPEND_BW);
|
||||
bufferevent_suspend_write_(bev, BEV_SUSPEND_BW);
|
||||
if (event_add(&bevp->rate_limiting->refill_bucket_event,
|
||||
&bevp->rate_limiting->cfg->tick_timeout) < 0)
|
||||
r = -1;
|
||||
} else if (old_limit <= 0 && new_limit > 0) {
|
||||
if (!(bevp->read_suspended & BEV_SUSPEND_BW))
|
||||
event_del(&bevp->rate_limiting->refill_bucket_event);
|
||||
bufferevent_unsuspend_write(bev, BEV_SUSPEND_BW);
|
||||
bufferevent_unsuspend_write_(bev, BEV_SUSPEND_BW);
|
||||
}
|
||||
|
||||
BEV_UNLOCK(bev);
|
||||
|
@ -214,7 +214,7 @@ bufferevent_writecb(evutil_socket_t fd, short event, void *arg)
|
||||
goto error;
|
||||
}
|
||||
if (bufev_p->connecting) {
|
||||
int c = evutil_socket_finished_connecting(fd);
|
||||
int c = evutil_socket_finished_connecting_(fd);
|
||||
/* we need to fake the error if the connection was refused
|
||||
* immediately - usually connection to localhost on BSD */
|
||||
if (bufev_p->connection_refused) {
|
||||
@ -236,7 +236,7 @@ bufferevent_writecb(evutil_socket_t fd, short event, void *arg)
|
||||
#ifdef _WIN32
|
||||
if (BEV_IS_ASYNC(bufev)) {
|
||||
event_del(&bufev->ev_write);
|
||||
bufferevent_async_set_connected(bufev);
|
||||
bufferevent_async_set_connected_(bufev);
|
||||
bufferevent_run_eventcb_(bufev,
|
||||
BEV_EVENT_CONNECTED);
|
||||
goto done;
|
||||
@ -316,14 +316,14 @@ bufferevent_socket_new(struct event_base *base, evutil_socket_t fd,
|
||||
struct bufferevent *bufev;
|
||||
|
||||
#ifdef _WIN32
|
||||
if (base && event_base_get_iocp(base))
|
||||
return bufferevent_async_new(base, fd, options);
|
||||
if (base && event_base_get_iocp_(base))
|
||||
return bufferevent_async_new_(base, fd, options);
|
||||
#endif
|
||||
|
||||
if ((bufev_p = mm_calloc(1, sizeof(struct bufferevent_private)))== NULL)
|
||||
return NULL;
|
||||
|
||||
if (bufferevent_init_common(bufev_p, base, &bufferevent_ops_socket,
|
||||
if (bufferevent_init_common_(bufev_p, base, &bufferevent_ops_socket,
|
||||
options) < 0) {
|
||||
mm_free(bufev_p);
|
||||
return NULL;
|
||||
@ -365,7 +365,7 @@ bufferevent_socket_connect(struct bufferevent *bev,
|
||||
if (fd < 0) {
|
||||
if (!sa)
|
||||
goto done;
|
||||
fd = evutil_socket(sa->sa_family,
|
||||
fd = evutil_socket_(sa->sa_family,
|
||||
SOCK_STREAM|EVUTIL_SOCK_NONBLOCK, 0);
|
||||
if (fd < 0)
|
||||
goto done;
|
||||
@ -373,9 +373,9 @@ bufferevent_socket_connect(struct bufferevent *bev,
|
||||
}
|
||||
if (sa) {
|
||||
#ifdef _WIN32
|
||||
if (bufferevent_async_can_connect(bev)) {
|
||||
if (bufferevent_async_can_connect_(bev)) {
|
||||
bufferevent_setfd(bev, fd);
|
||||
r = bufferevent_async_connect(bev, fd, sa, socklen);
|
||||
r = bufferevent_async_connect_(bev, fd, sa, socklen);
|
||||
if (r < 0)
|
||||
goto freesock;
|
||||
bufev_p->connecting = 1;
|
||||
@ -383,7 +383,7 @@ bufferevent_socket_connect(struct bufferevent *bev,
|
||||
goto done;
|
||||
} else
|
||||
#endif
|
||||
r = evutil_socket_connect(&fd, sa, socklen);
|
||||
r = evutil_socket_connect_(&fd, sa, socklen);
|
||||
if (r < 0)
|
||||
goto freesock;
|
||||
}
|
||||
@ -438,8 +438,8 @@ bufferevent_connect_getaddrinfo_cb(int result, struct evutil_addrinfo *ai,
|
||||
int r;
|
||||
BEV_LOCK(bev);
|
||||
|
||||
bufferevent_unsuspend_write(bev, BEV_SUSPEND_LOOKUP);
|
||||
bufferevent_unsuspend_read(bev, BEV_SUSPEND_LOOKUP);
|
||||
bufferevent_unsuspend_write_(bev, BEV_SUSPEND_LOOKUP);
|
||||
bufferevent_unsuspend_read_(bev, BEV_SUSPEND_LOOKUP);
|
||||
|
||||
if (result != 0) {
|
||||
bev_p->dns_error = result;
|
||||
@ -484,18 +484,18 @@ bufferevent_socket_connect_hostname(struct bufferevent *bev,
|
||||
hint.ai_protocol = IPPROTO_TCP;
|
||||
hint.ai_socktype = SOCK_STREAM;
|
||||
|
||||
bufferevent_suspend_write(bev, BEV_SUSPEND_LOOKUP);
|
||||
bufferevent_suspend_read(bev, BEV_SUSPEND_LOOKUP);
|
||||
bufferevent_suspend_write_(bev, BEV_SUSPEND_LOOKUP);
|
||||
bufferevent_suspend_read_(bev, BEV_SUSPEND_LOOKUP);
|
||||
|
||||
bufferevent_incref(bev);
|
||||
err = evutil_getaddrinfo_async(evdns_base, hostname, portbuf,
|
||||
bufferevent_incref_(bev);
|
||||
err = evutil_getaddrinfo_async_(evdns_base, hostname, portbuf,
|
||||
&hint, bufferevent_connect_getaddrinfo_cb, bev);
|
||||
|
||||
if (err == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
bufferevent_unsuspend_write(bev, BEV_SUSPEND_LOOKUP);
|
||||
bufferevent_unsuspend_read(bev, BEV_SUSPEND_LOOKUP);
|
||||
bufferevent_unsuspend_write_(bev, BEV_SUSPEND_LOOKUP);
|
||||
bufferevent_unsuspend_read_(bev, BEV_SUSPEND_LOOKUP);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -82,20 +82,20 @@ struct event_change {
|
||||
#define EVENT_CHANGELIST_FDINFO_SIZE sizeof(int)
|
||||
|
||||
/** Set up the data fields in a changelist. */
|
||||
void event_changelist_init(struct event_changelist *changelist);
|
||||
void event_changelist_init_(struct event_changelist *changelist);
|
||||
/** Remove every change in the changelist, and make corresponding changes
|
||||
* in the event maps in the base. This function is generally used right
|
||||
* after making all the changes in the changelist. */
|
||||
void event_changelist_remove_all(struct event_changelist *changelist,
|
||||
void event_changelist_remove_all_(struct event_changelist *changelist,
|
||||
struct event_base *base);
|
||||
/** Free all memory held in a changelist. */
|
||||
void event_changelist_freemem(struct event_changelist *changelist);
|
||||
void event_changelist_freemem_(struct event_changelist *changelist);
|
||||
|
||||
/** Implementation of eventop_add that queues the event in a changelist. */
|
||||
int event_changelist_add(struct event_base *base, evutil_socket_t fd, short old, short events,
|
||||
int event_changelist_add_(struct event_base *base, evutil_socket_t fd, short old, short events,
|
||||
void *p);
|
||||
/** Implementation of eventop_del that queues the event in a changelist. */
|
||||
int event_changelist_del(struct event_base *base, evutil_socket_t fd, short old, short events,
|
||||
int event_changelist_del_(struct event_base *base, evutil_socket_t fd, short old, short events,
|
||||
void *p);
|
||||
|
||||
#endif
|
||||
|
@ -80,15 +80,15 @@ struct deferred_cb_queue {
|
||||
@param cb The function to run when the deferred_cb executes.
|
||||
@param arg The function's second argument.
|
||||
*/
|
||||
void event_deferred_cb_init(struct deferred_cb *, deferred_cb_fn, void *);
|
||||
void event_deferred_cb_init_(struct deferred_cb *, deferred_cb_fn, void *);
|
||||
/**
|
||||
Cancel a deferred_cb if it is currently scheduled in an event_base.
|
||||
*/
|
||||
void event_deferred_cb_cancel(struct deferred_cb_queue *, struct deferred_cb *);
|
||||
void event_deferred_cb_cancel_(struct deferred_cb_queue *, struct deferred_cb *);
|
||||
/**
|
||||
Activate a deferred_cb if it is not currently scheduled in an event_base.
|
||||
*/
|
||||
void event_deferred_cb_schedule(struct deferred_cb_queue *, struct deferred_cb *);
|
||||
void event_deferred_cb_schedule_(struct deferred_cb_queue *, struct deferred_cb *);
|
||||
|
||||
#define LOCK_DEFERRED_QUEUE(q) \
|
||||
EVLOCK_LOCK((q)->lock, 0)
|
||||
@ -99,8 +99,8 @@ void event_deferred_cb_schedule(struct deferred_cb_queue *, struct deferred_cb *
|
||||
}
|
||||
#endif
|
||||
|
||||
void event_deferred_cb_queue_init(struct deferred_cb_queue *);
|
||||
struct deferred_cb_queue *event_base_get_deferred_cb_queue(struct event_base *);
|
||||
void event_deferred_cb_queue_init_(struct deferred_cb_queue *);
|
||||
struct deferred_cb_queue *event_base_get_deferred_cb_queue_(struct event_base *);
|
||||
|
||||
#endif /* EVENT_INTERNAL_H_INCLUDED_ */
|
||||
|
||||
|
@ -132,7 +132,7 @@ devpoll_init(struct event_base *base)
|
||||
nfiles = rl.rlim_cur;
|
||||
|
||||
/* Initialize the kernel queue */
|
||||
if ((dpfd = evutil_open_closeonexec("/dev/poll", O_RDWR, 0)) == -1) {
|
||||
if ((dpfd = evutil_open_closeonexec_("/dev/poll", O_RDWR, 0)) == -1) {
|
||||
event_warn("open: /dev/poll");
|
||||
mm_free(devpollop);
|
||||
return (NULL);
|
||||
@ -159,7 +159,7 @@ devpoll_init(struct event_base *base)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
evsig_init(base);
|
||||
evsig_init_(base);
|
||||
|
||||
return (devpollop);
|
||||
}
|
||||
@ -217,7 +217,7 @@ devpoll_dispatch(struct event_base *base, struct timeval *tv)
|
||||
continue;
|
||||
|
||||
/* XXX(niels): not sure if this works for devpoll */
|
||||
evmap_io_active(base, events[i].fd, which);
|
||||
evmap_io_active_(base, events[i].fd, which);
|
||||
}
|
||||
|
||||
return (0);
|
||||
@ -296,7 +296,7 @@ devpoll_dealloc(struct event_base *base)
|
||||
{
|
||||
struct devpollop *devpollop = base->evbase;
|
||||
|
||||
evsig_dealloc(base);
|
||||
evsig_dealloc_(base);
|
||||
if (devpollop->events)
|
||||
mm_free(devpollop->events);
|
||||
if (devpollop->changes)
|
||||
|
16
epoll.c
16
epoll.c
@ -69,8 +69,8 @@ static void epoll_dealloc(struct event_base *);
|
||||
static const struct eventop epollops_changelist = {
|
||||
"epoll (with changelist)",
|
||||
epoll_init,
|
||||
event_changelist_add,
|
||||
event_changelist_del,
|
||||
event_changelist_add_,
|
||||
event_changelist_del_,
|
||||
epoll_dispatch,
|
||||
epoll_dealloc,
|
||||
1, /* need reinit */
|
||||
@ -146,10 +146,10 @@ epoll_init(struct event_base *base)
|
||||
|
||||
if ((base->flags & EVENT_BASE_FLAG_EPOLL_USE_CHANGELIST) != 0 ||
|
||||
((base->flags & EVENT_BASE_FLAG_IGNORE_ENV) == 0 &&
|
||||
evutil_getenv("EVENT_EPOLL_USE_CHANGELIST") != NULL))
|
||||
evutil_getenv_("EVENT_EPOLL_USE_CHANGELIST") != NULL))
|
||||
base->evsel = &epollops_changelist;
|
||||
|
||||
evsig_init(base);
|
||||
evsig_init_(base);
|
||||
|
||||
return (epollop);
|
||||
}
|
||||
@ -509,7 +509,7 @@ epoll_dispatch(struct event_base *base, struct timeval *tv)
|
||||
long timeout = -1;
|
||||
|
||||
if (tv != NULL) {
|
||||
timeout = evutil_tv_to_msec(tv);
|
||||
timeout = evutil_tv_to_msec_(tv);
|
||||
if (timeout < 0 || timeout > MAX_EPOLL_TIMEOUT_MSEC) {
|
||||
/* Linux kernels can wait forever if the timeout is
|
||||
* too big; see comment on MAX_EPOLL_TIMEOUT_MSEC. */
|
||||
@ -518,7 +518,7 @@ epoll_dispatch(struct event_base *base, struct timeval *tv)
|
||||
}
|
||||
|
||||
epoll_apply_changes(base);
|
||||
event_changelist_remove_all(&base->changelist, base);
|
||||
event_changelist_remove_all_(&base->changelist, base);
|
||||
|
||||
EVBASE_RELEASE_LOCK(base, th_base_lock);
|
||||
|
||||
@ -554,7 +554,7 @@ epoll_dispatch(struct event_base *base, struct timeval *tv)
|
||||
if (!ev)
|
||||
continue;
|
||||
|
||||
evmap_io_active(base, events[i].data.fd, ev | EV_ET);
|
||||
evmap_io_active_(base, events[i].data.fd, ev | EV_ET);
|
||||
}
|
||||
|
||||
if (res == epollop->nevents && epollop->nevents < MAX_NEVENT) {
|
||||
@ -580,7 +580,7 @@ epoll_dealloc(struct event_base *base)
|
||||
{
|
||||
struct epollop *epollop = base->evbase;
|
||||
|
||||
evsig_dealloc(base);
|
||||
evsig_dealloc_(base);
|
||||
if (epollop->events)
|
||||
mm_free(epollop->events);
|
||||
if (epollop->epfd >= 0)
|
||||
|
@ -318,9 +318,9 @@ int evbuffer_read_setup_vecs_(struct evbuffer *buf, ev_ssize_t howmuch,
|
||||
* See note in buffer_iocp's launch_write function */
|
||||
|
||||
/** Set the parent bufferevent object for buf to bev */
|
||||
void evbuffer_set_parent(struct evbuffer *buf, struct bufferevent *bev);
|
||||
void evbuffer_set_parent_(struct evbuffer *buf, struct bufferevent *bev);
|
||||
|
||||
void evbuffer_invoke_callbacks(struct evbuffer *buf);
|
||||
void evbuffer_invoke_callbacks_(struct evbuffer *buf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
56
evdns.c
56
evdns.c
@ -547,7 +547,7 @@ nameserver_probe_failed(struct nameserver *const ns) {
|
||||
char addrbuf[128];
|
||||
log(EVDNS_LOG_WARN,
|
||||
"Error from libevent when adding timer event for %s",
|
||||
evutil_format_sockaddr_port(
|
||||
evutil_format_sockaddr_port_(
|
||||
(struct sockaddr *)&ns->address,
|
||||
addrbuf, sizeof(addrbuf)));
|
||||
}
|
||||
@ -568,7 +568,7 @@ nameserver_failed(struct nameserver *const ns, const char *msg) {
|
||||
if (!ns->state) return;
|
||||
|
||||
log(EVDNS_LOG_MSG, "Nameserver %s has failed: %s",
|
||||
evutil_format_sockaddr_port(
|
||||
evutil_format_sockaddr_port_(
|
||||
(struct sockaddr *)&ns->address,
|
||||
addrbuf, sizeof(addrbuf)),
|
||||
msg);
|
||||
@ -586,7 +586,7 @@ nameserver_failed(struct nameserver *const ns, const char *msg) {
|
||||
&base->global_nameserver_probe_initial_timeout) < 0) {
|
||||
log(EVDNS_LOG_WARN,
|
||||
"Error from libevent when adding timer event for %s",
|
||||
evutil_format_sockaddr_port(
|
||||
evutil_format_sockaddr_port_(
|
||||
(struct sockaddr *)&ns->address,
|
||||
addrbuf, sizeof(addrbuf)));
|
||||
/* ???? Do more? */
|
||||
@ -622,7 +622,7 @@ nameserver_up(struct nameserver *const ns)
|
||||
ASSERT_LOCKED(ns->base);
|
||||
if (ns->state) return;
|
||||
log(EVDNS_LOG_MSG, "Nameserver %s is back up",
|
||||
evutil_format_sockaddr_port(
|
||||
evutil_format_sockaddr_port_(
|
||||
(struct sockaddr *)&ns->address,
|
||||
addrbuf, sizeof(addrbuf)));
|
||||
evtimer_del(&ns->timeout_event);
|
||||
@ -836,10 +836,10 @@ reply_schedule_callback(struct request *const req, u32 ttl, u32 err, struct repl
|
||||
d->handle = req->handle;
|
||||
}
|
||||
|
||||
event_deferred_cb_init(&d->deferred, reply_run_callback,
|
||||
event_deferred_cb_init_(&d->deferred, reply_run_callback,
|
||||
req->user_pointer);
|
||||
event_deferred_cb_schedule(
|
||||
event_base_get_deferred_cb_queue(req->base->event_base),
|
||||
event_deferred_cb_schedule_(
|
||||
event_base_get_deferred_cb_queue_(req->base->event_base),
|
||||
&d->deferred);
|
||||
}
|
||||
|
||||
@ -893,7 +893,7 @@ reply_handle(struct request *const req, u16 flags, u32 ttl, struct reply *reply)
|
||||
*/
|
||||
log(EVDNS_LOG_DEBUG, "Got a SERVERFAILED from nameserver"
|
||||
"at %s; will allow the request to time out.",
|
||||
evutil_format_sockaddr_port(
|
||||
evutil_format_sockaddr_port_(
|
||||
(struct sockaddr *)&req->ns->address,
|
||||
addrbuf, sizeof(addrbuf)));
|
||||
break;
|
||||
@ -1371,7 +1371,7 @@ nameserver_read(struct nameserver *ns) {
|
||||
(struct sockaddr*)&ns->address, 0)) {
|
||||
log(EVDNS_LOG_WARN, "Address mismatch on received "
|
||||
"DNS packet. Apparent source was %s",
|
||||
evutil_format_sockaddr_port(
|
||||
evutil_format_sockaddr_port_(
|
||||
(struct sockaddr *)&ss,
|
||||
addrbuf, sizeof(addrbuf)));
|
||||
return;
|
||||
@ -1461,7 +1461,7 @@ nameserver_write_waiting(struct nameserver *ns, char waiting) {
|
||||
if (event_add(&ns->event, NULL) < 0) {
|
||||
char addrbuf[128];
|
||||
log(EVDNS_LOG_WARN, "Error from libevent when adding event for %s",
|
||||
evutil_format_sockaddr_port(
|
||||
evutil_format_sockaddr_port_(
|
||||
(struct sockaddr *)&ns->address,
|
||||
addrbuf, sizeof(addrbuf)));
|
||||
/* ???? Do more? */
|
||||
@ -2277,7 +2277,7 @@ nameserver_send_probe(struct nameserver *const ns) {
|
||||
|
||||
ASSERT_LOCKED(ns->base);
|
||||
log(EVDNS_LOG_DEBUG, "Sending probe to %s",
|
||||
evutil_format_sockaddr_port(
|
||||
evutil_format_sockaddr_port_(
|
||||
(struct sockaddr *)&ns->address,
|
||||
addrbuf, sizeof(addrbuf)));
|
||||
handle = mm_calloc(1, sizeof(*handle));
|
||||
@ -2458,12 +2458,12 @@ evdns_nameserver_add_impl_(struct evdns_base *base, const struct sockaddr *addre
|
||||
|
||||
evtimer_assign(&ns->timeout_event, ns->base->event_base, nameserver_prod_callback, ns);
|
||||
|
||||
ns->socket = evutil_socket(address->sa_family,
|
||||
ns->socket = evutil_socket_(address->sa_family,
|
||||
SOCK_DGRAM|EVUTIL_SOCK_NONBLOCK|EVUTIL_SOCK_CLOEXEC, 0);
|
||||
if (ns->socket < 0) { err = 1; goto out1; }
|
||||
|
||||
if (base->global_outgoing_addrlen &&
|
||||
!evutil_sockaddr_is_loopback(address)) {
|
||||
!evutil_sockaddr_is_loopback_(address)) {
|
||||
if (bind(ns->socket,
|
||||
(struct sockaddr*)&base->global_outgoing_address,
|
||||
base->global_outgoing_addrlen) < 0) {
|
||||
@ -2483,7 +2483,7 @@ evdns_nameserver_add_impl_(struct evdns_base *base, const struct sockaddr *addre
|
||||
}
|
||||
|
||||
log(EVDNS_LOG_DEBUG, "Added nameserver %s",
|
||||
evutil_format_sockaddr_port(address, addrbuf, sizeof(addrbuf)));
|
||||
evutil_format_sockaddr_port_(address, addrbuf, sizeof(addrbuf)));
|
||||
|
||||
/* insert this nameserver into the list of them */
|
||||
if (!base->server_head) {
|
||||
@ -2506,7 +2506,7 @@ out1:
|
||||
event_debug_unassign(&ns->event);
|
||||
mm_free(ns);
|
||||
log(EVDNS_LOG_WARN, "Unable to add nameserver %s: error %d",
|
||||
evutil_format_sockaddr_port(address, addrbuf, sizeof(addrbuf)), err);
|
||||
evutil_format_sockaddr_port_(address, addrbuf, sizeof(addrbuf)), err);
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -2699,7 +2699,7 @@ request_new(struct evdns_base *base, struct evdns_request *handle, int type,
|
||||
strlcpy(namebuf, name, sizeof(namebuf));
|
||||
evutil_secure_rng_get_bytes(randbits, (name_len+7)/8);
|
||||
for (i = 0; i < name_len; ++i) {
|
||||
if (EVUTIL_ISALPHA(namebuf[i])) {
|
||||
if (EVUTIL_ISALPHA_(namebuf[i])) {
|
||||
if ((randbits[i >> 3] & (1<<(i & 7))))
|
||||
namebuf[i] |= 0x20;
|
||||
else
|
||||
@ -3532,7 +3532,7 @@ evdns_base_resolv_conf_parse_impl(struct evdns_base *base, int flags, const char
|
||||
mm_free(fname);
|
||||
}
|
||||
|
||||
if ((err = evutil_read_file(filename, &resolv, &n, 0)) < 0) {
|
||||
if ((err = evutil_read_file_(filename, &resolv, &n, 0)) < 0) {
|
||||
if (err == -1) {
|
||||
/* No file. */
|
||||
evdns_resolv_set_defaults(base, flags);
|
||||
@ -3619,7 +3619,7 @@ load_nameservers_with_getnetworkparams(struct evdns_base *base)
|
||||
GetNetworkParams_fn_t fn;
|
||||
|
||||
ASSERT_LOCKED(base);
|
||||
if (!(handle = evutil_load_windows_system_library(
|
||||
if (!(handle = evutil_load_windows_system_library_(
|
||||
TEXT("iphlpapi.dll")))) {
|
||||
log(EVDNS_LOG_WARN, "Could not open iphlpapi.dll");
|
||||
status = -1;
|
||||
@ -3819,7 +3819,7 @@ evdns_base_new(struct event_base *event_base, int initialize_nameservers)
|
||||
/* Give the evutil library a hook into its evdns-enabled
|
||||
* functionality. We can't just call evdns_getaddrinfo directly or
|
||||
* else libevent-core will depend on libevent-extras. */
|
||||
evutil_set_evdns_getaddrinfo_fn(evdns_getaddrinfo);
|
||||
evutil_set_evdns_getaddrinfo_fn_(evdns_getaddrinfo);
|
||||
|
||||
base = mm_malloc(sizeof(struct evdns_base));
|
||||
if (base == NULL)
|
||||
@ -4057,7 +4057,7 @@ evdns_base_load_hosts_impl(struct evdns_base *base, const char *hosts_fname)
|
||||
ASSERT_LOCKED(base);
|
||||
|
||||
if (hosts_fname == NULL ||
|
||||
(err = evutil_read_file(hosts_fname, &str, &len, 0)) < 0) {
|
||||
(err = evutil_read_file_(hosts_fname, &str, &len, 0)) < 0) {
|
||||
char tmp[64];
|
||||
strlcpy(tmp, "127.0.0.1 localhost", sizeof(tmp));
|
||||
evdns_base_parse_hosts_line(base, tmp);
|
||||
@ -4376,7 +4376,7 @@ evdns_getaddrinfo_gotresolve(int result, char type, int count,
|
||||
for (i=0; i < count; ++i) {
|
||||
struct evutil_addrinfo *ai;
|
||||
memcpy(addrp, ((char*)addresses)+i*addrlen, addrlen);
|
||||
ai = evutil_new_addrinfo(sa, socklen, &data->hints);
|
||||
ai = evutil_new_addrinfo_(sa, socklen, &data->hints);
|
||||
if (!ai) {
|
||||
if (other_req->r) {
|
||||
evdns_cancel_request(NULL, other_req->r);
|
||||
@ -4389,7 +4389,7 @@ evdns_getaddrinfo_gotresolve(int result, char type, int count,
|
||||
free_getaddrinfo_request(data);
|
||||
return;
|
||||
}
|
||||
res = evutil_addrinfo_append(res, ai);
|
||||
res = evutil_addrinfo_append_(res, ai);
|
||||
}
|
||||
|
||||
if (other_req->r) {
|
||||
@ -4403,10 +4403,10 @@ evdns_getaddrinfo_gotresolve(int result, char type, int count,
|
||||
* results (if any) and return them. */
|
||||
if (data->pending_result) {
|
||||
if (req->type == DNS_IPv4_A)
|
||||
res = evutil_addrinfo_append(res,
|
||||
res = evutil_addrinfo_append_(res,
|
||||
data->pending_result);
|
||||
else
|
||||
res = evutil_addrinfo_append(
|
||||
res = evutil_addrinfo_append_(
|
||||
data->pending_result, res);
|
||||
data->pending_result = NULL;
|
||||
}
|
||||
@ -4456,13 +4456,13 @@ evdns_getaddrinfo_fromhosts(struct evdns_base *base,
|
||||
if ((e->addr.sa.sa_family == AF_INET && f == PF_INET6) ||
|
||||
(e->addr.sa.sa_family == AF_INET6 && f == PF_INET))
|
||||
continue;
|
||||
ai_new = evutil_new_addrinfo(&e->addr.sa, e->addrlen, hints);
|
||||
ai_new = evutil_new_addrinfo_(&e->addr.sa, e->addrlen, hints);
|
||||
if (!ai_new) {
|
||||
n_found = 0;
|
||||
goto out;
|
||||
}
|
||||
sockaddr_setport(ai_new->ai_addr, port);
|
||||
ai = evutil_addrinfo_append(ai, ai_new);
|
||||
ai = evutil_addrinfo_append_(ai, ai_new);
|
||||
}
|
||||
EVDNS_UNLOCK(base);
|
||||
out:
|
||||
@ -4517,14 +4517,14 @@ evdns_getaddrinfo(struct evdns_base *dns_base,
|
||||
hints.ai_family = PF_UNSPEC;
|
||||
}
|
||||
|
||||
evutil_adjust_hints_for_addrconfig(&hints);
|
||||
evutil_adjust_hints_for_addrconfig_(&hints);
|
||||
|
||||
/* Now try to see if we _can_ answer immediately. */
|
||||
/* (It would be nice to do this by calling getaddrinfo directly, with
|
||||
* AI_NUMERICHOST, on plaforms that have it, but we can't: there isn't
|
||||
* a reliable way to distinguish the "that wasn't a numeric host!" case
|
||||
* from any other EAI_NONAME cases.) */
|
||||
err = evutil_getaddrinfo_common(nodename, servname, &hints, &res, &port);
|
||||
err = evutil_getaddrinfo_common_(nodename, servname, &hints, &res, &port);
|
||||
if (err != EVUTIL_EAI_NEED_RESOLVE) {
|
||||
cb(err, res, arg);
|
||||
return NULL;
|
||||
|
@ -348,11 +348,11 @@ int evsig_set_handler_(struct event_base *base, int evsignal,
|
||||
int evsig_restore_handler_(struct event_base *base, int evsignal);
|
||||
|
||||
|
||||
void event_active_nolock(struct event *ev, int res, short count);
|
||||
void event_active_nolock_(struct event *ev, int res, short count);
|
||||
|
||||
/* FIXME document. */
|
||||
void event_base_add_virtual(struct event_base *base);
|
||||
void event_base_del_virtual(struct event_base *base);
|
||||
void event_base_add_virtual_(struct event_base *base);
|
||||
void event_base_del_virtual_(struct event_base *base);
|
||||
|
||||
/** For debugging: unless assertions are disabled, verify the referential
|
||||
integrity of the internal data structures of 'base'. This operation can
|
||||
@ -360,7 +360,7 @@ void event_base_del_virtual(struct event_base *base);
|
||||
|
||||
Returns on success; aborts on failure.
|
||||
*/
|
||||
void event_base_assert_ok(struct event_base *base);
|
||||
void event_base_assert_ok_(struct event_base *base);
|
||||
|
||||
/* Callback type for event_base_foreach_event. */
|
||||
typedef int (*event_base_foreach_event_cb)(struct event_base *base, struct event *, void *);
|
||||
|
112
event.c
112
event.c
@ -502,10 +502,10 @@ event_is_method_disabled(const char *name)
|
||||
|
||||
evutil_snprintf(environment, sizeof(environment), "EVENT_NO%s", name);
|
||||
for (i = 8; environment[i] != '\0'; ++i)
|
||||
environment[i] = EVUTIL_TOUPPER(environment[i]);
|
||||
/* Note that evutil_getenv() ignores the environment entirely if
|
||||
environment[i] = EVUTIL_TOUPPER_(environment[i]);
|
||||
/* Note that evutil_getenv_() ignores the environment entirely if
|
||||
* we're setuid */
|
||||
return (evutil_getenv(environment) != NULL);
|
||||
return (evutil_getenv_(environment) != NULL);
|
||||
}
|
||||
|
||||
int
|
||||
@ -515,7 +515,7 @@ event_base_get_features(const struct event_base *base)
|
||||
}
|
||||
|
||||
void
|
||||
event_deferred_cb_queue_init(struct deferred_cb_queue *cb)
|
||||
event_deferred_cb_queue_init_(struct deferred_cb_queue *cb)
|
||||
{
|
||||
memset(cb, 0, sizeof(struct deferred_cb_queue));
|
||||
TAILQ_INIT(&cb->deferred_cb_list);
|
||||
@ -531,7 +531,7 @@ notify_base_cbq_callback(struct deferred_cb_queue *cb, void *baseptr)
|
||||
}
|
||||
|
||||
struct deferred_cb_queue *
|
||||
event_base_get_deferred_cb_queue(struct event_base *base)
|
||||
event_base_get_deferred_cb_queue_(struct event_base *base)
|
||||
{
|
||||
return base ? &base->defer_queue : NULL;
|
||||
}
|
||||
@ -587,23 +587,23 @@ event_base_new_with_config(const struct event_config *cfg)
|
||||
detect_monotonic();
|
||||
gettime(base, &base->event_tv);
|
||||
|
||||
min_heap_ctor(&base->timeheap);
|
||||
min_heap_ctor_(&base->timeheap);
|
||||
|
||||
base->sig.ev_signal_pair[0] = -1;
|
||||
base->sig.ev_signal_pair[1] = -1;
|
||||
base->th_notify_fd[0] = -1;
|
||||
base->th_notify_fd[1] = -1;
|
||||
|
||||
event_deferred_cb_queue_init(&base->defer_queue);
|
||||
event_deferred_cb_queue_init_(&base->defer_queue);
|
||||
base->defer_queue.base = base;
|
||||
base->defer_queue.notify_fn = notify_base_cbq_callback;
|
||||
base->defer_queue.notify_arg = base;
|
||||
if (cfg)
|
||||
base->flags = cfg->flags;
|
||||
|
||||
evmap_io_initmap(&base->io);
|
||||
evmap_signal_initmap(&base->sigmap);
|
||||
event_changelist_init(&base->changelist);
|
||||
evmap_io_initmap_(&base->io);
|
||||
evmap_signal_initmap_(&base->sigmap);
|
||||
event_changelist_init_(&base->changelist);
|
||||
|
||||
base->evbase = NULL;
|
||||
|
||||
@ -657,7 +657,7 @@ event_base_new_with_config(const struct event_config *cfg)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (evutil_getenv("EVENT_SHOW_METHOD"))
|
||||
if (evutil_getenv_("EVENT_SHOW_METHOD"))
|
||||
event_msgx("libevent using: %s", base->evsel->name);
|
||||
|
||||
/* allocate a single active event queue */
|
||||
@ -687,19 +687,19 @@ event_base_new_with_config(const struct event_config *cfg)
|
||||
|
||||
#ifdef _WIN32
|
||||
if (cfg && (cfg->flags & EVENT_BASE_FLAG_STARTUP_IOCP))
|
||||
event_base_start_iocp(base, cfg->n_cpus_hint);
|
||||
event_base_start_iocp_(base, cfg->n_cpus_hint);
|
||||
#endif
|
||||
|
||||
return (base);
|
||||
}
|
||||
|
||||
int
|
||||
event_base_start_iocp(struct event_base *base, int n_cpus)
|
||||
event_base_start_iocp_(struct event_base *base, int n_cpus)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (base->iocp)
|
||||
return 0;
|
||||
base->iocp = event_iocp_port_launch(n_cpus);
|
||||
base->iocp = event_iocp_port_launch_(n_cpus);
|
||||
if (!base->iocp) {
|
||||
event_warnx("%s: Couldn't launch IOCP", __func__);
|
||||
return -1;
|
||||
@ -711,14 +711,14 @@ event_base_start_iocp(struct event_base *base, int n_cpus)
|
||||
}
|
||||
|
||||
void
|
||||
event_base_stop_iocp(struct event_base *base)
|
||||
event_base_stop_iocp_(struct event_base *base)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
int rv;
|
||||
|
||||
if (!base->iocp)
|
||||
return;
|
||||
rv = event_iocp_shutdown(base->iocp, -1);
|
||||
rv = event_iocp_shutdown_(base->iocp, -1);
|
||||
EVUTIL_ASSERT(rv >= 0);
|
||||
base->iocp = NULL;
|
||||
#endif
|
||||
@ -747,7 +747,7 @@ event_base_free(struct event_base *base)
|
||||
/* XXX(niels) - check for internal events first */
|
||||
|
||||
#ifdef _WIN32
|
||||
event_base_stop_iocp(base);
|
||||
event_base_stop_iocp_(base);
|
||||
#endif
|
||||
|
||||
/* threading fds if we have them */
|
||||
@ -762,9 +762,9 @@ event_base_free(struct event_base *base)
|
||||
}
|
||||
|
||||
/* Delete all non-internal events. */
|
||||
evmap_delete_all(base);
|
||||
evmap_delete_all_(base);
|
||||
|
||||
while ((ev = min_heap_top(&base->timeheap)) != NULL) {
|
||||
while ((ev = min_heap_top_(&base->timeheap)) != NULL) {
|
||||
event_del(ev);
|
||||
++n_deleted;
|
||||
}
|
||||
@ -808,14 +808,14 @@ event_base_free(struct event_base *base)
|
||||
for (i = 0; i < base->nactivequeues; ++i)
|
||||
EVUTIL_ASSERT(TAILQ_EMPTY(&base->activequeues[i]));
|
||||
|
||||
EVUTIL_ASSERT(min_heap_empty(&base->timeheap));
|
||||
min_heap_dtor(&base->timeheap);
|
||||
EVUTIL_ASSERT(min_heap_empty_(&base->timeheap));
|
||||
min_heap_dtor_(&base->timeheap);
|
||||
|
||||
mm_free(base->activequeues);
|
||||
|
||||
evmap_io_clear(&base->io);
|
||||
evmap_signal_clear(&base->sigmap);
|
||||
event_changelist_freemem(&base->changelist);
|
||||
evmap_io_clear_(&base->io);
|
||||
evmap_signal_clear_(&base->sigmap);
|
||||
event_changelist_freemem_(&base->changelist);
|
||||
|
||||
EVTHREAD_FREE_LOCK(base->th_base_lock, EVTHREAD_LOCKTYPE_RECURSIVE);
|
||||
EVTHREAD_FREE_COND(base->current_event_cond);
|
||||
@ -923,16 +923,16 @@ event_reinit(struct event_base *base)
|
||||
|
||||
/* Empty out the changelist (if any): we are starting from a
|
||||
* blank slate. */
|
||||
event_changelist_freemem(&base->changelist);
|
||||
event_changelist_freemem_(&base->changelist);
|
||||
|
||||
/* Tell the event maps to re-inform the backend about all
|
||||
* pending events. This will make the signal notification
|
||||
* event get re-created if necessary. */
|
||||
if (evmap_reinit(base) < 0)
|
||||
if (evmap_reinit_(base) < 0)
|
||||
res = -1;
|
||||
} else {
|
||||
if (had_signal_added)
|
||||
res = evsig_init(base);
|
||||
res = evsig_init_(base);
|
||||
}
|
||||
|
||||
/* If we were notifiable before, and nothing just exploded, become
|
||||
@ -1265,7 +1265,7 @@ common_timeout_callback(evutil_socket_t fd, short what, void *arg)
|
||||
(ev->ev_timeout.tv_usec&MICROSECONDS_MASK) > now.tv_usec))
|
||||
break;
|
||||
event_del_internal(ev);
|
||||
event_active_nolock(ev, EV_TIMEOUT, 1);
|
||||
event_active_nolock_(ev, EV_TIMEOUT, 1);
|
||||
}
|
||||
if (ev)
|
||||
common_timeout_schedule(ctl, &now, ev);
|
||||
@ -1680,7 +1680,7 @@ event_base_loop(struct event_base *base, int flags)
|
||||
clear_time_cache(base);
|
||||
|
||||
if (base->sig.ev_signal_added && base->sig.ev_n_signals_added)
|
||||
evsig_set_base(base);
|
||||
evsig_set_base_(base);
|
||||
|
||||
done = 0;
|
||||
|
||||
@ -1874,7 +1874,7 @@ event_assign(struct event *ev, struct event_base *base, evutil_socket_t fd, shor
|
||||
}
|
||||
}
|
||||
|
||||
min_heap_elem_init(ev);
|
||||
min_heap_elem_init_(ev);
|
||||
|
||||
if (base != NULL) {
|
||||
/* by default, we put new events into the middle priority */
|
||||
@ -2165,8 +2165,8 @@ event_add_internal(struct event *ev, const struct timeval *tv,
|
||||
* failure on any step, we should not change any state.
|
||||
*/
|
||||
if (tv != NULL && !(ev->ev_flags & EVLIST_TIMEOUT)) {
|
||||
if (min_heap_reserve(&base->timeheap,
|
||||
1 + min_heap_size(&base->timeheap)) == -1)
|
||||
if (min_heap_reserve_(&base->timeheap,
|
||||
1 + min_heap_size_(&base->timeheap)) == -1)
|
||||
return (-1); /* ENOMEM == errno */
|
||||
}
|
||||
|
||||
@ -2185,9 +2185,9 @@ event_add_internal(struct event *ev, const struct timeval *tv,
|
||||
if ((ev->ev_events & (EV_READ|EV_WRITE|EV_SIGNAL)) &&
|
||||
!(ev->ev_flags & (EVLIST_INSERTED|EVLIST_ACTIVE))) {
|
||||
if (ev->ev_events & (EV_READ|EV_WRITE))
|
||||
res = evmap_io_add(base, ev->ev_fd, ev);
|
||||
res = evmap_io_add_(base, ev->ev_fd, ev);
|
||||
else if (ev->ev_events & EV_SIGNAL)
|
||||
res = evmap_signal_add(base, (int)ev->ev_fd, ev);
|
||||
res = evmap_signal_add_(base, (int)ev->ev_fd, ev);
|
||||
if (res != -1)
|
||||
event_queue_insert_inserted(base, ev);
|
||||
if (res == 1) {
|
||||
@ -2264,7 +2264,7 @@ event_add_internal(struct event *ev, const struct timeval *tv,
|
||||
* was before: if so, we will need to tell the main
|
||||
* thread to wake up earlier than it would
|
||||
* otherwise. */
|
||||
if (min_heap_elt_is_top(ev))
|
||||
if (min_heap_elt_is_top_(ev))
|
||||
notify = 1;
|
||||
}
|
||||
}
|
||||
@ -2353,9 +2353,9 @@ event_del_internal(struct event *ev)
|
||||
if (ev->ev_flags & EVLIST_INSERTED) {
|
||||
event_queue_remove_inserted(base, ev);
|
||||
if (ev->ev_events & (EV_READ|EV_WRITE))
|
||||
res = evmap_io_del(base, ev->ev_fd, ev);
|
||||
res = evmap_io_del_(base, ev->ev_fd, ev);
|
||||
else
|
||||
res = evmap_signal_del(base, (int)ev->ev_fd, ev);
|
||||
res = evmap_signal_del_(base, (int)ev->ev_fd, ev);
|
||||
if (res == 1) {
|
||||
/* evmap says we need to notify the main thread. */
|
||||
notify = 1;
|
||||
@ -2384,14 +2384,14 @@ event_active(struct event *ev, int res, short ncalls)
|
||||
|
||||
event_debug_assert_is_setup_(ev);
|
||||
|
||||
event_active_nolock(ev, res, ncalls);
|
||||
event_active_nolock_(ev, res, ncalls);
|
||||
|
||||
EVBASE_RELEASE_LOCK(ev->ev_base, th_base_lock);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
event_active_nolock(struct event *ev, int res, short ncalls)
|
||||
event_active_nolock_(struct event *ev, int res, short ncalls)
|
||||
{
|
||||
struct event_base *base;
|
||||
|
||||
@ -2429,7 +2429,7 @@ event_active_nolock(struct event *ev, int res, short ncalls)
|
||||
}
|
||||
|
||||
void
|
||||
event_deferred_cb_init(struct deferred_cb *cb, deferred_cb_fn fn, void *arg)
|
||||
event_deferred_cb_init_(struct deferred_cb *cb, deferred_cb_fn fn, void *arg)
|
||||
{
|
||||
memset(cb, 0, sizeof(struct deferred_cb));
|
||||
cb->cb = fn;
|
||||
@ -2437,7 +2437,7 @@ event_deferred_cb_init(struct deferred_cb *cb, deferred_cb_fn fn, void *arg)
|
||||
}
|
||||
|
||||
void
|
||||
event_deferred_cb_cancel(struct deferred_cb_queue *queue,
|
||||
event_deferred_cb_cancel_(struct deferred_cb_queue *queue,
|
||||
struct deferred_cb *cb)
|
||||
{
|
||||
if (!queue) {
|
||||
@ -2457,7 +2457,7 @@ event_deferred_cb_cancel(struct deferred_cb_queue *queue,
|
||||
}
|
||||
|
||||
void
|
||||
event_deferred_cb_schedule(struct deferred_cb_queue *queue,
|
||||
event_deferred_cb_schedule_(struct deferred_cb_queue *queue,
|
||||
struct deferred_cb *cb)
|
||||
{
|
||||
if (!queue) {
|
||||
@ -2487,7 +2487,7 @@ timeout_next(struct event_base *base, struct timeval **tv_p)
|
||||
struct timeval *tv = *tv_p;
|
||||
int res = 0;
|
||||
|
||||
ev = min_heap_top(&base->timeheap);
|
||||
ev = min_heap_top_(&base->timeheap);
|
||||
|
||||
if (ev == NULL) {
|
||||
/* if no time-based events are active wait for I/O */
|
||||
@ -2581,13 +2581,13 @@ timeout_process(struct event_base *base)
|
||||
struct timeval now;
|
||||
struct event *ev;
|
||||
|
||||
if (min_heap_empty(&base->timeheap)) {
|
||||
if (min_heap_empty_(&base->timeheap)) {
|
||||
return;
|
||||
}
|
||||
|
||||
gettime(base, &now);
|
||||
|
||||
while ((ev = min_heap_top(&base->timeheap))) {
|
||||
while ((ev = min_heap_top_(&base->timeheap))) {
|
||||
if (evutil_timercmp(&ev->ev_timeout, &now, >))
|
||||
break;
|
||||
|
||||
@ -2596,7 +2596,7 @@ timeout_process(struct event_base *base)
|
||||
|
||||
event_debug(("timeout_process: event: %p, call %p",
|
||||
ev, ev->ev_callback));
|
||||
event_active_nolock(ev, EV_TIMEOUT, 1);
|
||||
event_active_nolock_(ev, EV_TIMEOUT, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2657,7 +2657,7 @@ event_queue_remove_timeout(struct event_base *base, struct event *ev)
|
||||
TAILQ_REMOVE(&ctl->events, ev,
|
||||
ev_timeout_pos.ev_next_with_common_timeout);
|
||||
} else {
|
||||
min_heap_erase(&base->timeheap, ev);
|
||||
min_heap_erase_(&base->timeheap, ev);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2677,7 +2677,7 @@ event_queue_reinsert_timeout(struct event_base *base, struct event *ev)
|
||||
ev_timeout_pos.ev_next_with_common_timeout);
|
||||
insert_common_timeout_inorder(ctl, ev);
|
||||
} else {
|
||||
min_heap_adjust(&base->timeheap, ev);
|
||||
min_heap_adjust_(&base->timeheap, ev);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2767,7 +2767,7 @@ event_queue_insert_timeout(struct event_base *base, struct event *ev)
|
||||
get_common_timeout_list(base, &ev->ev_timeout);
|
||||
insert_common_timeout_inorder(ctl, ev);
|
||||
} else {
|
||||
min_heap_push(&base->timeheap, ev);
|
||||
min_heap_push_(&base->timeheap, ev);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2948,13 +2948,13 @@ evthread_make_base_notifiable(struct event_base *base)
|
||||
return 0;
|
||||
}
|
||||
|
||||
base->th_notify_fd[0] = evutil_eventfd(0,
|
||||
base->th_notify_fd[0] = evutil_eventfd_(0,
|
||||
EVUTIL_EFD_CLOEXEC|EVUTIL_EFD_NONBLOCK);
|
||||
if (base->th_notify_fd[0] >= 0) {
|
||||
base->th_notify_fd[1] = -1;
|
||||
notify = evthread_notify_base_eventfd;
|
||||
cb = evthread_notify_drain_eventfd;
|
||||
} else if (evutil_make_internal_pipe(base->th_notify_fd) == 0) {
|
||||
} else if (evutil_make_internal_pipe_(base->th_notify_fd) == 0) {
|
||||
notify = evthread_notify_base_default;
|
||||
cb = evthread_notify_drain_default;
|
||||
} else {
|
||||
@ -2983,7 +2983,7 @@ event_base_foreach_event_(struct event_base *base,
|
||||
struct event *ev;
|
||||
|
||||
/* Start out with all the EVLIST_INSERTED events. */
|
||||
if ((r = evmap_foreach_event(base, fn, arg)))
|
||||
if ((r = evmap_foreach_event_(base, fn, arg)))
|
||||
return r;
|
||||
|
||||
/* Okay, now we deal with those events that have timeouts and are in
|
||||
@ -3096,7 +3096,7 @@ event_base_dump_events(struct event_base *base, FILE *output)
|
||||
}
|
||||
|
||||
void
|
||||
event_base_add_virtual(struct event_base *base)
|
||||
event_base_add_virtual_(struct event_base *base)
|
||||
{
|
||||
EVBASE_ACQUIRE_LOCK(base, th_base_lock);
|
||||
base->virtual_event_count++;
|
||||
@ -3104,7 +3104,7 @@ event_base_add_virtual(struct event_base *base)
|
||||
}
|
||||
|
||||
void
|
||||
event_base_del_virtual(struct event_base *base)
|
||||
event_base_del_virtual_(struct event_base *base)
|
||||
{
|
||||
EVBASE_ACQUIRE_LOCK(base, th_base_lock);
|
||||
EVUTIL_ASSERT(base->virtual_event_count > 0);
|
||||
@ -3130,13 +3130,13 @@ event_global_setup_locks_(const int enable_locks)
|
||||
#endif
|
||||
|
||||
void
|
||||
event_base_assert_ok(struct event_base *base)
|
||||
event_base_assert_ok_(struct event_base *base)
|
||||
{
|
||||
int i;
|
||||
EVBASE_ACQUIRE_LOCK(base, th_base_lock);
|
||||
|
||||
/* First do checks on the per-fd and per-signal lists */
|
||||
evmap_check_integrity(base);
|
||||
evmap_check_integrity_(base);
|
||||
|
||||
/* Check the heap property */
|
||||
for (i = 1; i < (int)base->timeheap.n; ++i) {
|
||||
|
14
event_iocp.c
14
event_iocp.c
@ -46,7 +46,7 @@
|
||||
#define NOTIFICATION_KEY ((ULONG_PTR)-1)
|
||||
|
||||
void
|
||||
event_overlapped_init(struct event_overlapped *o, iocp_callback cb)
|
||||
event_overlapped_init_(struct event_overlapped *o, iocp_callback cb)
|
||||
{
|
||||
memset(o, 0, sizeof(struct event_overlapped));
|
||||
o->cb = cb;
|
||||
@ -99,7 +99,7 @@ loop(void *_port)
|
||||
}
|
||||
|
||||
int
|
||||
event_iocp_port_associate(struct event_iocp_port *port, evutil_socket_t fd,
|
||||
event_iocp_port_associate_(struct event_iocp_port *port, evutil_socket_t fd,
|
||||
ev_uintptr_t key)
|
||||
{
|
||||
HANDLE h;
|
||||
@ -162,7 +162,7 @@ static struct win32_extension_fns the_extension_fns;
|
||||
static int extension_fns_initialized = 0;
|
||||
|
||||
const struct win32_extension_fns *
|
||||
event_get_win32_extension_fns(void)
|
||||
event_get_win32_extension_fns_(void)
|
||||
{
|
||||
return &the_extension_fns;
|
||||
}
|
||||
@ -170,7 +170,7 @@ event_get_win32_extension_fns(void)
|
||||
#define N_CPUS_DEFAULT 2
|
||||
|
||||
struct event_iocp_port *
|
||||
event_iocp_port_launch(int n_cpus)
|
||||
event_iocp_port_launch_(int n_cpus)
|
||||
{
|
||||
struct event_iocp_port *port;
|
||||
int i;
|
||||
@ -244,7 +244,7 @@ event_iocp_notify_all(struct event_iocp_port *port)
|
||||
}
|
||||
|
||||
int
|
||||
event_iocp_shutdown(struct event_iocp_port *port, long waitMsec)
|
||||
event_iocp_shutdown_(struct event_iocp_port *port, long waitMsec)
|
||||
{
|
||||
DWORD ms = INFINITE;
|
||||
int n;
|
||||
@ -270,7 +270,7 @@ event_iocp_shutdown(struct event_iocp_port *port, long waitMsec)
|
||||
}
|
||||
|
||||
int
|
||||
event_iocp_activate_overlapped(
|
||||
event_iocp_activate_overlapped_(
|
||||
struct event_iocp_port *port, struct event_overlapped *o,
|
||||
ev_uintptr_t key, ev_uint32_t n)
|
||||
{
|
||||
@ -281,7 +281,7 @@ event_iocp_activate_overlapped(
|
||||
}
|
||||
|
||||
struct event_iocp_port *
|
||||
event_base_get_iocp(struct event_base *base)
|
||||
event_base_get_iocp_(struct event_base *base)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return base->iocp;
|
||||
|
@ -39,15 +39,15 @@ struct event;
|
||||
|
||||
/** Initialize an event_map for use.
|
||||
*/
|
||||
void evmap_io_initmap(struct event_io_map* ctx);
|
||||
void evmap_signal_initmap(struct event_signal_map* ctx);
|
||||
void evmap_io_initmap_(struct event_io_map* ctx);
|
||||
void evmap_signal_initmap_(struct event_signal_map* ctx);
|
||||
|
||||
/** Remove all entries from an event_map.
|
||||
|
||||
@param ctx the map to clear.
|
||||
*/
|
||||
void evmap_io_clear(struct event_io_map* ctx);
|
||||
void evmap_signal_clear(struct event_signal_map* ctx);
|
||||
void evmap_io_clear_(struct event_io_map* ctx);
|
||||
void evmap_signal_clear_(struct event_signal_map* ctx);
|
||||
|
||||
/** Add an IO event (some combination of EV_READ or EV_WRITE) to an
|
||||
event_base's list of events on a given file descriptor, and tell the
|
||||
@ -59,7 +59,7 @@ void evmap_signal_clear(struct event_signal_map* ctx);
|
||||
@param fd the file descriptor corresponding to ev.
|
||||
@param ev the event to add.
|
||||
*/
|
||||
int evmap_io_add(struct event_base *base, evutil_socket_t fd, struct event *ev);
|
||||
int evmap_io_add_(struct event_base *base, evutil_socket_t fd, struct event *ev);
|
||||
/** Remove an IO event (some combination of EV_READ or EV_WRITE) to an
|
||||
event_base's list of events on a given file descriptor, and tell the
|
||||
underlying eventops about the fd if its state has changed.
|
||||
@ -68,49 +68,49 @@ int evmap_io_add(struct event_base *base, evutil_socket_t fd, struct event *ev);
|
||||
@param fd the file descriptor corresponding to ev.
|
||||
@param ev the event to remove.
|
||||
*/
|
||||
int evmap_io_del(struct event_base *base, evutil_socket_t fd, struct event *ev);
|
||||
int evmap_io_del_(struct event_base *base, evutil_socket_t fd, struct event *ev);
|
||||
/** Active the set of events waiting on an event_base for a given fd.
|
||||
|
||||
@param base the event_base to operate on.
|
||||
@param fd the file descriptor that has become active.
|
||||
@param events a bitmask of EV_READ|EV_WRITE|EV_ET.
|
||||
*/
|
||||
void evmap_io_active(struct event_base *base, evutil_socket_t fd, short events);
|
||||
void evmap_io_active_(struct event_base *base, evutil_socket_t fd, short events);
|
||||
|
||||
|
||||
/* These functions behave in the same way as evmap_io_*, except they work on
|
||||
* signals rather than fds. signals use a linear map everywhere; fds use
|
||||
* either a linear map or a hashtable. */
|
||||
int evmap_signal_add(struct event_base *base, int signum, struct event *ev);
|
||||
int evmap_signal_del(struct event_base *base, int signum, struct event *ev);
|
||||
void evmap_signal_active(struct event_base *base, evutil_socket_t signum, int ncalls);
|
||||
int evmap_signal_add_(struct event_base *base, int signum, struct event *ev);
|
||||
int evmap_signal_del_(struct event_base *base, int signum, struct event *ev);
|
||||
void evmap_signal_active_(struct event_base *base, evutil_socket_t signum, int ncalls);
|
||||
|
||||
/* Return the fdinfo object associated with a given fd. If the fd has no
|
||||
* events associated with it, the result may be NULL.
|
||||
*/
|
||||
void *evmap_io_get_fdinfo(struct event_io_map *ctx, evutil_socket_t fd);
|
||||
void *evmap_io_get_fdinfo_(struct event_io_map *ctx, evutil_socket_t fd);
|
||||
|
||||
/* Helper for event_reinit(): Tell the backend to re-add every fd and signal
|
||||
* for which we have a pending event.
|
||||
*/
|
||||
int evmap_reinit(struct event_base *base);
|
||||
int evmap_reinit_(struct event_base *base);
|
||||
|
||||
/* Helper for event_base_free(): Call event_del() on every pending fd and
|
||||
* signal event.
|
||||
*/
|
||||
void evmap_delete_all(struct event_base *base);
|
||||
void evmap_delete_all_(struct event_base *base);
|
||||
|
||||
/* Helper for event_base_assert_ok(): Check referential integrity of the
|
||||
/* Helper for event_base_assert_ok_(): Check referential integrity of the
|
||||
* evmaps.
|
||||
*/
|
||||
void evmap_check_integrity(struct event_base *base);
|
||||
void evmap_check_integrity_(struct event_base *base);
|
||||
|
||||
/* Helper: Call fn on every fd or signal event, passing as its arguments the
|
||||
* provided event_base, the event, and arg. If fn returns 0, process the next
|
||||
* event. If it returns any other value, return that value and process no
|
||||
* more events.
|
||||
*/
|
||||
int evmap_foreach_event(struct event_base *base,
|
||||
int evmap_foreach_event_(struct event_base *base,
|
||||
event_base_foreach_event_cb fn,
|
||||
void *arg);
|
||||
|
||||
|
76
evmap.c
76
evmap.c
@ -137,12 +137,12 @@ HT_GENERATE(event_io_map, event_map_entry, map_node, hashsocket, eqsocket,
|
||||
(x) = &_ent->ent.type; \
|
||||
} while (0)
|
||||
|
||||
void evmap_io_initmap(struct event_io_map *ctx)
|
||||
void evmap_io_initmap_(struct event_io_map *ctx)
|
||||
{
|
||||
HT_INIT(event_io_map, ctx);
|
||||
}
|
||||
|
||||
void evmap_io_clear(struct event_io_map *ctx)
|
||||
void evmap_io_clear_(struct event_io_map *ctx)
|
||||
{
|
||||
struct event_map_entry **ent, **next, *this;
|
||||
for (ent = HT_START(event_io_map, ctx); ent; ent = next) {
|
||||
@ -184,14 +184,14 @@ void evmap_io_clear(struct event_io_map *ctx)
|
||||
GET_SIGNAL_SLOT_AND_CTOR(x,map,slot,type,ctor,fdinfo_len)
|
||||
#define FDINFO_OFFSET sizeof(struct evmap_io)
|
||||
void
|
||||
evmap_io_initmap(struct event_io_map* ctx)
|
||||
evmap_io_initmap_(struct event_io_map* ctx)
|
||||
{
|
||||
evmap_signal_initmap(ctx);
|
||||
evmap_signal_initmap_(ctx);
|
||||
}
|
||||
void
|
||||
evmap_io_clear(struct event_io_map* ctx)
|
||||
evmap_io_clear_(struct event_io_map* ctx)
|
||||
{
|
||||
evmap_signal_clear(ctx);
|
||||
evmap_signal_clear_(ctx);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -224,14 +224,14 @@ evmap_make_space(struct event_signal_map *map, int slot, int msize)
|
||||
}
|
||||
|
||||
void
|
||||
evmap_signal_initmap(struct event_signal_map *ctx)
|
||||
evmap_signal_initmap_(struct event_signal_map *ctx)
|
||||
{
|
||||
ctx->nentries = 0;
|
||||
ctx->entries = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
evmap_signal_clear(struct event_signal_map *ctx)
|
||||
evmap_signal_clear_(struct event_signal_map *ctx)
|
||||
{
|
||||
if (ctx->entries != NULL) {
|
||||
int i;
|
||||
@ -261,7 +261,7 @@ evmap_io_init(struct evmap_io *entry)
|
||||
/* return -1 on error, 0 on success if nothing changed in the event backend,
|
||||
* and 1 on success if something did. */
|
||||
int
|
||||
evmap_io_add(struct event_base *base, evutil_socket_t fd, struct event *ev)
|
||||
evmap_io_add_(struct event_base *base, evutil_socket_t fd, struct event *ev)
|
||||
{
|
||||
const struct eventop *evsel = base->evsel;
|
||||
struct event_io_map *io = &base->io;
|
||||
@ -334,7 +334,7 @@ evmap_io_add(struct event_base *base, evutil_socket_t fd, struct event *ev)
|
||||
/* return -1 on error, 0 on success if nothing changed in the event backend,
|
||||
* and 1 on success if something did. */
|
||||
int
|
||||
evmap_io_del(struct event_base *base, evutil_socket_t fd, struct event *ev)
|
||||
evmap_io_del_(struct event_base *base, evutil_socket_t fd, struct event *ev)
|
||||
{
|
||||
const struct eventop *evsel = base->evsel;
|
||||
struct event_io_map *io = &base->io;
|
||||
@ -388,7 +388,7 @@ evmap_io_del(struct event_base *base, evutil_socket_t fd, struct event *ev)
|
||||
}
|
||||
|
||||
void
|
||||
evmap_io_active(struct event_base *base, evutil_socket_t fd, short events)
|
||||
evmap_io_active_(struct event_base *base, evutil_socket_t fd, short events)
|
||||
{
|
||||
struct event_io_map *io = &base->io;
|
||||
struct evmap_io *ctx;
|
||||
@ -402,7 +402,7 @@ evmap_io_active(struct event_base *base, evutil_socket_t fd, short events)
|
||||
EVUTIL_ASSERT(ctx);
|
||||
LIST_FOREACH(ev, &ctx->events, ev_io_next) {
|
||||
if (ev->ev_events & events)
|
||||
event_active_nolock(ev, ev->ev_events & events, 1);
|
||||
event_active_nolock_(ev, ev->ev_events & events, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -416,7 +416,7 @@ evmap_signal_init(struct evmap_signal *entry)
|
||||
|
||||
|
||||
int
|
||||
evmap_signal_add(struct event_base *base, int sig, struct event *ev)
|
||||
evmap_signal_add_(struct event_base *base, int sig, struct event *ev)
|
||||
{
|
||||
const struct eventop *evsel = base->evsigsel;
|
||||
struct event_signal_map *map = &base->sigmap;
|
||||
@ -442,7 +442,7 @@ evmap_signal_add(struct event_base *base, int sig, struct event *ev)
|
||||
}
|
||||
|
||||
int
|
||||
evmap_signal_del(struct event_base *base, int sig, struct event *ev)
|
||||
evmap_signal_del_(struct event_base *base, int sig, struct event *ev)
|
||||
{
|
||||
const struct eventop *evsel = base->evsigsel;
|
||||
struct event_signal_map *map = &base->sigmap;
|
||||
@ -464,7 +464,7 @@ evmap_signal_del(struct event_base *base, int sig, struct event *ev)
|
||||
}
|
||||
|
||||
void
|
||||
evmap_signal_active(struct event_base *base, evutil_socket_t sig, int ncalls)
|
||||
evmap_signal_active_(struct event_base *base, evutil_socket_t sig, int ncalls)
|
||||
{
|
||||
struct event_signal_map *map = &base->sigmap;
|
||||
struct evmap_signal *ctx;
|
||||
@ -474,11 +474,11 @@ evmap_signal_active(struct event_base *base, evutil_socket_t sig, int ncalls)
|
||||
GET_SIGNAL_SLOT(ctx, map, sig, evmap_signal);
|
||||
|
||||
LIST_FOREACH(ev, &ctx->events, ev_signal_next)
|
||||
event_active_nolock(ev, EV_SIGNAL, ncalls);
|
||||
event_active_nolock_(ev, EV_SIGNAL, ncalls);
|
||||
}
|
||||
|
||||
void *
|
||||
evmap_io_get_fdinfo(struct event_io_map *map, evutil_socket_t fd)
|
||||
evmap_io_get_fdinfo_(struct event_io_map *map, evutil_socket_t fd)
|
||||
{
|
||||
struct evmap_io *ctx;
|
||||
GET_IO_SLOT(ctx, map, fd, evmap_io);
|
||||
@ -563,7 +563,7 @@ evmap_signal_foreach_signal(struct event_base *base,
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Helper for evmap_reinit: tell the backend to add every fd for which we have
|
||||
/* Helper for evmap_reinit_: tell the backend to add every fd for which we have
|
||||
* pending events, with the appropriate combination of EV_READ, EV_WRITE, and
|
||||
* EV_ET. */
|
||||
static int
|
||||
@ -594,7 +594,7 @@ evmap_io_reinit_iter_fn(struct event_base *base, evutil_socket_t fd,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Helper for evmap_reinit: tell the backend to add every signal for which we
|
||||
/* Helper for evmap_reinit_: tell the backend to add every signal for which we
|
||||
* have pending events. */
|
||||
static int
|
||||
evmap_signal_reinit_iter_fn(struct event_base *base,
|
||||
@ -611,7 +611,7 @@ evmap_signal_reinit_iter_fn(struct event_base *base,
|
||||
}
|
||||
|
||||
int
|
||||
evmap_reinit(struct event_base *base)
|
||||
evmap_reinit_(struct event_base *base)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
@ -624,7 +624,7 @@ evmap_reinit(struct event_base *base)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Helper for evmap_delete_all: delete every event in an event_dlist. */
|
||||
/* Helper for evmap_delete_all_: delete every event in an event_dlist. */
|
||||
static int
|
||||
delete_all_in_dlist(struct event_dlist *dlist)
|
||||
{
|
||||
@ -634,7 +634,7 @@ delete_all_in_dlist(struct event_dlist *dlist)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Helper for evmap_delete_all: delete every event pending on an fd. */
|
||||
/* Helper for evmap_delete_all_: delete every event pending on an fd. */
|
||||
static int
|
||||
evmap_io_delete_all_iter_fn(struct event_base *base, evutil_socket_t fd,
|
||||
struct evmap_io *io_info, void *arg)
|
||||
@ -642,7 +642,7 @@ evmap_io_delete_all_iter_fn(struct event_base *base, evutil_socket_t fd,
|
||||
return delete_all_in_dlist(&io_info->events);
|
||||
}
|
||||
|
||||
/* Helper for evmap_delete_all: delete every event pending on a signal. */
|
||||
/* Helper for evmap_delete_all_: delete every event pending on a signal. */
|
||||
static int
|
||||
evmap_signal_delete_all_iter_fn(struct event_base *base, int signum,
|
||||
struct evmap_signal *sig_info, void *arg)
|
||||
@ -651,7 +651,7 @@ evmap_signal_delete_all_iter_fn(struct event_base *base, int signum,
|
||||
}
|
||||
|
||||
void
|
||||
evmap_delete_all(struct event_base *base)
|
||||
evmap_delete_all_(struct event_base *base)
|
||||
{
|
||||
evmap_signal_foreach_signal(base, evmap_signal_delete_all_iter_fn, NULL);
|
||||
evmap_io_foreach_fd(base, evmap_io_delete_all_iter_fn, NULL);
|
||||
@ -666,7 +666,7 @@ struct event_changelist_fdinfo {
|
||||
};
|
||||
|
||||
void
|
||||
event_changelist_init(struct event_changelist *changelist)
|
||||
event_changelist_init_(struct event_changelist *changelist)
|
||||
{
|
||||
changelist->changes = NULL;
|
||||
changelist->changes_size = 0;
|
||||
@ -737,7 +737,7 @@ event_changelist_assert_ok(struct event_base *base)
|
||||
#endif
|
||||
|
||||
void
|
||||
event_changelist_remove_all(struct event_changelist *changelist,
|
||||
event_changelist_remove_all_(struct event_changelist *changelist,
|
||||
struct event_base *base)
|
||||
{
|
||||
int i;
|
||||
@ -758,11 +758,11 @@ event_changelist_remove_all(struct event_changelist *changelist,
|
||||
}
|
||||
|
||||
void
|
||||
event_changelist_freemem(struct event_changelist *changelist)
|
||||
event_changelist_freemem_(struct event_changelist *changelist)
|
||||
{
|
||||
if (changelist->changes)
|
||||
mm_free(changelist->changes);
|
||||
event_changelist_init(changelist); /* zero it all out. */
|
||||
event_changelist_init_(changelist); /* zero it all out. */
|
||||
}
|
||||
|
||||
/** Increase the size of 'changelist' to hold more changes. */
|
||||
@ -824,7 +824,7 @@ event_changelist_get_or_construct(struct event_changelist *changelist,
|
||||
}
|
||||
|
||||
int
|
||||
event_changelist_add(struct event_base *base, evutil_socket_t fd, short old, short events,
|
||||
event_changelist_add_(struct event_base *base, evutil_socket_t fd, short old, short events,
|
||||
void *p)
|
||||
{
|
||||
struct event_changelist *changelist = &base->changelist;
|
||||
@ -855,7 +855,7 @@ event_changelist_add(struct event_base *base, evutil_socket_t fd, short old, sho
|
||||
}
|
||||
|
||||
int
|
||||
event_changelist_del(struct event_base *base, evutil_socket_t fd, short old, short events,
|
||||
event_changelist_del_(struct event_base *base, evutil_socket_t fd, short old, short events,
|
||||
void *p)
|
||||
{
|
||||
struct event_changelist *changelist = &base->changelist;
|
||||
@ -900,7 +900,7 @@ event_changelist_del(struct event_base *base, evutil_socket_t fd, short old, sho
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Helper for evmap_check_integrity: verify that all of the events pending on
|
||||
/* Helper for evmap_check_integrity_: verify that all of the events pending on
|
||||
* given fd are set up correctly, and that the nread and nwrite counts on that
|
||||
* fd are correct. */
|
||||
static int
|
||||
@ -931,7 +931,7 @@ evmap_io_check_integrity_fn(struct event_base *base, evutil_socket_t fd,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Helper for evmap_check_integrity: verify that all of the events pending
|
||||
/* Helper for evmap_check_integrity_: verify that all of the events pending
|
||||
* on given signal are set up correctly. */
|
||||
static int
|
||||
evmap_signal_check_integrity_fn(struct event_base *base,
|
||||
@ -951,23 +951,23 @@ evmap_signal_check_integrity_fn(struct event_base *base,
|
||||
}
|
||||
|
||||
void
|
||||
evmap_check_integrity(struct event_base *base)
|
||||
evmap_check_integrity_(struct event_base *base)
|
||||
{
|
||||
evmap_io_foreach_fd(base, evmap_io_check_integrity_fn, NULL);
|
||||
evmap_signal_foreach_signal(base, evmap_signal_check_integrity_fn, NULL);
|
||||
|
||||
if (base->evsel->add == event_changelist_add)
|
||||
if (base->evsel->add == event_changelist_add_)
|
||||
event_changelist_assert_ok(base);
|
||||
}
|
||||
|
||||
/* Helper type for evmap_foreach_event: Bundles a function to call on every
|
||||
/* Helper type for evmap_foreach_event_: Bundles a function to call on every
|
||||
* event, and the user-provided void* to use as its third argument. */
|
||||
struct evmap_foreach_event_helper {
|
||||
int (*fn)(struct event_base *, struct event *, void *);
|
||||
void *arg;
|
||||
};
|
||||
|
||||
/* Helper for evmap_foreach_event: calls a provided function on every event
|
||||
/* Helper for evmap_foreach_event_: calls a provided function on every event
|
||||
* pending on a given fd. */
|
||||
static int
|
||||
evmap_io_foreach_event_fn(struct event_base *base, evutil_socket_t fd,
|
||||
@ -983,7 +983,7 @@ evmap_io_foreach_event_fn(struct event_base *base, evutil_socket_t fd,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Helper for evmap_foreach_event: calls a provided function on every event
|
||||
/* Helper for evmap_foreach_event_: calls a provided function on every event
|
||||
* pending on a given signal. */
|
||||
static int
|
||||
evmap_signal_foreach_event_fn(struct event_base *base, int signum,
|
||||
@ -1000,7 +1000,7 @@ evmap_signal_foreach_event_fn(struct event_base *base, int signum,
|
||||
}
|
||||
|
||||
int
|
||||
evmap_foreach_event(struct event_base *base,
|
||||
evmap_foreach_event_(struct event_base *base,
|
||||
int (*fn)(struct event_base *, struct event *, void *), void *arg)
|
||||
{
|
||||
struct evmap_foreach_event_helper h;
|
||||
|
10
evport.c
10
evport.c
@ -158,7 +158,7 @@ evport_init(struct event_base *base)
|
||||
|
||||
evpd->ed_npending = 0;
|
||||
|
||||
evsig_init(base);
|
||||
evsig_init_(base);
|
||||
|
||||
return (evpd);
|
||||
}
|
||||
@ -291,7 +291,7 @@ evport_dispatch(struct event_base *base, struct timeval *tv)
|
||||
if (fd != -1) {
|
||||
/* We might have cleared out this event; we need
|
||||
* to be sure that it's still set. */
|
||||
fdi = evmap_io_get_fdinfo(&base->io, fd);
|
||||
fdi = evmap_io_get_fdinfo_(&base->io, fd);
|
||||
}
|
||||
|
||||
if (fdi != NULL && FDI_HAS_EVENTS(fdi)) {
|
||||
@ -326,7 +326,7 @@ evport_dispatch(struct event_base *base, struct timeval *tv)
|
||||
port_event_t *pevt = &pevtlist[i];
|
||||
int fd = (int) pevt->portev_object;
|
||||
struct fd_info *fdi = pevt->portev_user;
|
||||
/*EVUTIL_ASSERT(evmap_io_get_fdinfo(&base->io, fd) == fdi);*/
|
||||
/*EVUTIL_ASSERT(evmap_io_get_fdinfo_(&base->io, fd) == fdi);*/
|
||||
|
||||
check_evportop(epdp);
|
||||
check_event(pevt);
|
||||
@ -353,7 +353,7 @@ evport_dispatch(struct event_base *base, struct timeval *tv)
|
||||
if (pevt->portev_events & (POLLERR|POLLHUP|POLLNVAL))
|
||||
res |= EV_READ|EV_WRITE;
|
||||
|
||||
evmap_io_active(base, fd, res);
|
||||
evmap_io_active_(base, fd, res);
|
||||
} /* end of all events gotten */
|
||||
epdp->ed_npending = nevents;
|
||||
|
||||
@ -436,7 +436,7 @@ evport_dealloc(struct event_base *base)
|
||||
{
|
||||
struct evport_data *evpd = base->evbase;
|
||||
|
||||
evsig_dealloc(base);
|
||||
evsig_dealloc_(base);
|
||||
|
||||
close(evpd->ed_port);
|
||||
|
||||
|
@ -79,7 +79,7 @@ struct evrpc_base {
|
||||
};
|
||||
|
||||
struct evrpc_req_generic;
|
||||
void evrpc_reqstate_free(struct evrpc_req_generic* rpc_state);
|
||||
void evrpc_reqstate_free_(struct evrpc_req_generic* rpc_state);
|
||||
|
||||
/* A pool for holding evhttp_connection objects */
|
||||
struct evrpc_pool {
|
||||
@ -117,14 +117,14 @@ struct evrpc_hook_meta {
|
||||
};
|
||||
|
||||
/* allows association of meta data with a request */
|
||||
static void evrpc_hook_associate_meta(struct evrpc_hook_meta **pctx,
|
||||
static void evrpc_hook_associate_meta_(struct evrpc_hook_meta **pctx,
|
||||
struct evhttp_connection *evcon);
|
||||
|
||||
/* creates a new meta data store */
|
||||
static struct evrpc_hook_meta *evrpc_hook_meta_new(void);
|
||||
static struct evrpc_hook_meta *evrpc_hook_meta_new_(void);
|
||||
|
||||
/* frees the meta data associated with a request */
|
||||
static void evrpc_hook_context_free(struct evrpc_hook_meta *ctx);
|
||||
static void evrpc_hook_context_free_(struct evrpc_hook_meta *ctx);
|
||||
|
||||
/* the server side of an rpc */
|
||||
|
||||
|
36
evrpc.c
36
evrpc.c
@ -302,7 +302,7 @@ evrpc_request_cb(struct evhttp_request *req, void *arg)
|
||||
if (TAILQ_FIRST(&rpc->base->input_hooks) != NULL) {
|
||||
int hook_res;
|
||||
|
||||
evrpc_hook_associate_meta(&rpc_state->hook_meta, req->evcon);
|
||||
evrpc_hook_associate_meta_(&rpc_state->hook_meta, req->evcon);
|
||||
|
||||
/*
|
||||
* allow hooks to modify the outgoing request
|
||||
@ -330,7 +330,7 @@ evrpc_request_cb(struct evhttp_request *req, void *arg)
|
||||
|
||||
error:
|
||||
if (rpc_state != NULL)
|
||||
evrpc_reqstate_free(rpc_state);
|
||||
evrpc_reqstate_free_(rpc_state);
|
||||
evhttp_send_error(req, HTTP_SERVUNAVAIL, NULL);
|
||||
return;
|
||||
}
|
||||
@ -373,14 +373,14 @@ evrpc_request_cb_closure(void *arg, enum EVRPC_HOOK_RESULT hook_res)
|
||||
|
||||
error:
|
||||
if (rpc_state != NULL)
|
||||
evrpc_reqstate_free(rpc_state);
|
||||
evrpc_reqstate_free_(rpc_state);
|
||||
evhttp_send_error(req, HTTP_SERVUNAVAIL, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
evrpc_reqstate_free(struct evrpc_req_generic* rpc_state)
|
||||
evrpc_reqstate_free_(struct evrpc_req_generic* rpc_state)
|
||||
{
|
||||
struct evrpc *rpc;
|
||||
EVUTIL_ASSERT(rpc_state != NULL);
|
||||
@ -388,7 +388,7 @@ evrpc_reqstate_free(struct evrpc_req_generic* rpc_state)
|
||||
|
||||
/* clean up all memory */
|
||||
if (rpc_state->hook_meta != NULL)
|
||||
evrpc_hook_context_free(rpc_state->hook_meta);
|
||||
evrpc_hook_context_free_(rpc_state->hook_meta);
|
||||
if (rpc_state->request != NULL)
|
||||
rpc->request_free(rpc_state->request);
|
||||
if (rpc_state->reply != NULL)
|
||||
@ -428,7 +428,7 @@ evrpc_request_done(struct evrpc_req_generic *rpc_state)
|
||||
if (TAILQ_FIRST(&rpc->base->output_hooks) != NULL) {
|
||||
int hook_res;
|
||||
|
||||
evrpc_hook_associate_meta(&rpc_state->hook_meta, req->evcon);
|
||||
evrpc_hook_associate_meta_(&rpc_state->hook_meta, req->evcon);
|
||||
|
||||
/* do hook based tweaks to the request */
|
||||
hook_res = evrpc_process_hooks(&rpc->base->output_hooks,
|
||||
@ -455,7 +455,7 @@ evrpc_request_done(struct evrpc_req_generic *rpc_state)
|
||||
|
||||
error:
|
||||
if (rpc_state != NULL)
|
||||
evrpc_reqstate_free(rpc_state);
|
||||
evrpc_reqstate_free_(rpc_state);
|
||||
evhttp_send_error(req, HTTP_SERVUNAVAIL, NULL);
|
||||
return;
|
||||
}
|
||||
@ -490,13 +490,13 @@ evrpc_request_done_closure(void *arg, enum EVRPC_HOOK_RESULT hook_res)
|
||||
}
|
||||
evhttp_send_reply(req, HTTP_OK, "OK", rpc_state->rpc_data);
|
||||
|
||||
evrpc_reqstate_free(rpc_state);
|
||||
evrpc_reqstate_free_(rpc_state);
|
||||
|
||||
return;
|
||||
|
||||
error:
|
||||
if (rpc_state != NULL)
|
||||
evrpc_reqstate_free(rpc_state);
|
||||
evrpc_reqstate_free_(rpc_state);
|
||||
evhttp_send_error(req, HTTP_SERVUNAVAIL, NULL);
|
||||
return;
|
||||
}
|
||||
@ -532,7 +532,7 @@ static void
|
||||
evrpc_request_wrapper_free(struct evrpc_request_wrapper *request)
|
||||
{
|
||||
if (request->hook_meta != NULL)
|
||||
evrpc_hook_context_free(request->hook_meta);
|
||||
evrpc_hook_context_free_(request->hook_meta);
|
||||
mm_free(request->name);
|
||||
mm_free(request);
|
||||
}
|
||||
@ -681,7 +681,7 @@ evrpc_schedule_request(struct evhttp_connection *connection,
|
||||
if (TAILQ_FIRST(&pool->output_hooks) != NULL) {
|
||||
int hook_res;
|
||||
|
||||
evrpc_hook_associate_meta(&ctx->hook_meta, connection);
|
||||
evrpc_hook_associate_meta_(&ctx->hook_meta, connection);
|
||||
|
||||
/* apply hooks to the outgoing request */
|
||||
hook_res = evrpc_process_hooks(&pool->output_hooks,
|
||||
@ -878,7 +878,7 @@ evrpc_reply_done(struct evhttp_request *req, void *arg)
|
||||
}
|
||||
|
||||
if (TAILQ_FIRST(&pool->input_hooks) != NULL) {
|
||||
evrpc_hook_associate_meta(&ctx->hook_meta, ctx->evcon);
|
||||
evrpc_hook_associate_meta_(&ctx->hook_meta, ctx->evcon);
|
||||
|
||||
/* apply hooks to the incoming request */
|
||||
hook_res = evrpc_process_hooks(&pool->input_hooks,
|
||||
@ -977,7 +977,7 @@ evrpc_request_timeout(evutil_socket_t fd, short what, void *arg)
|
||||
struct evhttp_connection *evcon = ctx->evcon;
|
||||
EVUTIL_ASSERT(evcon != NULL);
|
||||
|
||||
evhttp_connection_fail(evcon, EVCON_HTTP_TIMEOUT);
|
||||
evhttp_connection_fail_(evcon, EVCON_HTTP_TIMEOUT);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -999,7 +999,7 @@ evrpc_meta_data_free(struct evrpc_meta_list *meta_data)
|
||||
}
|
||||
|
||||
static struct evrpc_hook_meta *
|
||||
evrpc_hook_meta_new(void)
|
||||
evrpc_hook_meta_new_(void)
|
||||
{
|
||||
struct evrpc_hook_meta *ctx;
|
||||
ctx = mm_malloc(sizeof(struct evrpc_hook_meta));
|
||||
@ -1012,17 +1012,17 @@ evrpc_hook_meta_new(void)
|
||||
}
|
||||
|
||||
static void
|
||||
evrpc_hook_associate_meta(struct evrpc_hook_meta **pctx,
|
||||
evrpc_hook_associate_meta_(struct evrpc_hook_meta **pctx,
|
||||
struct evhttp_connection *evcon)
|
||||
{
|
||||
struct evrpc_hook_meta *ctx = *pctx;
|
||||
if (ctx == NULL)
|
||||
*pctx = ctx = evrpc_hook_meta_new();
|
||||
*pctx = ctx = evrpc_hook_meta_new_();
|
||||
ctx->evcon = evcon;
|
||||
}
|
||||
|
||||
static void
|
||||
evrpc_hook_context_free(struct evrpc_hook_meta *ctx)
|
||||
evrpc_hook_context_free_(struct evrpc_hook_meta *ctx)
|
||||
{
|
||||
evrpc_meta_data_free(&ctx->meta_data);
|
||||
mm_free(ctx);
|
||||
@ -1038,7 +1038,7 @@ evrpc_hook_add_meta(void *ctx, const char *key,
|
||||
struct evrpc_meta *meta = NULL;
|
||||
|
||||
if ((store = req->hook_meta) == NULL)
|
||||
store = req->hook_meta = evrpc_hook_meta_new();
|
||||
store = req->hook_meta = evrpc_hook_meta_new_();
|
||||
|
||||
meta = mm_malloc(sizeof(struct evrpc_meta));
|
||||
EVUTIL_ASSERT(meta != NULL);
|
||||
|
@ -56,9 +56,9 @@ struct evsig_info {
|
||||
/* Size of sh_old. */
|
||||
int sh_old_max;
|
||||
};
|
||||
int evsig_init(struct event_base *);
|
||||
void evsig_dealloc(struct event_base *);
|
||||
int evsig_init_(struct event_base *);
|
||||
void evsig_dealloc_(struct event_base *);
|
||||
|
||||
void evsig_set_base(struct event_base *base);
|
||||
void evsig_set_base_(struct event_base *base);
|
||||
|
||||
#endif /* EVSIGNAL_INTERNAL_H_INCLUDED_ */
|
||||
|
@ -132,9 +132,9 @@ extern int evthread_lock_debugging_enabled_;
|
||||
|
||||
/** Try to grab the lock for 'lockvar' without blocking, and return 1 if we
|
||||
* manage to get it. */
|
||||
static inline int EVLOCK_TRY_LOCK(void *lock);
|
||||
static inline int EVLOCK_TRY_LOCK_(void *lock);
|
||||
static inline int
|
||||
EVLOCK_TRY_LOCK(void *lock)
|
||||
EVLOCK_TRY_LOCK_(void *lock)
|
||||
{
|
||||
if (lock && evthread_lock_fns_.lock) {
|
||||
int r = evthread_lock_fns_.lock(EVTHREAD_TRY, lock);
|
||||
@ -246,9 +246,9 @@ int evthreadimpl_locking_enabled_(void);
|
||||
|
||||
/** Try to grab the lock for 'lockvar' without blocking, and return 1 if we
|
||||
* manage to get it. */
|
||||
static inline int EVLOCK_TRY_LOCK(void *lock);
|
||||
static inline int EVLOCK_TRY_LOCK_(void *lock);
|
||||
static inline int
|
||||
EVLOCK_TRY_LOCK(void *lock)
|
||||
EVLOCK_TRY_LOCK_(void *lock)
|
||||
{
|
||||
if (lock) {
|
||||
int r = evthreadimpl_lock_lock_(EVTHREAD_TRY, lock);
|
||||
@ -308,7 +308,7 @@ EVLOCK_TRY_LOCK(void *lock)
|
||||
#define EVBASE_RELEASE_LOCK(base, lock) EVUTIL_NIL_STMT_
|
||||
#define EVLOCK_ASSERT_LOCKED(lock) EVUTIL_NIL_STMT_
|
||||
|
||||
#define EVLOCK_TRY_LOCK(lock) 1
|
||||
#define EVLOCK_TRY_LOCK_(lock) 1
|
||||
|
||||
#define EVTHREAD_ALLOC_COND(condvar) EVUTIL_NIL_STMT_
|
||||
#define EVTHREAD_FREE_COND(cond) EVUTIL_NIL_STMT_
|
||||
|
@ -161,7 +161,7 @@ evthread_win32_condvar_wait(void *_cond, void *_lock, const struct timeval *tv)
|
||||
BOOL result;
|
||||
|
||||
if (tv)
|
||||
ms = evutil_tv_to_msec(tv);
|
||||
ms = evutil_tv_to_msec_(tv);
|
||||
else
|
||||
ms = INFINITE;
|
||||
result = SleepConditionVariableCS_fn(cond, lock, ms);
|
||||
@ -238,7 +238,7 @@ evthread_win32_cond_wait(void *_cond, void *_lock, const struct timeval *tv)
|
||||
int result = -1;
|
||||
DWORD ms = INFINITE, ms_orig = INFINITE, startTime, endTime;
|
||||
if (tv)
|
||||
ms_orig = ms = evutil_tv_to_msec(tv);
|
||||
ms_orig = ms = evutil_tv_to_msec_(tv);
|
||||
|
||||
EnterCriticalSection(&cond->lock);
|
||||
++cond->n_waiting;
|
||||
|
104
evutil.c
104
evutil.c
@ -100,7 +100,7 @@
|
||||
#endif
|
||||
|
||||
int
|
||||
evutil_open_closeonexec(const char *pathname, int flags, unsigned mode)
|
||||
evutil_open_closeonexec_(const char *pathname, int flags, unsigned mode)
|
||||
{
|
||||
int fd;
|
||||
|
||||
@ -139,7 +139,7 @@ evutil_open_closeonexec(const char *pathname, int flags, unsigned mode)
|
||||
Used internally only; may go away in a future version.
|
||||
*/
|
||||
int
|
||||
evutil_read_file(const char *filename, char **content_out, size_t *len_out,
|
||||
evutil_read_file_(const char *filename, char **content_out, size_t *len_out,
|
||||
int is_binary)
|
||||
{
|
||||
int fd, r;
|
||||
@ -158,7 +158,7 @@ evutil_read_file(const char *filename, char **content_out, size_t *len_out,
|
||||
mode |= O_BINARY;
|
||||
#endif
|
||||
|
||||
fd = evutil_open_closeonexec(filename, mode, 0);
|
||||
fd = evutil_open_closeonexec_(filename, mode, 0);
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
if (fstat(fd, &st) || st.st_size < 0 ||
|
||||
@ -201,12 +201,12 @@ evutil_socketpair(int family, int type, int protocol, evutil_socket_t fd[2])
|
||||
#ifndef _WIN32
|
||||
return socketpair(family, type, protocol, fd);
|
||||
#else
|
||||
return evutil_ersatz_socketpair(family, type, protocol, fd);
|
||||
return evutil_ersatz_socketpair_(family, type, protocol, fd);
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
evutil_ersatz_socketpair(int family, int type, int protocol,
|
||||
evutil_ersatz_socketpair_(int family, int type, int protocol,
|
||||
evutil_socket_t fd[2])
|
||||
{
|
||||
/* This code is originally from Tor. Used with permission. */
|
||||
@ -465,15 +465,15 @@ evutil_strtoll(const char *s, char **endptr, int base)
|
||||
}
|
||||
if (n != 1)
|
||||
return 0;
|
||||
while (EVUTIL_ISSPACE(*s))
|
||||
while (EVUTIL_ISSPACE_(*s))
|
||||
++s;
|
||||
if (*s == '-')
|
||||
++s;
|
||||
if (base == 10) {
|
||||
while (EVUTIL_ISDIGIT(*s))
|
||||
while (EVUTIL_ISDIGIT_(*s))
|
||||
++s;
|
||||
} else {
|
||||
while (EVUTIL_ISXDIGIT(*s))
|
||||
while (EVUTIL_ISXDIGIT_(*s))
|
||||
++s;
|
||||
}
|
||||
if (endptr)
|
||||
@ -544,7 +544,7 @@ evutil_socket_geterror(evutil_socket_t sock)
|
||||
/* XXX we should use an enum here. */
|
||||
/* 2 for connection refused, 1 for connected, 0 for not yet, -1 for error. */
|
||||
int
|
||||
evutil_socket_connect(evutil_socket_t *fd_ptr, struct sockaddr *sa, int socklen)
|
||||
evutil_socket_connect_(evutil_socket_t *fd_ptr, struct sockaddr *sa, int socklen)
|
||||
{
|
||||
int made_fd = 0;
|
||||
|
||||
@ -581,7 +581,7 @@ err:
|
||||
error case, set the current socket errno to the error that happened during
|
||||
the connect operation. */
|
||||
int
|
||||
evutil_socket_finished_connecting(evutil_socket_t fd)
|
||||
evutil_socket_finished_connecting_(evutil_socket_t fd)
|
||||
{
|
||||
int e;
|
||||
ev_socklen_t elen = sizeof(e);
|
||||
@ -690,7 +690,7 @@ evutil_check_ifaddrs(void)
|
||||
"GetAdaptersInfo", but that's deprecated; let's just try
|
||||
GetAdaptersAddresses and fall back to connect+getsockname.
|
||||
*/
|
||||
HANDLE lib = evutil_load_windows_system_library(TEXT("ihplapi.dll"));
|
||||
HANDLE lib = evutil_load_windows_system_library_(TEXT("ihplapi.dll"));
|
||||
GetAdaptersAddresses_fn_t fn;
|
||||
ULONG size, res;
|
||||
IP_ADAPTER_ADDRESSES *addresses = NULL, *address;
|
||||
@ -818,7 +818,7 @@ evutil_check_interfaces(int force_recheck)
|
||||
* allocate both a TCP and a UDP addrinfo.
|
||||
*/
|
||||
struct evutil_addrinfo *
|
||||
evutil_new_addrinfo(struct sockaddr *sa, ev_socklen_t socklen,
|
||||
evutil_new_addrinfo_(struct sockaddr *sa, ev_socklen_t socklen,
|
||||
const struct evutil_addrinfo *hints)
|
||||
{
|
||||
struct evutil_addrinfo *res;
|
||||
@ -830,11 +830,11 @@ evutil_new_addrinfo(struct sockaddr *sa, ev_socklen_t socklen,
|
||||
struct evutil_addrinfo tmp;
|
||||
memcpy(&tmp, hints, sizeof(tmp));
|
||||
tmp.ai_socktype = SOCK_STREAM; tmp.ai_protocol = IPPROTO_TCP;
|
||||
r1 = evutil_new_addrinfo(sa, socklen, &tmp);
|
||||
r1 = evutil_new_addrinfo_(sa, socklen, &tmp);
|
||||
if (!r1)
|
||||
return NULL;
|
||||
tmp.ai_socktype = SOCK_DGRAM; tmp.ai_protocol = IPPROTO_UDP;
|
||||
r2 = evutil_new_addrinfo(sa, socklen, &tmp);
|
||||
r2 = evutil_new_addrinfo_(sa, socklen, &tmp);
|
||||
if (!r2) {
|
||||
evutil_freeaddrinfo(r1);
|
||||
return NULL;
|
||||
@ -863,7 +863,7 @@ evutil_new_addrinfo(struct sockaddr *sa, ev_socklen_t socklen,
|
||||
* the list. Either element can be NULL, in which case we return the element
|
||||
* that is not NULL. */
|
||||
struct evutil_addrinfo *
|
||||
evutil_addrinfo_append(struct evutil_addrinfo *first,
|
||||
evutil_addrinfo_append_(struct evutil_addrinfo *first,
|
||||
struct evutil_addrinfo *append)
|
||||
{
|
||||
struct evutil_addrinfo *ai = first;
|
||||
@ -979,7 +979,7 @@ evutil_getaddrinfo_infer_protocols(struct evutil_addrinfo *hints)
|
||||
* set *res as getaddrinfo would.
|
||||
*/
|
||||
int
|
||||
evutil_getaddrinfo_common(const char *nodename, const char *servname,
|
||||
evutil_getaddrinfo_common_(const char *nodename, const char *servname,
|
||||
struct evutil_addrinfo *hints, struct evutil_addrinfo **res, int *portnum)
|
||||
{
|
||||
int port = 0;
|
||||
@ -1021,7 +1021,7 @@ evutil_getaddrinfo_common(const char *nodename, const char *servname,
|
||||
/* connect to ::1 */
|
||||
sin6.sin6_addr.s6_addr[15] = 1;
|
||||
}
|
||||
res6 = evutil_new_addrinfo((struct sockaddr*)&sin6,
|
||||
res6 = evutil_new_addrinfo_((struct sockaddr*)&sin6,
|
||||
sizeof(sin6), hints);
|
||||
if (!res6)
|
||||
return EVUTIL_EAI_MEMORY;
|
||||
@ -1038,7 +1038,7 @@ evutil_getaddrinfo_common(const char *nodename, const char *servname,
|
||||
/* connect to 127.0.0.1 */
|
||||
sin.sin_addr.s_addr = htonl(0x7f000001);
|
||||
}
|
||||
res4 = evutil_new_addrinfo((struct sockaddr*)&sin,
|
||||
res4 = evutil_new_addrinfo_((struct sockaddr*)&sin,
|
||||
sizeof(sin), hints);
|
||||
if (!res4) {
|
||||
if (res6)
|
||||
@ -1046,7 +1046,7 @@ evutil_getaddrinfo_common(const char *nodename, const char *servname,
|
||||
return EVUTIL_EAI_MEMORY;
|
||||
}
|
||||
}
|
||||
*res = evutil_addrinfo_append(res4, res6);
|
||||
*res = evutil_addrinfo_append_(res4, res6);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1060,7 +1060,7 @@ evutil_getaddrinfo_common(const char *nodename, const char *servname,
|
||||
/* Got an ipv6 address. */
|
||||
sin6.sin6_family = AF_INET6;
|
||||
sin6.sin6_port = htons(port);
|
||||
*res = evutil_new_addrinfo((struct sockaddr*)&sin6,
|
||||
*res = evutil_new_addrinfo_((struct sockaddr*)&sin6,
|
||||
sizeof(sin6), hints);
|
||||
if (!*res)
|
||||
return EVUTIL_EAI_MEMORY;
|
||||
@ -1076,7 +1076,7 @@ evutil_getaddrinfo_common(const char *nodename, const char *servname,
|
||||
/* Got an ipv6 address. */
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(port);
|
||||
*res = evutil_new_addrinfo((struct sockaddr*)&sin,
|
||||
*res = evutil_new_addrinfo_((struct sockaddr*)&sin,
|
||||
sizeof(sin), hints);
|
||||
if (!*res)
|
||||
return EVUTIL_EAI_MEMORY;
|
||||
@ -1194,12 +1194,12 @@ addrinfo_from_hostent(const struct hostent *ent,
|
||||
|
||||
for (i = 0; ent->h_addr_list[i]; ++i) {
|
||||
memcpy(addrp, ent->h_addr_list[i], ent->h_length);
|
||||
ai = evutil_new_addrinfo(sa, socklen, hints);
|
||||
ai = evutil_new_addrinfo_(sa, socklen, hints);
|
||||
if (!ai) {
|
||||
evutil_freeaddrinfo(res);
|
||||
return NULL;
|
||||
}
|
||||
res = evutil_addrinfo_append(res, ai);
|
||||
res = evutil_addrinfo_append_(res, ai);
|
||||
}
|
||||
|
||||
if (res && ((hints->ai_flags & EVUTIL_AI_CANONNAME) && ent->h_name)) {
|
||||
@ -1219,7 +1219,7 @@ addrinfo_from_hostent(const struct hostent *ent,
|
||||
* that we'll only get addresses we could maybe connect to.
|
||||
*/
|
||||
void
|
||||
evutil_adjust_hints_for_addrconfig(struct evutil_addrinfo *hints)
|
||||
evutil_adjust_hints_for_addrconfig_(struct evutil_addrinfo *hints)
|
||||
{
|
||||
if (!(hints->ai_flags & EVUTIL_AI_ADDRCONFIG))
|
||||
return;
|
||||
@ -1245,7 +1245,7 @@ static int tested_for_getaddrinfo_hacks=0;
|
||||
turns out that the bug is present, then:
|
||||
|
||||
- If nodename==NULL and servname is numeric, we build an answer
|
||||
ourselves using evutil_getaddrinfo_common().
|
||||
ourselves using evutil_getaddrinfo_common_().
|
||||
|
||||
- If nodename!=NULL and servname is numeric, then we set
|
||||
servname=NULL when calling getaddrinfo, and post-process the
|
||||
@ -1375,7 +1375,7 @@ evutil_getaddrinfo(const char *nodename, const char *servname,
|
||||
/* Not every system has AI_ADDRCONFIG, so fake it. */
|
||||
if (hints.ai_family == PF_UNSPEC &&
|
||||
(hints.ai_flags & EVUTIL_AI_ADDRCONFIG)) {
|
||||
evutil_adjust_hints_for_addrconfig(&hints);
|
||||
evutil_adjust_hints_for_addrconfig_(&hints);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1401,7 +1401,7 @@ evutil_getaddrinfo(const char *nodename, const char *servname,
|
||||
#ifdef _WIN32
|
||||
{
|
||||
int tmp_port;
|
||||
err = evutil_getaddrinfo_common(nodename,servname,&hints,
|
||||
err = evutil_getaddrinfo_common_(nodename,servname,&hints,
|
||||
res, &tmp_port);
|
||||
if (err == 0 ||
|
||||
err == EVUTIL_EAI_MEMORY ||
|
||||
@ -1417,7 +1417,7 @@ evutil_getaddrinfo(const char *nodename, const char *servname,
|
||||
&& ((portnum=parse_numeric_servname(servname)) >= 0);
|
||||
if (need_np_hack) {
|
||||
if (!nodename)
|
||||
return evutil_getaddrinfo_common(
|
||||
return evutil_getaddrinfo_common_(
|
||||
NULL,servname,&hints, res, &portnum);
|
||||
servname = NULL;
|
||||
}
|
||||
@ -1462,9 +1462,9 @@ evutil_getaddrinfo(const char *nodename, const char *servname,
|
||||
hints.ai_family = PF_UNSPEC;
|
||||
}
|
||||
|
||||
evutil_adjust_hints_for_addrconfig(&hints);
|
||||
evutil_adjust_hints_for_addrconfig_(&hints);
|
||||
|
||||
err = evutil_getaddrinfo_common(nodename, servname, &hints, res, &port);
|
||||
err = evutil_getaddrinfo_common_(nodename, servname, &hints, res, &port);
|
||||
if (err != EVUTIL_EAI_NEED_RESOLVE) {
|
||||
/* We either succeeded or failed. No need to continue */
|
||||
return err;
|
||||
@ -1568,7 +1568,7 @@ evutil_freeaddrinfo(struct evutil_addrinfo *ai)
|
||||
static evdns_getaddrinfo_fn evdns_getaddrinfo_impl = NULL;
|
||||
|
||||
void
|
||||
evutil_set_evdns_getaddrinfo_fn(evdns_getaddrinfo_fn fn)
|
||||
evutil_set_evdns_getaddrinfo_fn_(evdns_getaddrinfo_fn fn)
|
||||
{
|
||||
if (!evdns_getaddrinfo_impl)
|
||||
evdns_getaddrinfo_impl = fn;
|
||||
@ -1579,7 +1579,7 @@ evutil_set_evdns_getaddrinfo_fn(evdns_getaddrinfo_fn fn)
|
||||
* way that evdns_getaddrinfo would.
|
||||
*/
|
||||
int
|
||||
evutil_getaddrinfo_async(struct evdns_base *dns_base,
|
||||
evutil_getaddrinfo_async_(struct evdns_base *dns_base,
|
||||
const char *nodename, const char *servname,
|
||||
const struct evutil_addrinfo *hints_in,
|
||||
void (*cb)(int, struct evutil_addrinfo *, void *), void *arg)
|
||||
@ -1884,7 +1884,7 @@ evutil_inet_pton(int af, const char *src, void *dst)
|
||||
else {
|
||||
int byte1,byte2,byte3,byte4;
|
||||
char more;
|
||||
for (eow = dot-1; eow >= src && EVUTIL_ISDIGIT(*eow); --eow)
|
||||
for (eow = dot-1; eow >= src && EVUTIL_ISDIGIT_(*eow); --eow)
|
||||
;
|
||||
++eow;
|
||||
|
||||
@ -1909,7 +1909,7 @@ evutil_inet_pton(int af, const char *src, void *dst)
|
||||
while (src < eow) {
|
||||
if (i > 7)
|
||||
return 0;
|
||||
if (EVUTIL_ISXDIGIT(*src)) {
|
||||
if (EVUTIL_ISXDIGIT_(*src)) {
|
||||
char *next;
|
||||
long r = strtol(src, &next, 16);
|
||||
if (next > 4+src)
|
||||
@ -2068,7 +2068,7 @@ evutil_parse_sockaddr_port(const char *ip_as_string, struct sockaddr *out, int *
|
||||
}
|
||||
|
||||
const char *
|
||||
evutil_format_sockaddr_port(const struct sockaddr *sa, char *out, size_t outlen)
|
||||
evutil_format_sockaddr_port_(const struct sockaddr *sa, char *out, size_t outlen)
|
||||
{
|
||||
char b[128];
|
||||
const char *res=NULL;
|
||||
@ -2205,11 +2205,11 @@ IMPL_CTYPE_FN(ISPRINT)
|
||||
IMPL_CTYPE_FN(ISLOWER)
|
||||
IMPL_CTYPE_FN(ISUPPER)
|
||||
|
||||
char EVUTIL_TOLOWER(char c)
|
||||
char EVUTIL_TOLOWER_(char c)
|
||||
{
|
||||
return ((char)EVUTIL_TOLOWER_TABLE[(ev_uint8_t)c]);
|
||||
}
|
||||
char EVUTIL_TOUPPER(char c)
|
||||
char EVUTIL_TOUPPER_(char c)
|
||||
{
|
||||
return ((char)EVUTIL_TOUPPER_TABLE[(ev_uint8_t)c]);
|
||||
}
|
||||
@ -2218,8 +2218,8 @@ evutil_ascii_strcasecmp(const char *s1, const char *s2)
|
||||
{
|
||||
char c1, c2;
|
||||
while (1) {
|
||||
c1 = EVUTIL_TOLOWER(*s1++);
|
||||
c2 = EVUTIL_TOLOWER(*s2++);
|
||||
c1 = EVUTIL_TOLOWER_(*s1++);
|
||||
c2 = EVUTIL_TOLOWER_(*s2++);
|
||||
if (c1 < c2)
|
||||
return -1;
|
||||
else if (c1 > c2)
|
||||
@ -2232,8 +2232,8 @@ int evutil_ascii_strncasecmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
char c1, c2;
|
||||
while (n--) {
|
||||
c1 = EVUTIL_TOLOWER(*s1++);
|
||||
c2 = EVUTIL_TOLOWER(*s2++);
|
||||
c1 = EVUTIL_TOLOWER_(*s1++);
|
||||
c2 = EVUTIL_TOLOWER_(*s2++);
|
||||
if (c1 < c2)
|
||||
return -1;
|
||||
else if (c1 > c2)
|
||||
@ -2264,7 +2264,7 @@ evutil_issetugid(void)
|
||||
}
|
||||
|
||||
const char *
|
||||
evutil_getenv(const char *varname)
|
||||
evutil_getenv_(const char *varname)
|
||||
{
|
||||
if (evutil_issetugid())
|
||||
return NULL;
|
||||
@ -2283,7 +2283,7 @@ evutil_weakrand_(void)
|
||||
}
|
||||
|
||||
int
|
||||
evutil_sockaddr_is_loopback(const struct sockaddr *addr)
|
||||
evutil_sockaddr_is_loopback_(const struct sockaddr *addr)
|
||||
{
|
||||
static const char LOOPBACK_S6[16] =
|
||||
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1";
|
||||
@ -2301,7 +2301,7 @@ evutil_sockaddr_is_loopback(const struct sockaddr *addr)
|
||||
(((LONG_MAX) - 999) / 1000)
|
||||
|
||||
long
|
||||
evutil_tv_to_msec(const struct timeval *tv)
|
||||
evutil_tv_to_msec_(const struct timeval *tv)
|
||||
{
|
||||
if (tv->tv_usec > 1000000 || tv->tv_sec > MAX_SECONDS_IN_MSEC_LONG)
|
||||
return -1;
|
||||
@ -2310,7 +2310,7 @@ evutil_tv_to_msec(const struct timeval *tv)
|
||||
}
|
||||
|
||||
int
|
||||
evutil_hex_char_to_int(char c)
|
||||
evutil_hex_char_to_int_(char c)
|
||||
{
|
||||
switch(c)
|
||||
{
|
||||
@ -2336,7 +2336,7 @@ evutil_hex_char_to_int(char c)
|
||||
|
||||
#ifdef _WIN32
|
||||
HANDLE
|
||||
evutil_load_windows_system_library(const TCHAR *library_name)
|
||||
evutil_load_windows_system_library_(const TCHAR *library_name)
|
||||
{
|
||||
TCHAR path[MAX_PATH];
|
||||
unsigned n;
|
||||
@ -2350,13 +2350,13 @@ evutil_load_windows_system_library(const TCHAR *library_name)
|
||||
#endif
|
||||
|
||||
void
|
||||
evutil_usleep(const struct timeval *tv)
|
||||
evutil_usleep_(const struct timeval *tv)
|
||||
{
|
||||
if (!tv)
|
||||
return;
|
||||
#if defined(_WIN32)
|
||||
{
|
||||
long msec = evutil_tv_to_msec(tv);
|
||||
long msec = evutil_tv_to_msec_(tv);
|
||||
Sleep((DWORD)msec);
|
||||
}
|
||||
#elif defined(_EVENT_HAVE_NANOSLEEP_X)
|
||||
@ -2384,7 +2384,7 @@ evutil_usleep(const struct timeval *tv)
|
||||
* possible.
|
||||
*/
|
||||
evutil_socket_t
|
||||
evutil_socket(int domain, int type, int protocol)
|
||||
evutil_socket_(int domain, int type, int protocol)
|
||||
{
|
||||
evutil_socket_t r;
|
||||
#if defined(SOCK_NONBLOCK) && defined(SOCK_CLOEXEC)
|
||||
@ -2422,7 +2422,7 @@ evutil_socket(int domain, int type, int protocol)
|
||||
* possible.
|
||||
*/
|
||||
evutil_socket_t
|
||||
evutil_accept4(evutil_socket_t sockfd, struct sockaddr *addr,
|
||||
evutil_accept4_(evutil_socket_t sockfd, struct sockaddr *addr,
|
||||
ev_socklen_t *addrlen, int flags)
|
||||
{
|
||||
evutil_socket_t result;
|
||||
@ -2455,7 +2455,7 @@ evutil_accept4(evutil_socket_t sockfd, struct sockaddr *addr,
|
||||
* Return 0 on success, -1 on failure.
|
||||
*/
|
||||
int
|
||||
evutil_make_internal_pipe(evutil_socket_t fd[2])
|
||||
evutil_make_internal_pipe_(evutil_socket_t fd[2])
|
||||
{
|
||||
/*
|
||||
Making the second socket nonblocking is a bit subtle, given that we
|
||||
@ -2513,7 +2513,7 @@ evutil_make_internal_pipe(evutil_socket_t fd[2])
|
||||
* flags. Returns -1 on error or if eventfd is not supported.
|
||||
*/
|
||||
evutil_socket_t
|
||||
evutil_eventfd(unsigned initval, int flags)
|
||||
evutil_eventfd_(unsigned initval, int flags)
|
||||
{
|
||||
#if defined(EVENT__HAVE_EVENTFD) && defined(EVENT__HAVE_SYS_EVENTFD_H)
|
||||
int r;
|
||||
|
@ -60,7 +60,7 @@
|
||||
#define HT_INIT(name, head) name##_HT_INIT(head)
|
||||
/* Helper: */
|
||||
static inline unsigned
|
||||
ht_improve_hash(unsigned h)
|
||||
ht_improve_hash_(unsigned h)
|
||||
{
|
||||
/* Aim to protect against poor hash functions by adding logic here
|
||||
* - logic taken from java 1.4 hashtable source */
|
||||
@ -74,7 +74,7 @@ ht_improve_hash(unsigned h)
|
||||
#if 0
|
||||
/** Basic string hash function, from Java standard String.hashCode(). */
|
||||
static inline unsigned
|
||||
ht_string_hash(const char *s)
|
||||
ht_string_hash_(const char *s)
|
||||
{
|
||||
unsigned h = 0;
|
||||
int m = 1;
|
||||
@ -88,7 +88,7 @@ ht_string_hash(const char *s)
|
||||
|
||||
/** Basic string hash function, from Python's str.__hash__() */
|
||||
static inline unsigned
|
||||
ht_string_hash(const char *s)
|
||||
ht_string_hash_(const char *s)
|
||||
{
|
||||
unsigned h;
|
||||
const unsigned char *cp = (const unsigned char *)s;
|
||||
|
@ -177,24 +177,24 @@ struct evhttp {
|
||||
/* XXX most of these functions could be static. */
|
||||
|
||||
/* resets the connection; can be reused for more requests */
|
||||
void evhttp_connection_reset(struct evhttp_connection *);
|
||||
void evhttp_connection_reset_(struct evhttp_connection *);
|
||||
|
||||
/* connects if necessary */
|
||||
int evhttp_connection_connect(struct evhttp_connection *);
|
||||
int evhttp_connection_connect_(struct evhttp_connection *);
|
||||
|
||||
/* notifies the current request that it failed; resets connection */
|
||||
void evhttp_connection_fail(struct evhttp_connection *,
|
||||
void evhttp_connection_fail_(struct evhttp_connection *,
|
||||
enum evhttp_connection_error error);
|
||||
|
||||
enum message_read_status;
|
||||
|
||||
enum message_read_status evhttp_parse_firstline(struct evhttp_request *, struct evbuffer*);
|
||||
enum message_read_status evhttp_parse_headers(struct evhttp_request *, struct evbuffer*);
|
||||
enum message_read_status evhttp_parse_firstline_(struct evhttp_request *, struct evbuffer*);
|
||||
enum message_read_status evhttp_parse_headers_(struct evhttp_request *, struct evbuffer*);
|
||||
|
||||
void evhttp_start_read(struct evhttp_connection *);
|
||||
void evhttp_start_read_(struct evhttp_connection *);
|
||||
|
||||
/* response sending HTML the data in the buffer */
|
||||
void evhttp_response_code(struct evhttp_request *, int, const char *);
|
||||
void evhttp_send_page(struct evhttp_request *, struct evbuffer *);
|
||||
void evhttp_response_code_(struct evhttp_request *, int, const char *);
|
||||
void evhttp_send_page_(struct evhttp_request *, struct evbuffer *);
|
||||
|
||||
#endif /* _HTTP_H */
|
||||
|
140
http.c
140
http.c
@ -678,7 +678,7 @@ evhttp_connection_incoming_fail(struct evhttp_request *req,
|
||||
* retry any pending requests, and inform the user. If it's incoming,
|
||||
* delegates to evhttp_connection_incoming_fail(). */
|
||||
void
|
||||
evhttp_connection_fail(struct evhttp_connection *evcon,
|
||||
evhttp_connection_fail_(struct evhttp_connection *evcon,
|
||||
enum evhttp_connection_error error)
|
||||
{
|
||||
struct evhttp_request* req = TAILQ_FIRST(&evcon->requests);
|
||||
@ -720,11 +720,11 @@ evhttp_connection_fail(struct evhttp_connection *evcon,
|
||||
evhttp_request_free(req);
|
||||
|
||||
/* reset the connection */
|
||||
evhttp_connection_reset(evcon);
|
||||
evhttp_connection_reset_(evcon);
|
||||
|
||||
/* We are trying the next request that was queued on us */
|
||||
if (TAILQ_FIRST(&evcon->requests) != NULL)
|
||||
evhttp_connection_connect(evcon);
|
||||
evhttp_connection_connect_(evcon);
|
||||
|
||||
/* inform the user */
|
||||
if (cb != NULL)
|
||||
@ -770,7 +770,7 @@ evhttp_connection_done(struct evhttp_connection *evcon)
|
||||
|
||||
/* check if we got asked to close the connection */
|
||||
if (need_close)
|
||||
evhttp_connection_reset(evcon);
|
||||
evhttp_connection_reset_(evcon);
|
||||
|
||||
if (TAILQ_FIRST(&evcon->requests) != NULL) {
|
||||
/*
|
||||
@ -778,7 +778,7 @@ evhttp_connection_done(struct evhttp_connection *evcon)
|
||||
* and deal with the next request.
|
||||
*/
|
||||
if (!evhttp_connected(evcon))
|
||||
evhttp_connection_connect(evcon);
|
||||
evhttp_connection_connect_(evcon);
|
||||
else
|
||||
evhttp_request_dispatch(evcon);
|
||||
} else if (!need_close) {
|
||||
@ -917,10 +917,10 @@ evhttp_read_trailer(struct evhttp_connection *evcon, struct evhttp_request *req)
|
||||
{
|
||||
struct evbuffer *buf = bufferevent_get_input(evcon->bufev);
|
||||
|
||||
switch (evhttp_parse_headers(req, buf)) {
|
||||
switch (evhttp_parse_headers_(req, buf)) {
|
||||
case DATA_CORRUPTED:
|
||||
case DATA_TOO_LONG:
|
||||
evhttp_connection_fail(evcon, EVCON_HTTP_INVALID_HEADER);
|
||||
evhttp_connection_fail_(evcon, EVCON_HTTP_INVALID_HEADER);
|
||||
break;
|
||||
case ALL_DATA_READ:
|
||||
bufferevent_disable(evcon->bufev, EV_READ);
|
||||
@ -949,7 +949,7 @@ evhttp_read_body(struct evhttp_connection *evcon, struct evhttp_request *req)
|
||||
case DATA_CORRUPTED:
|
||||
case DATA_TOO_LONG:/*separate error for this? XXX */
|
||||
/* corrupted data */
|
||||
evhttp_connection_fail(evcon,
|
||||
evhttp_connection_fail_(evcon,
|
||||
EVCON_HTTP_INVALID_HEADER);
|
||||
return;
|
||||
case REQUEST_CANCELED:
|
||||
@ -963,7 +963,7 @@ evhttp_read_body(struct evhttp_connection *evcon, struct evhttp_request *req)
|
||||
} else if (req->ntoread < 0) {
|
||||
/* Read until connection close. */
|
||||
if ((size_t)(req->body_size + evbuffer_get_length(buf)) < req->body_size) {
|
||||
evhttp_connection_fail(evcon, EVCON_HTTP_INVALID_HEADER);
|
||||
evhttp_connection_fail_(evcon, EVCON_HTTP_INVALID_HEADER);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -988,7 +988,7 @@ evhttp_read_body(struct evhttp_connection *evcon, struct evhttp_request *req)
|
||||
/* XXX: The above casted comparison must checked for overflow */
|
||||
/* failed body length test */
|
||||
event_debug(("Request body is too long"));
|
||||
evhttp_connection_fail(evcon,
|
||||
evhttp_connection_fail_(evcon,
|
||||
EVCON_HTTP_INVALID_HEADER);
|
||||
return;
|
||||
}
|
||||
@ -1017,7 +1017,7 @@ evhttp_read_body(struct evhttp_connection *evcon, struct evhttp_request *req)
|
||||
}
|
||||
|
||||
#define get_deferred_queue(evcon) \
|
||||
(event_base_get_deferred_cb_queue((evcon)->base))
|
||||
(event_base_get_deferred_cb_queue_((evcon)->base))
|
||||
|
||||
/*
|
||||
* Gets called when more data becomes available
|
||||
@ -1030,7 +1030,7 @@ evhttp_read_cb(struct bufferevent *bufev, void *arg)
|
||||
struct evhttp_request *req = TAILQ_FIRST(&evcon->requests);
|
||||
|
||||
/* Cancel if it's pending. */
|
||||
event_deferred_cb_cancel(get_deferred_queue(evcon),
|
||||
event_deferred_cb_cancel_(get_deferred_queue(evcon),
|
||||
&evcon->read_more_deferred_cb);
|
||||
|
||||
switch (evcon->state) {
|
||||
@ -1066,7 +1066,7 @@ evhttp_read_cb(struct bufferevent *bufev, void *arg)
|
||||
__func__, EV_SIZE_ARG(total_len)));
|
||||
#endif
|
||||
|
||||
evhttp_connection_reset(evcon);
|
||||
evhttp_connection_reset_(evcon);
|
||||
}
|
||||
break;
|
||||
case EVCON_DISCONNECTED:
|
||||
@ -1097,7 +1097,7 @@ evhttp_write_connectioncb(struct evhttp_connection *evcon, void *arg)
|
||||
/* We are done writing our header and are now expecting the response */
|
||||
req->kind = EVHTTP_RESPONSE;
|
||||
|
||||
evhttp_start_read(evcon);
|
||||
evhttp_start_read_(evcon);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1118,7 +1118,7 @@ evhttp_connection_free(struct evhttp_connection *evcon)
|
||||
/* remove all requests that might be queued on this
|
||||
* connection. for server connections, this should be empty.
|
||||
* because it gets dequeued either in evhttp_connection_done or
|
||||
* evhttp_connection_fail.
|
||||
* evhttp_connection_fail_.
|
||||
*/
|
||||
while ((req = TAILQ_FIRST(&evcon->requests)) != NULL) {
|
||||
TAILQ_REMOVE(&evcon->requests, req, next);
|
||||
@ -1138,7 +1138,7 @@ evhttp_connection_free(struct evhttp_connection *evcon)
|
||||
if (evcon->bufev != NULL)
|
||||
bufferevent_free(evcon->bufev);
|
||||
|
||||
event_deferred_cb_cancel(get_deferred_queue(evcon),
|
||||
event_deferred_cb_cancel_(get_deferred_queue(evcon),
|
||||
&evcon->read_more_deferred_cb);
|
||||
|
||||
if (evcon->fd != -1) {
|
||||
@ -1200,7 +1200,7 @@ evhttp_request_dispatch(struct evhttp_connection* evcon)
|
||||
/* Reset our connection state: disables reading/writing, closes our fd (if
|
||||
* any), clears out buffers, and puts us in state DISCONNECTED. */
|
||||
void
|
||||
evhttp_connection_reset(struct evhttp_connection *evcon)
|
||||
evhttp_connection_reset_(struct evhttp_connection *evcon)
|
||||
{
|
||||
struct evbuffer *tmp;
|
||||
|
||||
@ -1213,9 +1213,9 @@ evhttp_connection_reset(struct evhttp_connection *evcon)
|
||||
bufferevent is connecting, then you can't actually stop the
|
||||
bufferevent from trying to connect with bufferevent_disable(). The
|
||||
connect will never trigger, since we close the fd, but the timeout
|
||||
might. That caused an assertion failure in evhttp_connection_fail.
|
||||
might. That caused an assertion failure in evhttp_connection_fail_.
|
||||
*/
|
||||
bufferevent_disable_hard(evcon->bufev, EV_READ|EV_WRITE);
|
||||
bufferevent_disable_hard_(evcon->bufev, EV_READ|EV_WRITE);
|
||||
|
||||
if (evcon->fd != -1) {
|
||||
/* inform interested parties about connection close */
|
||||
@ -1258,7 +1258,7 @@ evhttp_connection_retry(evutil_socket_t fd, short what, void *arg)
|
||||
struct evhttp_connection *evcon = arg;
|
||||
|
||||
evcon->state = EVCON_DISCONNECTED;
|
||||
evhttp_connection_connect(evcon);
|
||||
evhttp_connection_connect_(evcon);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1287,7 +1287,7 @@ evhttp_connection_cb_cleanup(struct evhttp_connection *evcon)
|
||||
evcon->retry_cnt++;
|
||||
return;
|
||||
}
|
||||
evhttp_connection_reset(evcon);
|
||||
evhttp_connection_reset_(evcon);
|
||||
|
||||
/*
|
||||
* User callback can do evhttp_make_request() on the same
|
||||
@ -1361,17 +1361,17 @@ evhttp_error_cb(struct bufferevent *bufev, short what, void *arg)
|
||||
* disconnected.
|
||||
*/
|
||||
EVUTIL_ASSERT(evcon->state == EVCON_IDLE);
|
||||
evhttp_connection_reset(evcon);
|
||||
evhttp_connection_reset_(evcon);
|
||||
return;
|
||||
}
|
||||
|
||||
if (what & BEV_EVENT_TIMEOUT) {
|
||||
evhttp_connection_fail(evcon, EVCON_HTTP_TIMEOUT);
|
||||
evhttp_connection_fail_(evcon, EVCON_HTTP_TIMEOUT);
|
||||
} else if (what & (BEV_EVENT_EOF|BEV_EVENT_ERROR)) {
|
||||
evhttp_connection_fail(evcon, EVCON_HTTP_EOF);
|
||||
evhttp_connection_fail_(evcon, EVCON_HTTP_EOF);
|
||||
} else if (what == BEV_EVENT_CONNECTED) {
|
||||
} else {
|
||||
evhttp_connection_fail(evcon, EVCON_HTTP_BUFFER_ERROR);
|
||||
evhttp_connection_fail_(evcon, EVCON_HTTP_BUFFER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1802,7 +1802,7 @@ evhttp_add_header_internal(struct evkeyvalq *headers,
|
||||
*/
|
||||
|
||||
enum message_read_status
|
||||
evhttp_parse_firstline(struct evhttp_request *req, struct evbuffer *buffer)
|
||||
evhttp_parse_firstline_(struct evhttp_request *req, struct evbuffer *buffer)
|
||||
{
|
||||
char *line;
|
||||
enum message_read_status status = ALL_DATA_READ;
|
||||
@ -1867,7 +1867,7 @@ evhttp_append_to_last_header(struct evkeyvalq *headers, const char *line)
|
||||
}
|
||||
|
||||
enum message_read_status
|
||||
evhttp_parse_headers(struct evhttp_request *req, struct evbuffer* buffer)
|
||||
evhttp_parse_headers_(struct evhttp_request *req, struct evbuffer* buffer)
|
||||
{
|
||||
enum message_read_status errcode = DATA_CORRUPTED;
|
||||
char *line;
|
||||
@ -2007,7 +2007,7 @@ evhttp_get_body(struct evhttp_connection *evcon, struct evhttp_request *req)
|
||||
req->ntoread = -1;
|
||||
} else {
|
||||
if (evhttp_get_body_length(req) == -1) {
|
||||
evhttp_connection_fail(evcon,
|
||||
evhttp_connection_fail_(evcon,
|
||||
EVCON_HTTP_INVALID_HEADER);
|
||||
return;
|
||||
}
|
||||
@ -2059,12 +2059,12 @@ evhttp_read_firstline(struct evhttp_connection *evcon,
|
||||
{
|
||||
enum message_read_status res;
|
||||
|
||||
res = evhttp_parse_firstline(req, bufferevent_get_input(evcon->bufev));
|
||||
res = evhttp_parse_firstline_(req, bufferevent_get_input(evcon->bufev));
|
||||
if (res == DATA_CORRUPTED || res == DATA_TOO_LONG) {
|
||||
/* Error while reading, terminate */
|
||||
event_debug(("%s: bad header lines on %d\n",
|
||||
__func__, evcon->fd));
|
||||
evhttp_connection_fail(evcon, EVCON_HTTP_INVALID_HEADER);
|
||||
evhttp_connection_fail_(evcon, EVCON_HTTP_INVALID_HEADER);
|
||||
return;
|
||||
} else if (res == MORE_DATA_EXPECTED) {
|
||||
/* Need more header lines */
|
||||
@ -2082,11 +2082,11 @@ evhttp_read_header(struct evhttp_connection *evcon,
|
||||
enum message_read_status res;
|
||||
evutil_socket_t fd = evcon->fd;
|
||||
|
||||
res = evhttp_parse_headers(req, bufferevent_get_input(evcon->bufev));
|
||||
res = evhttp_parse_headers_(req, bufferevent_get_input(evcon->bufev));
|
||||
if (res == DATA_CORRUPTED || res == DATA_TOO_LONG) {
|
||||
/* Error while reading, terminate */
|
||||
event_debug(("%s: bad header lines on %d\n", __func__, fd));
|
||||
evhttp_connection_fail(evcon, EVCON_HTTP_INVALID_HEADER);
|
||||
evhttp_connection_fail_(evcon, EVCON_HTTP_INVALID_HEADER);
|
||||
return;
|
||||
} else if (res == MORE_DATA_EXPECTED) {
|
||||
/* Need more header lines */
|
||||
@ -2108,7 +2108,7 @@ evhttp_read_header(struct evhttp_connection *evcon,
|
||||
case EVHTTP_RESPONSE:
|
||||
/* Start over if we got a 100 Continue response. */
|
||||
if (req->response_code == 100) {
|
||||
evhttp_start_read(evcon);
|
||||
evhttp_start_read_(evcon);
|
||||
return;
|
||||
}
|
||||
if (!evhttp_response_needs_body(req)) {
|
||||
@ -2126,7 +2126,7 @@ evhttp_read_header(struct evhttp_connection *evcon,
|
||||
|
||||
default:
|
||||
event_warnx("%s: bad header on %d", __func__, fd);
|
||||
evhttp_connection_fail(evcon, EVCON_HTTP_INVALID_HEADER);
|
||||
evhttp_connection_fail_(evcon, EVCON_HTTP_INVALID_HEADER);
|
||||
break;
|
||||
}
|
||||
/* request may have been freed above */
|
||||
@ -2197,7 +2197,7 @@ evhttp_connection_base_bufferevent_new(struct event_base *base, struct evdns_bas
|
||||
bufferevent_base_set(base, evcon->bufev);
|
||||
}
|
||||
|
||||
event_deferred_cb_init(&evcon->read_more_deferred_cb,
|
||||
event_deferred_cb_init_(&evcon->read_more_deferred_cb,
|
||||
evhttp_deferred_read_cb, evcon);
|
||||
|
||||
evcon->dns_base = dnsbase;
|
||||
@ -2297,12 +2297,12 @@ evhttp_connection_get_peer(struct evhttp_connection *evcon,
|
||||
}
|
||||
|
||||
int
|
||||
evhttp_connection_connect(struct evhttp_connection *evcon)
|
||||
evhttp_connection_connect_(struct evhttp_connection *evcon)
|
||||
{
|
||||
if (evcon->state == EVCON_CONNECTING)
|
||||
return (0);
|
||||
|
||||
evhttp_connection_reset(evcon);
|
||||
evhttp_connection_reset_(evcon);
|
||||
|
||||
EVUTIL_ASSERT(!(evcon->flags & EVHTTP_CON_INCOMING));
|
||||
evcon->flags |= EVHTTP_CON_OUTGOING;
|
||||
@ -2384,9 +2384,9 @@ evhttp_make_request(struct evhttp_connection *evcon,
|
||||
|
||||
/* If the connection object is not connected; make it so */
|
||||
if (!evhttp_connected(evcon)) {
|
||||
int res = evhttp_connection_connect(evcon);
|
||||
/* evhttp_connection_fail(), which is called through
|
||||
* evhttp_connection_connect(), assumes that req lies in
|
||||
int res = evhttp_connection_connect_(evcon);
|
||||
/* evhttp_connection_fail_(), which is called through
|
||||
* evhttp_connection_connect_(), assumes that req lies in
|
||||
* evcon->requests. Thus, enqueue the request in advance and r
|
||||
* it in the error case. */
|
||||
if (res != 0)
|
||||
@ -2416,7 +2416,7 @@ evhttp_cancel_request(struct evhttp_request *req)
|
||||
/* it's currently being worked on, so reset
|
||||
* the connection.
|
||||
*/
|
||||
evhttp_connection_fail(evcon,
|
||||
evhttp_connection_fail_(evcon,
|
||||
EVCON_HTTP_REQUEST_CANCEL);
|
||||
|
||||
/* connection fail freed the request */
|
||||
@ -2438,7 +2438,7 @@ evhttp_cancel_request(struct evhttp_request *req)
|
||||
*/
|
||||
|
||||
void
|
||||
evhttp_start_read(struct evhttp_connection *evcon)
|
||||
evhttp_start_read_(struct evhttp_connection *evcon)
|
||||
{
|
||||
/* Set up an event to read the headers */
|
||||
bufferevent_disable(evcon->bufev, EV_WRITE);
|
||||
@ -2454,7 +2454,7 @@ evhttp_start_read(struct evhttp_connection *evcon)
|
||||
/* If there's still data pending, process it next time through the
|
||||
* loop. Don't do it now; that could get recusive. */
|
||||
if (evbuffer_get_length(bufferevent_get_input(evcon->bufev))) {
|
||||
event_deferred_cb_schedule(get_deferred_queue(evcon),
|
||||
event_deferred_cb_schedule_(get_deferred_queue(evcon),
|
||||
&evcon->read_more_deferred_cb);
|
||||
}
|
||||
}
|
||||
@ -2510,11 +2510,11 @@ evhttp_send_error(struct evhttp_request *req, int error, const char *reason)
|
||||
reason = evhttp_response_phrase_internal(error);
|
||||
}
|
||||
|
||||
evhttp_response_code(req, error, reason);
|
||||
evhttp_response_code_(req, error, reason);
|
||||
|
||||
evbuffer_add_printf(buf, ERR_FORMAT, error, reason, reason);
|
||||
|
||||
evhttp_send_page(req, buf);
|
||||
evhttp_send_page_(req, buf);
|
||||
|
||||
evbuffer_free(buf);
|
||||
#undef ERR_FORMAT
|
||||
@ -2551,7 +2551,7 @@ void
|
||||
evhttp_send_reply(struct evhttp_request *req, int code, const char *reason,
|
||||
struct evbuffer *databuf)
|
||||
{
|
||||
evhttp_response_code(req, code, reason);
|
||||
evhttp_response_code_(req, code, reason);
|
||||
|
||||
evhttp_send(req, databuf);
|
||||
}
|
||||
@ -2560,7 +2560,7 @@ void
|
||||
evhttp_send_reply_start(struct evhttp_request *req, int code,
|
||||
const char *reason)
|
||||
{
|
||||
evhttp_response_code(req, code, reason);
|
||||
evhttp_response_code_(req, code, reason);
|
||||
if (evhttp_find_header(req->output_headers, "Content-Length") == NULL &&
|
||||
REQ_VERSION_ATLEAST(req, 1, 1) &&
|
||||
evhttp_response_needs_body(req)) {
|
||||
@ -2726,7 +2726,7 @@ evhttp_response_phrase_internal(int code)
|
||||
}
|
||||
|
||||
void
|
||||
evhttp_response_code(struct evhttp_request *req, int code, const char *reason)
|
||||
evhttp_response_code_(struct evhttp_request *req, int code, const char *reason)
|
||||
{
|
||||
req->kind = EVHTTP_RESPONSE;
|
||||
req->response_code = code;
|
||||
@ -2742,7 +2742,7 @@ evhttp_response_code(struct evhttp_request *req, int code, const char *reason)
|
||||
}
|
||||
|
||||
void
|
||||
evhttp_send_page(struct evhttp_request *req, struct evbuffer *databuf)
|
||||
evhttp_send_page_(struct evhttp_request *req, struct evbuffer *databuf)
|
||||
{
|
||||
if (!req->major || !req->minor) {
|
||||
req->major = 1;
|
||||
@ -2750,7 +2750,7 @@ evhttp_send_page(struct evhttp_request *req, struct evbuffer *databuf)
|
||||
}
|
||||
|
||||
if (req->kind != EVHTTP_RESPONSE)
|
||||
evhttp_response_code(req, 200, "OK");
|
||||
evhttp_response_code_(req, 200, "OK");
|
||||
|
||||
evhttp_clear_headers(req->output_headers);
|
||||
evhttp_add_header(req->output_headers, "Content-Type", "text/html");
|
||||
@ -2851,8 +2851,8 @@ evhttp_decode_uri_internal(
|
||||
decode_plus = 1;
|
||||
} else if (c == '+' && decode_plus) {
|
||||
c = ' ';
|
||||
} else if (c == '%' && EVUTIL_ISXDIGIT(uri[i+1]) &&
|
||||
EVUTIL_ISXDIGIT(uri[i+2])) {
|
||||
} else if (c == '%' && EVUTIL_ISXDIGIT_(uri[i+1]) &&
|
||||
EVUTIL_ISXDIGIT_(uri[i+2])) {
|
||||
char tmp[3];
|
||||
tmp[0] = uri[i+1];
|
||||
tmp[1] = uri[i+2];
|
||||
@ -3040,7 +3040,7 @@ prefix_suffix_match(const char *pattern, const char *name, int ignorecase)
|
||||
default:
|
||||
if (c != *name) {
|
||||
if (!ignorecase ||
|
||||
EVUTIL_TOLOWER(c) != EVUTIL_TOLOWER(*name))
|
||||
EVUTIL_TOLOWER_(c) != EVUTIL_TOLOWER_(*name))
|
||||
return (0);
|
||||
}
|
||||
++name;
|
||||
@ -3181,13 +3181,13 @@ evhttp_handle_request(struct evhttp_request *req, void *arg)
|
||||
return;
|
||||
}
|
||||
|
||||
evhttp_response_code(req, HTTP_NOTFOUND, "Not Found");
|
||||
evhttp_response_code_(req, HTTP_NOTFOUND, "Not Found");
|
||||
|
||||
evbuffer_add_printf(buf, ERR_FORMAT, escaped_html);
|
||||
|
||||
mm_free(escaped_html);
|
||||
|
||||
evhttp_send_page(req, buf);
|
||||
evhttp_send_page_(req, buf);
|
||||
|
||||
evbuffer_free(buf);
|
||||
#undef ERR_FORMAT
|
||||
@ -3766,7 +3766,7 @@ evhttp_request_get_host(struct evhttp_request *req)
|
||||
to be consistent with uri_elems case above. */
|
||||
if (host) {
|
||||
p = host + strlen(host) - 1;
|
||||
while (p > host && EVUTIL_ISDIGIT(*p))
|
||||
while (p > host && EVUTIL_ISDIGIT_(*p))
|
||||
--p;
|
||||
if (p > host && *p == ':') {
|
||||
len = p - host;
|
||||
@ -3899,7 +3899,7 @@ evhttp_associate_new_request_with_connection(struct evhttp_connection *evcon)
|
||||
req->kind = EVHTTP_REQUEST;
|
||||
|
||||
|
||||
evhttp_start_read(evcon);
|
||||
evhttp_start_read_(evcon);
|
||||
|
||||
return (0);
|
||||
}
|
||||
@ -3984,7 +3984,7 @@ bind_socket_ai(struct evutil_addrinfo *ai, int reuse)
|
||||
int serrno;
|
||||
|
||||
/* Create listen socket */
|
||||
fd = evutil_socket(ai ? ai->ai_family : AF_INET,
|
||||
fd = evutil_socket_(ai ? ai->ai_family : AF_INET,
|
||||
SOCK_STREAM|EVUTIL_SOCK_NONBLOCK|EVUTIL_SOCK_CLOEXEC, 0);
|
||||
if (fd == -1) {
|
||||
event_sock_warn(-1, "socket");
|
||||
@ -4097,10 +4097,10 @@ scheme_ok(const char *s, const char *eos)
|
||||
EVUTIL_ASSERT(eos >= s);
|
||||
if (s == eos)
|
||||
return 0;
|
||||
if (!EVUTIL_ISALPHA(*s))
|
||||
if (!EVUTIL_ISALPHA_(*s))
|
||||
return 0;
|
||||
while (++s < eos) {
|
||||
if (! EVUTIL_ISALNUM(*s) &&
|
||||
if (! EVUTIL_ISALNUM_(*s) &&
|
||||
*s != '+' && *s != '-' && *s != '.')
|
||||
return 0;
|
||||
}
|
||||
@ -4119,8 +4119,8 @@ userinfo_ok(const char *s, const char *eos)
|
||||
*s == ':')
|
||||
++s;
|
||||
else if (*s == '%' && s+2 < eos &&
|
||||
EVUTIL_ISXDIGIT(s[1]) &&
|
||||
EVUTIL_ISXDIGIT(s[2]))
|
||||
EVUTIL_ISXDIGIT_(s[1]) &&
|
||||
EVUTIL_ISXDIGIT_(s[2]))
|
||||
s += 3;
|
||||
else
|
||||
return 0;
|
||||
@ -4136,8 +4136,8 @@ regname_ok(const char *s, const char *eos)
|
||||
strchr(SUBDELIMS, *s))
|
||||
++s;
|
||||
else if (*s == '%' &&
|
||||
EVUTIL_ISXDIGIT(s[1]) &&
|
||||
EVUTIL_ISXDIGIT(s[2]))
|
||||
EVUTIL_ISXDIGIT_(s[1]) &&
|
||||
EVUTIL_ISXDIGIT_(s[2]))
|
||||
s += 3;
|
||||
else
|
||||
return 0;
|
||||
@ -4150,7 +4150,7 @@ parse_port(const char *s, const char *eos)
|
||||
{
|
||||
int portnum = 0;
|
||||
while (s < eos) {
|
||||
if (! EVUTIL_ISDIGIT(*s))
|
||||
if (! EVUTIL_ISDIGIT_(*s))
|
||||
return -1;
|
||||
portnum = (portnum * 10) + (*s - '0');
|
||||
if (portnum < 0)
|
||||
@ -4172,10 +4172,10 @@ bracket_addr_ok(const char *s, const char *eos)
|
||||
*/
|
||||
s += 2; /* skip [v */
|
||||
--eos;
|
||||
if (!EVUTIL_ISXDIGIT(*s)) /*require at least one*/
|
||||
if (!EVUTIL_ISXDIGIT_(*s)) /*require at least one*/
|
||||
return 0;
|
||||
while (s < eos && *s != '.') {
|
||||
if (EVUTIL_ISXDIGIT(*s))
|
||||
if (EVUTIL_ISXDIGIT_(*s))
|
||||
++s;
|
||||
else
|
||||
return 0;
|
||||
@ -4235,7 +4235,7 @@ parse_authority(struct evhttp_uri *uri, char *s, char *eos)
|
||||
cp = s;
|
||||
}
|
||||
/* Optionally, we end with ":port" */
|
||||
for (port=eos-1; port >= cp && EVUTIL_ISDIGIT(*port); --port)
|
||||
for (port=eos-1; port >= cp && EVUTIL_ISDIGIT_(*port); --port)
|
||||
;
|
||||
if (port >= cp && *port == ':') {
|
||||
if (port+1 == eos) /* Leave port unspecified; the RFC allows a
|
||||
@ -4319,8 +4319,8 @@ end_of_path(char *cp, enum uri_part part, unsigned flags)
|
||||
strchr(SUBDELIMS, *cp) ||
|
||||
*cp == ':' || *cp == '@' || *cp == '/')
|
||||
++cp;
|
||||
else if (*cp == '%' && EVUTIL_ISXDIGIT(cp[1]) &&
|
||||
EVUTIL_ISXDIGIT(cp[2]))
|
||||
else if (*cp == '%' && EVUTIL_ISXDIGIT_(cp[1]) &&
|
||||
EVUTIL_ISXDIGIT_(cp[2]))
|
||||
cp += 3;
|
||||
else if (*cp == '?' && part != PART_PATH)
|
||||
++cp;
|
||||
|
@ -92,7 +92,7 @@ struct event_iocp_port {
|
||||
HANDLE *shutdownSemaphore;
|
||||
};
|
||||
|
||||
const struct win32_extension_fns *event_get_win32_extension_fns(void);
|
||||
const struct win32_extension_fns *event_get_win32_extension_fns_(void);
|
||||
#else
|
||||
/* Dummy definition so we can test-compile more things on unix. */
|
||||
struct event_overlapped {
|
||||
@ -106,13 +106,13 @@ struct event_overlapped {
|
||||
@param cb The callback that should be invoked once the IO operation has
|
||||
finished.
|
||||
*/
|
||||
void event_overlapped_init(struct event_overlapped *, iocp_callback cb);
|
||||
void event_overlapped_init_(struct event_overlapped *, iocp_callback cb);
|
||||
|
||||
/** Allocate and return a new evbuffer that supports overlapped IO on a given
|
||||
socket. The socket must be associated with an IO completion port using
|
||||
event_iocp_port_associate.
|
||||
event_iocp_port_associate_.
|
||||
*/
|
||||
struct evbuffer *evbuffer_overlapped_new(evutil_socket_t fd);
|
||||
struct evbuffer *evbuffer_overlapped_new_(evutil_socket_t fd);
|
||||
|
||||
/** XXXX Document (nickm) */
|
||||
evutil_socket_t evbuffer_overlapped_get_fd_(struct evbuffer *buf);
|
||||
@ -123,44 +123,44 @@ void evbuffer_overlapped_set_fd_(struct evbuffer *buf, evutil_socket_t fd);
|
||||
|
||||
An evbuffer can only have one read pending at a time. While the read
|
||||
is in progress, no other data may be added to the end of the buffer.
|
||||
The buffer must be created with event_overlapped_init().
|
||||
evbuffer_commit_read() must be called in the completion callback.
|
||||
The buffer must be created with event_overlapped_init_().
|
||||
evbuffer_commit_read_() must be called in the completion callback.
|
||||
|
||||
@param buf The buffer to read onto
|
||||
@param n The number of bytes to try to read.
|
||||
@param ol Overlapped object with associated completion callback.
|
||||
@return 0 on success, -1 on error.
|
||||
*/
|
||||
int evbuffer_launch_read(struct evbuffer *buf, size_t n, struct event_overlapped *ol);
|
||||
int evbuffer_launch_read_(struct evbuffer *buf, size_t n, struct event_overlapped *ol);
|
||||
|
||||
/** Start writing data from the start of an evbuffer.
|
||||
|
||||
An evbuffer can only have one write pending at a time. While the write is
|
||||
in progress, no other data may be removed from the front of the buffer.
|
||||
The buffer must be created with event_overlapped_init().
|
||||
evbuffer_commit_write() must be called in the completion callback.
|
||||
The buffer must be created with event_overlapped_init_().
|
||||
evbuffer_commit_write_() must be called in the completion callback.
|
||||
|
||||
@param buf The buffer to read onto
|
||||
@param n The number of bytes to try to read.
|
||||
@param ol Overlapped object with associated completion callback.
|
||||
@return 0 on success, -1 on error.
|
||||
*/
|
||||
int evbuffer_launch_write(struct evbuffer *buf, ev_ssize_t n, struct event_overlapped *ol);
|
||||
int evbuffer_launch_write_(struct evbuffer *buf, ev_ssize_t n, struct event_overlapped *ol);
|
||||
|
||||
/** XXX document */
|
||||
void evbuffer_commit_read(struct evbuffer *, ev_ssize_t);
|
||||
void evbuffer_commit_write(struct evbuffer *, ev_ssize_t);
|
||||
void evbuffer_commit_read_(struct evbuffer *, ev_ssize_t);
|
||||
void evbuffer_commit_write_(struct evbuffer *, ev_ssize_t);
|
||||
|
||||
/** Create an IOCP, and launch its worker threads. Internal use only.
|
||||
|
||||
This interface is unstable, and will change.
|
||||
*/
|
||||
struct event_iocp_port *event_iocp_port_launch(int n_cpus);
|
||||
struct event_iocp_port *event_iocp_port_launch_(int n_cpus);
|
||||
|
||||
/** Associate a file descriptor with an iocp, such that overlapped IO on the
|
||||
fd will happen on one of the iocp's worker threads.
|
||||
*/
|
||||
int event_iocp_port_associate(struct event_iocp_port *port, evutil_socket_t fd,
|
||||
int event_iocp_port_associate_(struct event_iocp_port *port, evutil_socket_t fd,
|
||||
ev_uintptr_t key);
|
||||
|
||||
/** Tell all threads serving an iocp to stop. Wait for up to waitMsec for all
|
||||
@ -169,29 +169,29 @@ int event_iocp_port_associate(struct event_iocp_port *port, evutil_socket_t fd,
|
||||
0. Otherwise, return -1. If you get a -1 return value, it is safe to call
|
||||
this function again.
|
||||
*/
|
||||
int event_iocp_shutdown(struct event_iocp_port *port, long waitMsec);
|
||||
int event_iocp_shutdown_(struct event_iocp_port *port, long waitMsec);
|
||||
|
||||
/* FIXME document. */
|
||||
int event_iocp_activate_overlapped(struct event_iocp_port *port,
|
||||
int event_iocp_activate_overlapped_(struct event_iocp_port *port,
|
||||
struct event_overlapped *o,
|
||||
ev_uintptr_t key, ev_uint32_t n_bytes);
|
||||
|
||||
struct event_base;
|
||||
/* FIXME document. */
|
||||
struct event_iocp_port *event_base_get_iocp(struct event_base *base);
|
||||
struct event_iocp_port *event_base_get_iocp_(struct event_base *base);
|
||||
|
||||
/* FIXME document. */
|
||||
int event_base_start_iocp(struct event_base *base, int n_cpus);
|
||||
void event_base_stop_iocp(struct event_base *base);
|
||||
int event_base_start_iocp_(struct event_base *base, int n_cpus);
|
||||
void event_base_stop_iocp_(struct event_base *base);
|
||||
|
||||
/* FIXME document. */
|
||||
struct bufferevent *bufferevent_async_new(struct event_base *base,
|
||||
struct bufferevent *bufferevent_async_new_(struct event_base *base,
|
||||
evutil_socket_t fd, int options);
|
||||
|
||||
/* FIXME document. */
|
||||
void bufferevent_async_set_connected(struct bufferevent *bev);
|
||||
int bufferevent_async_can_connect(struct bufferevent *bev);
|
||||
int bufferevent_async_connect(struct bufferevent *bev, evutil_socket_t fd,
|
||||
void bufferevent_async_set_connected_(struct bufferevent *bev);
|
||||
int bufferevent_async_can_connect_(struct bufferevent *bev);
|
||||
int bufferevent_async_connect_(struct bufferevent *bev, evutil_socket_t fd,
|
||||
const struct sockaddr *sa, int socklen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
12
kqueue.c
12
kqueue.c
@ -88,8 +88,8 @@ static void kq_dealloc(struct event_base *);
|
||||
const struct eventop kqops = {
|
||||
"kqueue",
|
||||
kq_init,
|
||||
event_changelist_add,
|
||||
event_changelist_del,
|
||||
event_changelist_add_,
|
||||
event_changelist_del_,
|
||||
kq_dispatch,
|
||||
kq_dealloc,
|
||||
1 /* need reinit */,
|
||||
@ -267,7 +267,7 @@ kq_dispatch(struct event_base *base, struct timeval *tv)
|
||||
if (n_changes < 0)
|
||||
return -1;
|
||||
|
||||
event_changelist_remove_all(&base->changelist, base);
|
||||
event_changelist_remove_all_(&base->changelist, base);
|
||||
|
||||
/* steal the changes array in case some broken code tries to call
|
||||
* dispatch twice at once. */
|
||||
@ -375,9 +375,9 @@ kq_dispatch(struct event_base *base, struct timeval *tv)
|
||||
continue;
|
||||
|
||||
if (events[i].filter == EVFILT_SIGNAL) {
|
||||
evmap_signal_active(base, events[i].ident, 1);
|
||||
evmap_signal_active_(base, events[i].ident, 1);
|
||||
} else {
|
||||
evmap_io_active(base, events[i].ident, which | EV_ET);
|
||||
evmap_io_active_(base, events[i].ident, which | EV_ET);
|
||||
}
|
||||
}
|
||||
|
||||
@ -407,7 +407,7 @@ static void
|
||||
kq_dealloc(struct event_base *base)
|
||||
{
|
||||
struct kqop *kqop = base->evbase;
|
||||
evsig_dealloc(base);
|
||||
evsig_dealloc_(base);
|
||||
kqop_free(kqop);
|
||||
}
|
||||
|
||||
|
40
listener.c
40
listener.c
@ -160,9 +160,9 @@ evconnlistener_new(struct event_base *base,
|
||||
struct evconnlistener_event *lev;
|
||||
|
||||
#ifdef _WIN32
|
||||
if (base && event_base_get_iocp(base)) {
|
||||
if (base && event_base_get_iocp_(base)) {
|
||||
const struct win32_extension_fns *ext =
|
||||
event_get_win32_extension_fns();
|
||||
event_get_win32_extension_fns_();
|
||||
if (ext->AcceptEx && ext->GetAcceptExSockaddrs)
|
||||
return evconnlistener_new_async(base, cb, ptr, flags,
|
||||
backlog, fd);
|
||||
@ -223,7 +223,7 @@ evconnlistener_new_bind(struct event_base *base, evconnlistener_cb cb,
|
||||
if (flags & LEV_OPT_CLOSE_ON_EXEC)
|
||||
socktype |= EVUTIL_SOCK_CLOEXEC;
|
||||
|
||||
fd = evutil_socket(family, socktype, 0);
|
||||
fd = evutil_socket_(family, socktype, 0);
|
||||
if (fd == -1)
|
||||
return NULL;
|
||||
|
||||
@ -388,7 +388,7 @@ listener_read_cb(evutil_socket_t fd, short what, void *p)
|
||||
while (1) {
|
||||
struct sockaddr_storage ss;
|
||||
ev_socklen_t socklen = sizeof(ss);
|
||||
evutil_socket_t new_fd = evutil_accept4(fd, (struct sockaddr*)&ss, &socklen, lev->accept4_flags);
|
||||
evutil_socket_t new_fd = evutil_accept4_(fd, (struct sockaddr*)&ss, &socklen, lev->accept4_flags);
|
||||
if (new_fd < 0)
|
||||
break;
|
||||
if (socklen == 0) {
|
||||
@ -459,7 +459,7 @@ iocp_listener_event_add(struct evconnlistener_iocp *lev)
|
||||
return;
|
||||
|
||||
lev->event_added = 1;
|
||||
event_base_add_virtual(lev->event_base);
|
||||
event_base_add_virtual_(lev->event_base);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -469,7 +469,7 @@ iocp_listener_event_del(struct evconnlistener_iocp *lev)
|
||||
return;
|
||||
|
||||
lev->event_added = 0;
|
||||
event_base_del_virtual(lev->event_base);
|
||||
event_base_del_virtual_(lev->event_base);
|
||||
}
|
||||
|
||||
static struct accepting_socket *
|
||||
@ -491,13 +491,13 @@ new_accepting_socket(struct evconnlistener_iocp *lev, int family)
|
||||
if (!res)
|
||||
return NULL;
|
||||
|
||||
event_overlapped_init(&res->overlapped, accepted_socket_cb);
|
||||
event_overlapped_init_(&res->overlapped, accepted_socket_cb);
|
||||
res->s = INVALID_SOCKET;
|
||||
res->lev = lev;
|
||||
res->buflen = buflen;
|
||||
res->family = family;
|
||||
|
||||
event_deferred_cb_init(&res->deferred,
|
||||
event_deferred_cb_init_(&res->deferred,
|
||||
accepted_socket_invoke_user_cb, res);
|
||||
|
||||
InitializeCriticalSectionAndSpinCount(&res->lock, 1000);
|
||||
@ -521,7 +521,7 @@ static int
|
||||
start_accepting(struct accepting_socket *as)
|
||||
{
|
||||
/* requires lock */
|
||||
const struct win32_extension_fns *ext = event_get_win32_extension_fns();
|
||||
const struct win32_extension_fns *ext = event_get_win32_extension_fns_();
|
||||
DWORD pending = 0;
|
||||
SOCKET s = socket(as->family, SOCK_STREAM, 0);
|
||||
int error = 0;
|
||||
@ -542,7 +542,7 @@ start_accepting(struct accepting_socket *as)
|
||||
if (!(as->lev->base.flags & LEV_OPT_LEAVE_SOCKETS_BLOCKING))
|
||||
evutil_make_socket_nonblocking(s);
|
||||
|
||||
if (event_iocp_port_associate(as->lev->port, s, 1) < 0) {
|
||||
if (event_iocp_port_associate_(as->lev->port, s, 1) < 0) {
|
||||
closesocket(s);
|
||||
return -1;
|
||||
}
|
||||
@ -565,8 +565,8 @@ start_accepting(struct accepting_socket *as)
|
||||
|
||||
report_err:
|
||||
as->error = error;
|
||||
event_deferred_cb_schedule(
|
||||
event_base_get_deferred_cb_queue(as->lev->event_base),
|
||||
event_deferred_cb_schedule_(
|
||||
event_base_get_deferred_cb_queue_(as->lev->event_base),
|
||||
&as->deferred);
|
||||
return 0;
|
||||
}
|
||||
@ -587,7 +587,7 @@ accepted_socket_invoke_user_cb(struct deferred_cb *dcb, void *arg)
|
||||
|
||||
struct sockaddr *sa_local=NULL, *sa_remote=NULL;
|
||||
int socklen_local=0, socklen_remote=0;
|
||||
const struct win32_extension_fns *ext = event_get_win32_extension_fns();
|
||||
const struct win32_extension_fns *ext = event_get_win32_extension_fns_();
|
||||
struct evconnlistener *lev = &as->lev->base;
|
||||
evutil_socket_t sock=-1;
|
||||
void *data;
|
||||
@ -657,8 +657,8 @@ accepted_socket_cb(struct event_overlapped *o, ev_uintptr_t key, ev_ssize_t n, i
|
||||
EnterCriticalSection(&as->lock);
|
||||
if (ok) {
|
||||
/* XXXX Don't do this if some EV_MT flag is set. */
|
||||
event_deferred_cb_schedule(
|
||||
event_base_get_deferred_cb_queue(as->lev->event_base),
|
||||
event_deferred_cb_schedule_(
|
||||
event_base_get_deferred_cb_queue_(as->lev->event_base),
|
||||
&as->deferred);
|
||||
LeaveCriticalSection(&as->lock);
|
||||
} else if (as->free_on_cb) {
|
||||
@ -682,8 +682,8 @@ accepted_socket_cb(struct event_overlapped *o, ev_uintptr_t key, ev_ssize_t n, i
|
||||
} else {
|
||||
as->error = WSAGetLastError();
|
||||
}
|
||||
event_deferred_cb_schedule(
|
||||
event_base_get_deferred_cb_queue(as->lev->event_base),
|
||||
event_deferred_cb_schedule_(
|
||||
event_base_get_deferred_cb_queue_(as->lev->event_base),
|
||||
&as->deferred);
|
||||
LeaveCriticalSection(&as->lock);
|
||||
}
|
||||
@ -795,7 +795,7 @@ evconnlistener_new_async(struct event_base *base,
|
||||
|
||||
flags |= LEV_OPT_THREADSAFE;
|
||||
|
||||
if (!base || !event_base_get_iocp(base))
|
||||
if (!base || !event_base_get_iocp_(base))
|
||||
goto err;
|
||||
|
||||
/* XXXX duplicate code */
|
||||
@ -822,12 +822,12 @@ evconnlistener_new_async(struct event_base *base,
|
||||
lev->base.refcnt = 1;
|
||||
lev->base.enabled = 1;
|
||||
|
||||
lev->port = event_base_get_iocp(base);
|
||||
lev->port = event_base_get_iocp_(base);
|
||||
lev->fd = fd;
|
||||
lev->event_base = base;
|
||||
|
||||
|
||||
if (event_iocp_port_associate(lev->port, fd, 1) < 0)
|
||||
if (event_iocp_port_associate_(lev->port, fd, 1) < 0)
|
||||
goto err_free_lev;
|
||||
|
||||
EVTHREAD_ALLOC_LOCK(lev->base.lock, EVTHREAD_LOCKTYPE_RECURSIVE);
|
||||
|
@ -42,18 +42,18 @@ typedef struct min_heap
|
||||
unsigned n, a;
|
||||
} min_heap_t;
|
||||
|
||||
static inline void min_heap_ctor(min_heap_t* s);
|
||||
static inline void min_heap_dtor(min_heap_t* s);
|
||||
static inline void min_heap_elem_init(struct event* e);
|
||||
static inline int min_heap_elt_is_top(const struct event *e);
|
||||
static inline int min_heap_empty(min_heap_t* s);
|
||||
static inline unsigned min_heap_size(min_heap_t* s);
|
||||
static inline struct event* min_heap_top(min_heap_t* s);
|
||||
static inline int min_heap_reserve(min_heap_t* s, unsigned n);
|
||||
static inline int min_heap_push(min_heap_t* s, struct event* e);
|
||||
static inline struct event* min_heap_pop(min_heap_t* s);
|
||||
static inline int min_heap_adjust(min_heap_t *s, struct event* e);
|
||||
static inline int min_heap_erase(min_heap_t* s, struct event* e);
|
||||
static inline void min_heap_ctor_(min_heap_t* s);
|
||||
static inline void min_heap_dtor_(min_heap_t* s);
|
||||
static inline void min_heap_elem_init_(struct event* e);
|
||||
static inline int min_heap_elt_is_top_(const struct event *e);
|
||||
static inline int min_heap_empty_(min_heap_t* s);
|
||||
static inline unsigned min_heap_size_(min_heap_t* s);
|
||||
static inline struct event* min_heap_top_(min_heap_t* s);
|
||||
static inline int min_heap_reserve_(min_heap_t* s, unsigned n);
|
||||
static inline int min_heap_push_(min_heap_t* s, struct event* e);
|
||||
static inline struct event* min_heap_pop_(min_heap_t* s);
|
||||
static inline int min_heap_adjust_(min_heap_t *s, struct event* e);
|
||||
static inline int min_heap_erase_(min_heap_t* s, struct event* e);
|
||||
static inline void min_heap_shift_up_(min_heap_t* s, unsigned hole_index, struct event* e);
|
||||
static inline void min_heap_shift_up_unconditional_(min_heap_t* s, unsigned hole_index, struct event* e);
|
||||
static inline void min_heap_shift_down_(min_heap_t* s, unsigned hole_index, struct event* e);
|
||||
@ -61,22 +61,22 @@ static inline void min_heap_shift_down_(min_heap_t* s, unsigned hole_index,
|
||||
#define min_heap_elem_greater(a, b) \
|
||||
(evutil_timercmp(&(a)->ev_timeout, &(b)->ev_timeout, >))
|
||||
|
||||
void min_heap_ctor(min_heap_t* s) { s->p = 0; s->n = 0; s->a = 0; }
|
||||
void min_heap_dtor(min_heap_t* s) { if (s->p) mm_free(s->p); }
|
||||
void min_heap_elem_init(struct event* e) { e->ev_timeout_pos.min_heap_idx = -1; }
|
||||
int min_heap_empty(min_heap_t* s) { return 0u == s->n; }
|
||||
unsigned min_heap_size(min_heap_t* s) { return s->n; }
|
||||
struct event* min_heap_top(min_heap_t* s) { return s->n ? *s->p : 0; }
|
||||
void min_heap_ctor_(min_heap_t* s) { s->p = 0; s->n = 0; s->a = 0; }
|
||||
void min_heap_dtor_(min_heap_t* s) { if (s->p) mm_free(s->p); }
|
||||
void min_heap_elem_init_(struct event* e) { e->ev_timeout_pos.min_heap_idx = -1; }
|
||||
int min_heap_empty_(min_heap_t* s) { return 0u == s->n; }
|
||||
unsigned min_heap_size_(min_heap_t* s) { return s->n; }
|
||||
struct event* min_heap_top_(min_heap_t* s) { return s->n ? *s->p : 0; }
|
||||
|
||||
int min_heap_push(min_heap_t* s, struct event* e)
|
||||
int min_heap_push_(min_heap_t* s, struct event* e)
|
||||
{
|
||||
if (min_heap_reserve(s, s->n + 1))
|
||||
if (min_heap_reserve_(s, s->n + 1))
|
||||
return -1;
|
||||
min_heap_shift_up_(s, s->n++, e);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct event* min_heap_pop(min_heap_t* s)
|
||||
struct event* min_heap_pop_(min_heap_t* s)
|
||||
{
|
||||
if (s->n)
|
||||
{
|
||||
@ -88,12 +88,12 @@ struct event* min_heap_pop(min_heap_t* s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int min_heap_elt_is_top(const struct event *e)
|
||||
int min_heap_elt_is_top_(const struct event *e)
|
||||
{
|
||||
return e->ev_timeout_pos.min_heap_idx == 0;
|
||||
}
|
||||
|
||||
int min_heap_erase(min_heap_t* s, struct event* e)
|
||||
int min_heap_erase_(min_heap_t* s, struct event* e)
|
||||
{
|
||||
if (-1 != e->ev_timeout_pos.min_heap_idx)
|
||||
{
|
||||
@ -114,10 +114,10 @@ int min_heap_erase(min_heap_t* s, struct event* e)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int min_heap_adjust(min_heap_t *s, struct event *e)
|
||||
int min_heap_adjust_(min_heap_t *s, struct event *e)
|
||||
{
|
||||
if (-1 == e->ev_timeout_pos.min_heap_idx) {
|
||||
return min_heap_push(s, e);
|
||||
return min_heap_push_(s, e);
|
||||
} else {
|
||||
unsigned parent = (e->ev_timeout_pos.min_heap_idx - 1) / 2;
|
||||
/* The position of e has changed; we shift it up or down
|
||||
@ -131,7 +131,7 @@ int min_heap_adjust(min_heap_t *s, struct event *e)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int min_heap_reserve(min_heap_t* s, unsigned n)
|
||||
int min_heap_reserve_(min_heap_t* s, unsigned n)
|
||||
{
|
||||
if (s->a < n)
|
||||
{
|
||||
|
10
poll.c
10
poll.c
@ -91,7 +91,7 @@ poll_init(struct event_base *base)
|
||||
if (!(pollop = mm_calloc(1, sizeof(struct pollop))))
|
||||
return (NULL);
|
||||
|
||||
evsig_init(base);
|
||||
evsig_init_(base);
|
||||
|
||||
return (pollop);
|
||||
}
|
||||
@ -158,7 +158,7 @@ poll_dispatch(struct event_base *base, struct timeval *tv)
|
||||
#endif
|
||||
|
||||
if (tv != NULL) {
|
||||
msec = evutil_tv_to_msec(tv);
|
||||
msec = evutil_tv_to_msec_(tv);
|
||||
if (msec < 0 || msec > INT_MAX)
|
||||
msec = INT_MAX;
|
||||
}
|
||||
@ -204,7 +204,7 @@ poll_dispatch(struct event_base *base, struct timeval *tv)
|
||||
if (res == 0)
|
||||
continue;
|
||||
|
||||
evmap_io_active(base, event_set[i].fd, res);
|
||||
evmap_io_active_(base, event_set[i].fd, res);
|
||||
}
|
||||
|
||||
return (0);
|
||||
@ -310,7 +310,7 @@ poll_del(struct event_base *base, int fd, short old, short events, void *_idx)
|
||||
*/
|
||||
memcpy(&pop->event_set[i], &pop->event_set[pop->nfds],
|
||||
sizeof(struct pollfd));
|
||||
idx = evmap_io_get_fdinfo(&base->io, pop->event_set[i].fd);
|
||||
idx = evmap_io_get_fdinfo_(&base->io, pop->event_set[i].fd);
|
||||
EVUTIL_ASSERT(idx);
|
||||
EVUTIL_ASSERT(idx->idxplus1 == pop->nfds + 1);
|
||||
idx->idxplus1 = i + 1;
|
||||
@ -325,7 +325,7 @@ poll_dealloc(struct event_base *base)
|
||||
{
|
||||
struct pollop *pop = base->evbase;
|
||||
|
||||
evsig_dealloc(base);
|
||||
evsig_dealloc_(base);
|
||||
if (pop->event_set)
|
||||
mm_free(pop->event_set);
|
||||
if (pop->event_set_copy)
|
||||
|
@ -65,13 +65,13 @@ struct ev_token_bucket_cfg {
|
||||
|
||||
/** The current tick is 'current_tick': add bytes to 'bucket' as specified in
|
||||
* 'cfg'. */
|
||||
int ev_token_bucket_update(struct ev_token_bucket *bucket,
|
||||
int ev_token_bucket_update_(struct ev_token_bucket *bucket,
|
||||
const struct ev_token_bucket_cfg *cfg,
|
||||
ev_uint32_t current_tick);
|
||||
|
||||
/** In which tick does 'tv' fall according to 'cfg'? Note that ticks can
|
||||
* overflow easily; your code needs to handle this. */
|
||||
ev_uint32_t ev_token_bucket_get_tick(const struct timeval *tv,
|
||||
ev_uint32_t ev_token_bucket_get_tick_(const struct timeval *tv,
|
||||
const struct ev_token_bucket_cfg *cfg);
|
||||
|
||||
/** Adjust 'bucket' to respect 'cfg', and note that it was last updated in
|
||||
@ -79,12 +79,12 @@ ev_uint32_t ev_token_bucket_get_tick(const struct timeval *tv,
|
||||
* configuration of 'bucket'; otherwise, we are setting it up for the first
|
||||
* time.
|
||||
*/
|
||||
int ev_token_bucket_init(struct ev_token_bucket *bucket,
|
||||
int ev_token_bucket_init_(struct ev_token_bucket *bucket,
|
||||
const struct ev_token_bucket_cfg *cfg,
|
||||
ev_uint32_t current_tick,
|
||||
int reinitialize);
|
||||
|
||||
int bufferevent_remove_from_rate_limit_group_internal(struct bufferevent *bev,
|
||||
int bufferevent_remove_from_rate_limit_group_internal_(struct bufferevent *bev,
|
||||
int unsuspend);
|
||||
|
||||
/** Decrease the read limit of 'b' by 'n' bytes */
|
||||
|
6
select.c
6
select.c
@ -119,7 +119,7 @@ select_init(struct event_base *base)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
evsig_init(base);
|
||||
evsig_init_(base);
|
||||
|
||||
return (sop);
|
||||
}
|
||||
@ -199,7 +199,7 @@ select_dispatch(struct event_base *base, struct timeval *tv)
|
||||
if (res == 0)
|
||||
continue;
|
||||
|
||||
evmap_io_active(base, i, res);
|
||||
evmap_io_active_(base, i, res);
|
||||
}
|
||||
check_selectop(sop);
|
||||
|
||||
@ -336,7 +336,7 @@ select_free_selectop(struct selectop *sop)
|
||||
static void
|
||||
select_dealloc(struct event_base *base)
|
||||
{
|
||||
evsig_dealloc(base);
|
||||
evsig_dealloc_(base);
|
||||
|
||||
select_free_selectop(base->evbase);
|
||||
}
|
||||
|
12
signal.c
12
signal.c
@ -117,7 +117,7 @@ static void __cdecl evsig_handler(int sig);
|
||||
#define EVSIGBASE_UNLOCK() EVLOCK_UNLOCK(evsig_base_lock, 0)
|
||||
|
||||
void
|
||||
evsig_set_base(struct event_base *base)
|
||||
evsig_set_base_(struct event_base *base)
|
||||
{
|
||||
EVSIGBASE_LOCK();
|
||||
evsig_base = base;
|
||||
@ -165,20 +165,20 @@ evsig_cb(evutil_socket_t fd, short what, void *arg)
|
||||
EVBASE_ACQUIRE_LOCK(base, th_base_lock);
|
||||
for (i = 0; i < NSIG; ++i) {
|
||||
if (ncaught[i])
|
||||
evmap_signal_active(base, i, ncaught[i]);
|
||||
evmap_signal_active_(base, i, ncaught[i]);
|
||||
}
|
||||
EVBASE_RELEASE_LOCK(base, th_base_lock);
|
||||
}
|
||||
|
||||
int
|
||||
evsig_init(struct event_base *base)
|
||||
evsig_init_(struct event_base *base)
|
||||
{
|
||||
/*
|
||||
* Our signal handler is going to write to one end of the socket
|
||||
* pair to wake up our event loop. The event loop then scans for
|
||||
* signals that got delivered.
|
||||
*/
|
||||
if (evutil_make_internal_pipe(base->sig.ev_signal_pair) == -1) {
|
||||
if (evutil_make_internal_pipe_(base->sig.ev_signal_pair) == -1) {
|
||||
#ifdef _WIN32
|
||||
/* Make this nonfatal on win32, where sometimes people
|
||||
have localhost firewalled. */
|
||||
@ -409,14 +409,14 @@ evsig_handler(int sig)
|
||||
}
|
||||
|
||||
void
|
||||
evsig_dealloc(struct event_base *base)
|
||||
evsig_dealloc_(struct event_base *base)
|
||||
{
|
||||
int i = 0;
|
||||
if (base->sig.ev_signal_added) {
|
||||
event_del(&base->sig.ev_signal);
|
||||
base->sig.ev_signal_added = 0;
|
||||
}
|
||||
/* debug event is created in evsig_init/event_assign even when
|
||||
/* debug event is created in evsig_init_/event_assign even when
|
||||
* ev_signal_added == 0, so unassign is required */
|
||||
event_debug_unassign(&base->sig.ev_signal);
|
||||
|
||||
|
@ -666,11 +666,11 @@ test_persistent_active_timeout(void *ptr)
|
||||
tv_exit.tv_usec = 600 * 1000;
|
||||
event_base_loopexit(base, &tv_exit);
|
||||
|
||||
event_base_assert_ok(base);
|
||||
event_base_assert_ok_(base);
|
||||
evutil_gettimeofday(&start, NULL);
|
||||
|
||||
event_base_dispatch(base);
|
||||
event_base_assert_ok(base);
|
||||
event_base_assert_ok_(base);
|
||||
|
||||
tt_int_op(res.n, ==, 3);
|
||||
tt_int_op(res.events[0], ==, EV_READ);
|
||||
@ -739,11 +739,11 @@ test_common_timeout(void *ptr)
|
||||
}
|
||||
}
|
||||
|
||||
event_base_assert_ok(base);
|
||||
event_base_assert_ok_(base);
|
||||
evutil_gettimeofday(&start, NULL);
|
||||
event_base_dispatch(base);
|
||||
|
||||
event_base_assert_ok(base);
|
||||
event_base_assert_ok_(base);
|
||||
|
||||
for (i=0; i<10; ++i) {
|
||||
tt_int_op(info[i].count, ==, 4);
|
||||
@ -811,18 +811,18 @@ test_fork(void)
|
||||
evsignal_set(&sig_ev, SIGCHLD, child_signal_cb, &got_sigchld);
|
||||
evsignal_add(&sig_ev, NULL);
|
||||
|
||||
event_base_assert_ok(current_base);
|
||||
event_base_assert_ok_(current_base);
|
||||
TT_BLATHER(("Before fork"));
|
||||
if ((pid = fork()) == 0) {
|
||||
/* in the child */
|
||||
TT_BLATHER(("In child, before reinit"));
|
||||
event_base_assert_ok(current_base);
|
||||
event_base_assert_ok_(current_base);
|
||||
if (event_reinit(current_base) == -1) {
|
||||
fprintf(stdout, "FAILED (reinit)\n");
|
||||
exit(1);
|
||||
}
|
||||
TT_BLATHER(("After reinit"));
|
||||
event_base_assert_ok(current_base);
|
||||
event_base_assert_ok_(current_base);
|
||||
TT_BLATHER(("After assert-ok"));
|
||||
|
||||
evsignal_del(&sig_ev);
|
||||
@ -842,7 +842,7 @@ test_fork(void)
|
||||
/* wait for the child to read the data */
|
||||
{
|
||||
const struct timeval tv = { 0, 100000 };
|
||||
evutil_usleep(&tv);
|
||||
evutil_usleep_(&tv);
|
||||
}
|
||||
|
||||
if (write(pair[0], TEST1, strlen(TEST1)+1) < 0) {
|
||||
@ -1919,7 +1919,7 @@ methodname_to_envvar(const char *mname, char *buf, size_t buflen)
|
||||
char *cp;
|
||||
evutil_snprintf(buf, buflen, "EVENT_NO%s", mname);
|
||||
for (cp = buf; *cp; ++cp) {
|
||||
*cp = EVUTIL_TOUPPER(*cp);
|
||||
*cp = EVUTIL_TOUPPER_(*cp);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -803,7 +803,7 @@ test_evbuffer_add_file(void *ptr)
|
||||
#if defined(EVENT__HAVE_SENDFILE) && defined(__sun__) && defined(__svr4__)
|
||||
/* We need to use a pair of AF_INET sockets, since Solaris
|
||||
doesn't support sendfile() over AF_UNIX. */
|
||||
if (evutil_ersatz_socketpair(AF_INET, SOCK_STREAM, 0, pair) == -1)
|
||||
if (evutil_ersatz_socketpair_(AF_INET, SOCK_STREAM, 0, pair) == -1)
|
||||
tt_abort_msg("ersatz_socketpair failed");
|
||||
#else
|
||||
if (evutil_socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == -1)
|
||||
|
@ -503,7 +503,7 @@ test_bufferevent_connect(void *arg)
|
||||
if (!strcmp((char*)data->setup_data, "unset_connectex")) {
|
||||
struct win32_extension_fns *ext =
|
||||
(struct win32_extension_fns *)
|
||||
event_get_win32_extension_fns();
|
||||
event_get_win32_extension_fns_();
|
||||
ext->ConnectEx = NULL;
|
||||
}
|
||||
#endif
|
||||
|
@ -93,7 +93,7 @@ test_edgetriggered(void *et)
|
||||
* problem.
|
||||
*/
|
||||
#ifdef __linux__
|
||||
if (evutil_ersatz_socketpair(AF_INET, SOCK_STREAM, 0, pair) == -1) {
|
||||
if (evutil_ersatz_socketpair_(AF_INET, SOCK_STREAM, 0, pair) == -1) {
|
||||
tt_abort_perror("socketpair");
|
||||
}
|
||||
#else
|
||||
|
@ -212,11 +212,11 @@ http_readcb(struct bufferevent *bev, void *arg)
|
||||
enum message_read_status done;
|
||||
|
||||
/* req->kind = EVHTTP_RESPONSE; */
|
||||
done = evhttp_parse_firstline(req, bufferevent_get_input(bev));
|
||||
done = evhttp_parse_firstline_(req, bufferevent_get_input(bev));
|
||||
if (done != ALL_DATA_READ)
|
||||
goto out;
|
||||
|
||||
done = evhttp_parse_headers(req, bufferevent_get_input(bev));
|
||||
done = evhttp_parse_headers_(req, bufferevent_get_input(bev));
|
||||
if (done != ALL_DATA_READ)
|
||||
goto out;
|
||||
|
||||
@ -512,11 +512,11 @@ http_badreq_readcb(struct bufferevent *bev, void *arg)
|
||||
enum message_read_status done;
|
||||
|
||||
/* req->kind = EVHTTP_RESPONSE; */
|
||||
done = evhttp_parse_firstline(req, bufferevent_get_input(bev));
|
||||
done = evhttp_parse_firstline_(req, bufferevent_get_input(bev));
|
||||
if (done != ALL_DATA_READ)
|
||||
goto out;
|
||||
|
||||
done = evhttp_parse_headers(req, bufferevent_get_input(bev));
|
||||
done = evhttp_parse_headers_(req, bufferevent_get_input(bev));
|
||||
if (done != ALL_DATA_READ)
|
||||
goto out;
|
||||
|
||||
@ -631,7 +631,7 @@ http_large_delay_cb(struct evhttp_request *req, void *arg)
|
||||
tv.tv_usec = 500000;
|
||||
|
||||
event_base_once(arg, -1, EV_TIMEOUT, http_delay_reply, req, &tv);
|
||||
evhttp_connection_fail(delayed_client, EVCON_HTTP_EOF);
|
||||
evhttp_connection_fail_(delayed_client, EVCON_HTTP_EOF);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2648,11 +2648,11 @@ http_chunked_errorcb(struct bufferevent *bev, short what, void *arg)
|
||||
enum message_read_status done;
|
||||
|
||||
/* req->kind = EVHTTP_RESPONSE; */
|
||||
done = evhttp_parse_firstline(req, bufferevent_get_input(bev));
|
||||
done = evhttp_parse_firstline_(req, bufferevent_get_input(bev));
|
||||
if (done != ALL_DATA_READ)
|
||||
goto out;
|
||||
|
||||
done = evhttp_parse_headers(req, bufferevent_get_input(bev));
|
||||
done = evhttp_parse_headers_(req, bufferevent_get_input(bev));
|
||||
if (done != ALL_DATA_READ)
|
||||
goto out;
|
||||
|
||||
@ -3016,7 +3016,7 @@ static void
|
||||
http_connection_fail_done(struct evhttp_request *req, void *arg)
|
||||
{
|
||||
/* An ENETUNREACH error results in an unrecoverable
|
||||
* evhttp_connection error (see evhttp_connection_fail()). The
|
||||
* evhttp_connection error (see evhttp_connection_fail_()). The
|
||||
* connection will be reset, and the user will be notified with a NULL
|
||||
* req parameter. */
|
||||
tt_assert(!req);
|
||||
|
@ -167,27 +167,27 @@ test_iocp_port(void *ptr)
|
||||
tt_assert(o1.lock);
|
||||
tt_assert(o2.lock);
|
||||
|
||||
event_overlapped_init(&o1.eo, dummy_cb);
|
||||
event_overlapped_init(&o2.eo, dummy_cb);
|
||||
event_overlapped_init_(&o1.eo, dummy_cb);
|
||||
event_overlapped_init_(&o2.eo, dummy_cb);
|
||||
|
||||
port = event_iocp_port_launch(0);
|
||||
port = event_iocp_port_launch_(0);
|
||||
tt_assert(port);
|
||||
|
||||
tt_assert(!event_iocp_activate_overlapped(port, &o1.eo, 10, 100));
|
||||
tt_assert(!event_iocp_activate_overlapped(port, &o2.eo, 20, 200));
|
||||
tt_assert(!event_iocp_activate_overlapped_(port, &o1.eo, 10, 100));
|
||||
tt_assert(!event_iocp_activate_overlapped_(port, &o2.eo, 20, 200));
|
||||
|
||||
tt_assert(!event_iocp_activate_overlapped(port, &o1.eo, 11, 101));
|
||||
tt_assert(!event_iocp_activate_overlapped(port, &o2.eo, 21, 201));
|
||||
tt_assert(!event_iocp_activate_overlapped_(port, &o1.eo, 11, 101));
|
||||
tt_assert(!event_iocp_activate_overlapped_(port, &o2.eo, 21, 201));
|
||||
|
||||
tt_assert(!event_iocp_activate_overlapped(port, &o1.eo, 12, 102));
|
||||
tt_assert(!event_iocp_activate_overlapped(port, &o2.eo, 22, 202));
|
||||
tt_assert(!event_iocp_activate_overlapped_(port, &o1.eo, 12, 102));
|
||||
tt_assert(!event_iocp_activate_overlapped_(port, &o2.eo, 22, 202));
|
||||
|
||||
tt_assert(!event_iocp_activate_overlapped(port, &o1.eo, 13, 103));
|
||||
tt_assert(!event_iocp_activate_overlapped(port, &o2.eo, 23, 203));
|
||||
tt_assert(!event_iocp_activate_overlapped_(port, &o1.eo, 13, 103));
|
||||
tt_assert(!event_iocp_activate_overlapped_(port, &o2.eo, 23, 203));
|
||||
|
||||
tt_int_op(count_wait_for(8, 2000), ==, 0);
|
||||
|
||||
tt_want(!event_iocp_shutdown(port, 2000));
|
||||
tt_want(!event_iocp_shutdown_(port, 2000));
|
||||
|
||||
tt_int_op(o1.call_count, ==, 4);
|
||||
tt_int_op(o2.call_count, ==, 4);
|
||||
@ -215,7 +215,7 @@ read_complete(struct event_overlapped *eo, uintptr_t key,
|
||||
ev_ssize_t nbytes, int ok)
|
||||
{
|
||||
tt_assert(ok);
|
||||
evbuffer_commit_read(rbuf, nbytes);
|
||||
evbuffer_commit_read_(rbuf, nbytes);
|
||||
count_incr();
|
||||
end:
|
||||
;
|
||||
@ -226,7 +226,7 @@ write_complete(struct event_overlapped *eo, uintptr_t key,
|
||||
ev_ssize_t nbytes, int ok)
|
||||
{
|
||||
tt_assert(ok);
|
||||
evbuffer_commit_write(wbuf, nbytes);
|
||||
evbuffer_commit_write_(wbuf, nbytes);
|
||||
count_incr();
|
||||
end:
|
||||
;
|
||||
@ -244,24 +244,24 @@ test_iocp_evbuffer(void *ptr)
|
||||
int i;
|
||||
|
||||
count_init();
|
||||
event_overlapped_init(&rol, read_complete);
|
||||
event_overlapped_init(&wol, write_complete);
|
||||
event_overlapped_init_(&rol, read_complete);
|
||||
event_overlapped_init_(&wol, write_complete);
|
||||
|
||||
for (i = 0; i < (int)sizeof(junk); ++i)
|
||||
junk[i] = (char)(i);
|
||||
|
||||
rbuf = evbuffer_overlapped_new(data->pair[0]);
|
||||
wbuf = evbuffer_overlapped_new(data->pair[1]);
|
||||
rbuf = evbuffer_overlapped_new_(data->pair[0]);
|
||||
wbuf = evbuffer_overlapped_new_(data->pair[1]);
|
||||
evbuffer_enable_locking(rbuf, NULL);
|
||||
evbuffer_enable_locking(wbuf, NULL);
|
||||
|
||||
port = event_iocp_port_launch(0);
|
||||
port = event_iocp_port_launch_(0);
|
||||
tt_assert(port);
|
||||
tt_assert(rbuf);
|
||||
tt_assert(wbuf);
|
||||
|
||||
tt_assert(!event_iocp_port_associate(port, data->pair[0], 100));
|
||||
tt_assert(!event_iocp_port_associate(port, data->pair[1], 100));
|
||||
tt_assert(!event_iocp_port_associate_(port, data->pair[0], 100));
|
||||
tt_assert(!event_iocp_port_associate_(port, data->pair[1], 100));
|
||||
|
||||
for (i=0;i<10;++i)
|
||||
evbuffer_add(wbuf, junk, sizeof(junk));
|
||||
@ -269,13 +269,13 @@ test_iocp_evbuffer(void *ptr)
|
||||
buf = evbuffer_new();
|
||||
tt_assert(buf != NULL);
|
||||
evbuffer_add(rbuf, junk, sizeof(junk));
|
||||
tt_assert(!evbuffer_launch_read(rbuf, 2048, &rol));
|
||||
tt_assert(!evbuffer_launch_read_(rbuf, 2048, &rol));
|
||||
evbuffer_add_buffer(buf, rbuf);
|
||||
tt_int_op(evbuffer_get_length(buf), ==, sizeof(junk));
|
||||
for (chain = buf->first; chain; chain = chain->next)
|
||||
tt_int_op(chain->flags & EVBUFFER_MEM_PINNED_ANY, ==, 0);
|
||||
tt_assert(!evbuffer_get_length(rbuf));
|
||||
tt_assert(!evbuffer_launch_write(wbuf, 512, &wol));
|
||||
tt_assert(!evbuffer_launch_write_(wbuf, 512, &wol));
|
||||
|
||||
tt_int_op(count_wait_for(2, 2000), ==, 0);
|
||||
|
||||
@ -283,7 +283,7 @@ test_iocp_evbuffer(void *ptr)
|
||||
|
||||
/* FIXME Actually test some stuff here. */
|
||||
|
||||
tt_want(!event_iocp_shutdown(port, 2000));
|
||||
tt_want(!event_iocp_shutdown_(port, 2000));
|
||||
end:
|
||||
count_free();
|
||||
evbuffer_free(rbuf);
|
||||
@ -310,13 +310,13 @@ test_iocp_bufferevent_async(void *ptr)
|
||||
char buf[128];
|
||||
size_t n;
|
||||
|
||||
event_base_start_iocp(data->base, 0);
|
||||
port = event_base_get_iocp(data->base);
|
||||
event_base_start_iocp_(data->base, 0);
|
||||
port = event_base_get_iocp_(data->base);
|
||||
tt_assert(port);
|
||||
|
||||
bea1 = bufferevent_async_new(data->base, data->pair[0],
|
||||
bea1 = bufferevent_async_new_(data->base, data->pair[0],
|
||||
BEV_OPT_DEFER_CALLBACKS);
|
||||
bea2 = bufferevent_async_new(data->base, data->pair[1],
|
||||
bea2 = bufferevent_async_new_(data->base, data->pair[1],
|
||||
BEV_OPT_DEFER_CALLBACKS);
|
||||
tt_assert(bea1);
|
||||
tt_assert(bea2);
|
||||
|
@ -115,9 +115,9 @@ regress_pick_a_port(void *arg)
|
||||
tt_ptr_op(evconnlistener_get_base(listener2), ==, base);
|
||||
|
||||
fd1 = fd2 = fd3 = -1;
|
||||
evutil_socket_connect(&fd1, (struct sockaddr*)&ss1, slen1);
|
||||
evutil_socket_connect(&fd2, (struct sockaddr*)&ss1, slen1);
|
||||
evutil_socket_connect(&fd3, (struct sockaddr*)&ss2, slen2);
|
||||
evutil_socket_connect_(&fd1, (struct sockaddr*)&ss1, slen1);
|
||||
evutil_socket_connect_(&fd2, (struct sockaddr*)&ss1, slen1);
|
||||
evutil_socket_connect_(&fd3, (struct sockaddr*)&ss2, slen2);
|
||||
|
||||
#ifdef _WIN32
|
||||
Sleep(100); /* XXXX this is a stupid stopgap. */
|
||||
|
@ -213,7 +213,7 @@ basic_test_setup(const struct testcase_t *testcase)
|
||||
exit(1);
|
||||
}
|
||||
if (testcase->flags & TT_ENABLE_IOCP_FLAG) {
|
||||
if (event_base_start_iocp(base, 0)<0) {
|
||||
if (event_base_start_iocp_(base, 0)<0) {
|
||||
event_base_free(base);
|
||||
return (void*)TT_SKIP;
|
||||
}
|
||||
@ -259,7 +259,7 @@ basic_test_cleanup(const struct testcase_t *testcase, void *ptr)
|
||||
|
||||
if (testcase->flags & TT_NEED_BASE) {
|
||||
if (data->base) {
|
||||
event_base_assert_ok(data->base);
|
||||
event_base_assert_ok_(data->base);
|
||||
event_base_free(data->base);
|
||||
}
|
||||
}
|
||||
|
@ -58,38 +58,38 @@ test_heap_randomized(void *ptr)
|
||||
struct event *e, *last_e;
|
||||
int i;
|
||||
|
||||
min_heap_ctor(&heap);
|
||||
min_heap_ctor_(&heap);
|
||||
|
||||
for (i = 0; i < 1024; ++i) {
|
||||
inserted[i] = malloc(sizeof(struct event));
|
||||
set_random_timeout(inserted[i]);
|
||||
min_heap_push(&heap, inserted[i]);
|
||||
min_heap_push_(&heap, inserted[i]);
|
||||
}
|
||||
check_heap(&heap);
|
||||
|
||||
tt_assert(min_heap_size(&heap) == 1024);
|
||||
tt_assert(min_heap_size_(&heap) == 1024);
|
||||
|
||||
for (i = 0; i < 512; ++i) {
|
||||
min_heap_erase(&heap, inserted[i]);
|
||||
min_heap_erase_(&heap, inserted[i]);
|
||||
if (0 == (i % 32))
|
||||
check_heap(&heap);
|
||||
}
|
||||
tt_assert(min_heap_size(&heap) == 512);
|
||||
tt_assert(min_heap_size_(&heap) == 512);
|
||||
|
||||
last_e = min_heap_pop(&heap);
|
||||
last_e = min_heap_pop_(&heap);
|
||||
while (1) {
|
||||
e = min_heap_pop(&heap);
|
||||
e = min_heap_pop_(&heap);
|
||||
if (!e)
|
||||
break;
|
||||
tt_want(evutil_timercmp(&last_e->ev_timeout,
|
||||
&e->ev_timeout, <=));
|
||||
}
|
||||
tt_assert(min_heap_size(&heap) == 0);
|
||||
tt_assert(min_heap_size_(&heap) == 0);
|
||||
end:
|
||||
for (i = 0; i < 1024; ++i)
|
||||
free(inserted[i]);
|
||||
|
||||
min_heap_dtor(&heap);
|
||||
min_heap_dtor_(&heap);
|
||||
}
|
||||
|
||||
struct testcase_t minheap_testcases[] = {
|
||||
|
@ -410,7 +410,7 @@ SLEEP_MS(int ms)
|
||||
struct timeval tv;
|
||||
tv.tv_sec = ms/1000;
|
||||
tv.tv_usec = (ms%1000)*1000;
|
||||
evutil_usleep(&tv);
|
||||
evutil_usleep_(&tv);
|
||||
}
|
||||
|
||||
struct deferred_test_data {
|
||||
@ -438,8 +438,8 @@ load_deferred_queue(void *arg)
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < CB_COUNT; ++i) {
|
||||
event_deferred_cb_init(&data->cbs[i], deferred_callback, NULL);
|
||||
event_deferred_cb_schedule(data->queue, &data->cbs[i]);
|
||||
event_deferred_cb_init_(&data->cbs[i], deferred_callback, NULL);
|
||||
event_deferred_cb_schedule_(data->queue, &data->cbs[i]);
|
||||
SLEEP_MS(1);
|
||||
}
|
||||
|
||||
@ -473,7 +473,7 @@ thread_deferred_cb_skew(void *arg)
|
||||
int elapsed_usec;
|
||||
int i;
|
||||
|
||||
queue = event_base_get_deferred_cb_queue(data->base);
|
||||
queue = event_base_get_deferred_cb_queue_(data->base);
|
||||
tt_assert(queue);
|
||||
|
||||
for (i = 0; i < QUEUE_THREAD_COUNT; ++i)
|
||||
|
@ -294,7 +294,7 @@ regress_sockaddr_port_format(void *ptr)
|
||||
r = evutil_parse_sockaddr_port("192.168.1.1:80",
|
||||
(struct sockaddr*)&ss, &len);
|
||||
tt_int_op(r,==,0);
|
||||
cp = evutil_format_sockaddr_port(
|
||||
cp = evutil_format_sockaddr_port_(
|
||||
(struct sockaddr*)&ss, cbuf, sizeof(cbuf));
|
||||
tt_ptr_op(cp,==,cbuf);
|
||||
tt_str_op(cp,==,"192.168.1.1:80");
|
||||
@ -303,13 +303,13 @@ regress_sockaddr_port_format(void *ptr)
|
||||
r = evutil_parse_sockaddr_port("[ff00::8010]:999",
|
||||
(struct sockaddr*)&ss, &len);
|
||||
tt_int_op(r,==,0);
|
||||
cp = evutil_format_sockaddr_port(
|
||||
cp = evutil_format_sockaddr_port_(
|
||||
(struct sockaddr*)&ss, cbuf, sizeof(cbuf));
|
||||
tt_ptr_op(cp,==,cbuf);
|
||||
tt_str_op(cp,==,"[ff00::8010]:999");
|
||||
|
||||
ss.ss_family=99;
|
||||
cp = evutil_format_sockaddr_port(
|
||||
cp = evutil_format_sockaddr_port_(
|
||||
(struct sockaddr*)&ss, cbuf, sizeof(cbuf));
|
||||
tt_ptr_op(cp,==,cbuf);
|
||||
tt_str_op(cp,==,"<addr with socktype 99>");
|
||||
@ -354,7 +354,7 @@ test_evutil_sockaddr_predicates(void *ptr)
|
||||
}
|
||||
|
||||
/* sockaddr_is_loopback */
|
||||
if (ent->is_loopback != evutil_sockaddr_is_loopback((struct sockaddr*)&ss)) {
|
||||
if (ent->is_loopback != evutil_sockaddr_is_loopback_((struct sockaddr*)&ss)) {
|
||||
TT_FAIL(("evutil_sockaddr_loopback(%s) not as expected",
|
||||
ent->parse));
|
||||
}
|
||||
@ -1063,7 +1063,7 @@ test_evutil_loadsyslib(void *arg)
|
||||
{
|
||||
HANDLE h=NULL;
|
||||
|
||||
h = evutil_load_windows_system_library(TEXT("kernel32.dll"));
|
||||
h = evutil_load_windows_system_library_(TEXT("kernel32.dll"));
|
||||
tt_assert(h);
|
||||
|
||||
end:
|
||||
@ -1184,9 +1184,9 @@ test_evutil_usleep(void *arg)
|
||||
long usec1, usec2;
|
||||
|
||||
evutil_gettimeofday(&tv1, NULL);
|
||||
evutil_usleep(&quarter_sec);
|
||||
evutil_usleep_(&quarter_sec);
|
||||
evutil_gettimeofday(&tv2, NULL);
|
||||
evutil_usleep(&tenth_sec);
|
||||
evutil_usleep_(&tenth_sec);
|
||||
evutil_gettimeofday(&tv3, NULL);
|
||||
|
||||
evutil_timersub(&tv2, &tv1, &diff1);
|
||||
|
@ -206,16 +206,16 @@ extern "C" {
|
||||
* when you care about ASCII's notion of character types, because you are about
|
||||
* to send those types onto the wire.
|
||||
*/
|
||||
int EVUTIL_ISALPHA(char c);
|
||||
int EVUTIL_ISALNUM(char c);
|
||||
int EVUTIL_ISSPACE(char c);
|
||||
int EVUTIL_ISDIGIT(char c);
|
||||
int EVUTIL_ISXDIGIT(char c);
|
||||
int EVUTIL_ISPRINT(char c);
|
||||
int EVUTIL_ISLOWER(char c);
|
||||
int EVUTIL_ISUPPER(char c);
|
||||
char EVUTIL_TOUPPER(char c);
|
||||
char EVUTIL_TOLOWER(char c);
|
||||
int EVUTIL_ISALPHA_(char c);
|
||||
int EVUTIL_ISALNUM_(char c);
|
||||
int EVUTIL_ISSPACE_(char c);
|
||||
int EVUTIL_ISDIGIT_(char c);
|
||||
int EVUTIL_ISXDIGIT_(char c);
|
||||
int EVUTIL_ISPRINT_(char c);
|
||||
int EVUTIL_ISLOWER_(char c);
|
||||
int EVUTIL_ISUPPER_(char c);
|
||||
char EVUTIL_TOUPPER_(char c);
|
||||
char EVUTIL_TOLOWER_(char c);
|
||||
|
||||
/** Helper macro. If we know that a given pointer points to a field in a
|
||||
structure, return a pointer to the structure itself. Used to implement
|
||||
@ -238,21 +238,21 @@ char EVUTIL_TOLOWER(char c);
|
||||
/* As open(pathname, flags, mode), except that the file is always opened with
|
||||
* the close-on-exec flag set. (And the mode argument is mandatory.)
|
||||
*/
|
||||
int evutil_open_closeonexec(const char *pathname, int flags, unsigned mode);
|
||||
int evutil_open_closeonexec_(const char *pathname, int flags, unsigned mode);
|
||||
|
||||
int evutil_read_file(const char *filename, char **content_out, size_t *len_out,
|
||||
int evutil_read_file_(const char *filename, char **content_out, size_t *len_out,
|
||||
int is_binary);
|
||||
|
||||
int evutil_socket_connect(evutil_socket_t *fd_ptr, struct sockaddr *sa, int socklen);
|
||||
int evutil_socket_connect_(evutil_socket_t *fd_ptr, struct sockaddr *sa, int socklen);
|
||||
|
||||
int evutil_socket_finished_connecting(evutil_socket_t fd);
|
||||
int evutil_socket_finished_connecting_(evutil_socket_t fd);
|
||||
|
||||
int evutil_ersatz_socketpair(int, int , int, evutil_socket_t[]);
|
||||
int evutil_ersatz_socketpair_(int, int , int, evutil_socket_t[]);
|
||||
|
||||
int evutil_resolve(int family, const char *hostname, struct sockaddr *sa,
|
||||
int evutil_resolve_(int family, const char *hostname, struct sockaddr *sa,
|
||||
ev_socklen_t *socklen, int port);
|
||||
|
||||
const char *evutil_getenv(const char *name);
|
||||
const char *evutil_getenv_(const char *name);
|
||||
|
||||
long evutil_weakrand_(void);
|
||||
|
||||
@ -302,7 +302,7 @@ struct sockaddr_storage {
|
||||
#endif
|
||||
|
||||
/* Internal addrinfo error code. This one is returned from only from
|
||||
* evutil_getaddrinfo_common, when we are sure that we'll have to hit a DNS
|
||||
* evutil_getaddrinfo_common_, when we are sure that we'll have to hit a DNS
|
||||
* server. */
|
||||
#define EVUTIL_EAI_NEED_RESOLVE -90002
|
||||
|
||||
@ -314,24 +314,24 @@ typedef struct evdns_getaddrinfo_request* (*evdns_getaddrinfo_fn)(
|
||||
const struct evutil_addrinfo *hints_in,
|
||||
void (*cb)(int, struct evutil_addrinfo *, void *), void *arg);
|
||||
|
||||
void evutil_set_evdns_getaddrinfo_fn(evdns_getaddrinfo_fn fn);
|
||||
void evutil_set_evdns_getaddrinfo_fn_(evdns_getaddrinfo_fn fn);
|
||||
|
||||
struct evutil_addrinfo *evutil_new_addrinfo(struct sockaddr *sa,
|
||||
struct evutil_addrinfo *evutil_new_addrinfo_(struct sockaddr *sa,
|
||||
ev_socklen_t socklen, const struct evutil_addrinfo *hints);
|
||||
struct evutil_addrinfo *evutil_addrinfo_append(struct evutil_addrinfo *first,
|
||||
struct evutil_addrinfo *evutil_addrinfo_append_(struct evutil_addrinfo *first,
|
||||
struct evutil_addrinfo *append);
|
||||
void evutil_adjust_hints_for_addrconfig(struct evutil_addrinfo *hints);
|
||||
int evutil_getaddrinfo_common(const char *nodename, const char *servname,
|
||||
void evutil_adjust_hints_for_addrconfig_(struct evutil_addrinfo *hints);
|
||||
int evutil_getaddrinfo_common_(const char *nodename, const char *servname,
|
||||
struct evutil_addrinfo *hints, struct evutil_addrinfo **res, int *portnum);
|
||||
|
||||
int evutil_getaddrinfo_async(struct evdns_base *dns_base,
|
||||
int evutil_getaddrinfo_async_(struct evdns_base *dns_base,
|
||||
const char *nodename, const char *servname,
|
||||
const struct evutil_addrinfo *hints_in,
|
||||
void (*cb)(int, struct evutil_addrinfo *, void *), void *arg);
|
||||
|
||||
/** Return true iff sa is a looback address. (That is, it is 127.0.0.1/8, or
|
||||
* ::1). */
|
||||
int evutil_sockaddr_is_loopback(const struct sockaddr *sa);
|
||||
int evutil_sockaddr_is_loopback_(const struct sockaddr *sa);
|
||||
|
||||
|
||||
/**
|
||||
@ -339,16 +339,16 @@ int evutil_sockaddr_is_loopback(const struct sockaddr *sa);
|
||||
Returns a pointer to out. Always writes something into out, so it's safe
|
||||
to use the output of this function without checking it for NULL.
|
||||
*/
|
||||
const char *evutil_format_sockaddr_port(const struct sockaddr *sa, char *out, size_t outlen);
|
||||
const char *evutil_format_sockaddr_port_(const struct sockaddr *sa, char *out, size_t outlen);
|
||||
|
||||
long evutil_tv_to_msec(const struct timeval *tv);
|
||||
long evutil_tv_to_msec_(const struct timeval *tv);
|
||||
|
||||
int evutil_hex_char_to_int(char c);
|
||||
int evutil_hex_char_to_int_(char c);
|
||||
|
||||
void evutil_usleep(const struct timeval *tv);
|
||||
void evutil_usleep_(const struct timeval *tv);
|
||||
|
||||
#ifdef _WIN32
|
||||
HANDLE evutil_load_windows_system_library(const TCHAR *library_name);
|
||||
HANDLE evutil_load_windows_system_library_(const TCHAR *library_name);
|
||||
#endif
|
||||
|
||||
#ifndef EV_SIZE_FMT
|
||||
@ -388,11 +388,11 @@ HANDLE evutil_load_windows_system_library(const TCHAR *library_name);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
evutil_socket_t evutil_socket(int domain, int type, int protocol);
|
||||
evutil_socket_t evutil_accept4(evutil_socket_t sockfd, struct sockaddr *addr,
|
||||
evutil_socket_t evutil_socket_(int domain, int type, int protocol);
|
||||
evutil_socket_t evutil_accept4_(evutil_socket_t sockfd, struct sockaddr *addr,
|
||||
ev_socklen_t *addrlen, int flags);
|
||||
int evutil_make_internal_pipe(evutil_socket_t fd[2]);
|
||||
evutil_socket_t evutil_eventfd(unsigned initval, int flags);
|
||||
int evutil_make_internal_pipe_(evutil_socket_t fd[2]);
|
||||
evutil_socket_t evutil_eventfd_(unsigned initval, int flags);
|
||||
|
||||
#ifdef SOCK_NONBLOCK
|
||||
#define EVUTIL_SOCK_NONBLOCK SOCK_NONBLOCK
|
||||
|
@ -163,7 +163,7 @@ do_fd_clear(struct event_base *base,
|
||||
SOCKET s2;
|
||||
s2 = set->fd_array[i] = set->fd_array[set->fd_count];
|
||||
|
||||
ent2 = evmap_io_get_fdinfo(&base->io, s2);
|
||||
ent2 = evmap_io_get_fdinfo_(&base->io, s2);
|
||||
|
||||
if (!ent2) /* This indicates a bug. */
|
||||
return (0);
|
||||
@ -199,7 +199,7 @@ win32_init(struct event_base *_base)
|
||||
winop->readset_out->fd_count = winop->writeset_out->fd_count
|
||||
= winop->exset_out->fd_count = 0;
|
||||
|
||||
if (evsig_init(_base) < 0)
|
||||
if (evsig_init_(_base) < 0)
|
||||
winop->signals_are_broken = 1;
|
||||
|
||||
return (winop);
|
||||
@ -301,7 +301,7 @@ win32_dispatch(struct event_base *base, struct timeval *tv)
|
||||
win32op->readset_out->fd_count : win32op->writeset_out->fd_count;
|
||||
|
||||
if (!fd_count) {
|
||||
long msec = evutil_tv_to_msec(tv);
|
||||
long msec = evutil_tv_to_msec_(tv);
|
||||
/* Sleep's DWORD argument is unsigned long */
|
||||
if (msec < 0)
|
||||
msec = LONG_MAX;
|
||||
@ -331,7 +331,7 @@ win32_dispatch(struct event_base *base, struct timeval *tv)
|
||||
if (++i >= win32op->readset_out->fd_count)
|
||||
i = 0;
|
||||
s = win32op->readset_out->fd_array[i];
|
||||
evmap_io_active(base, s, EV_READ);
|
||||
evmap_io_active_(base, s, EV_READ);
|
||||
}
|
||||
}
|
||||
if (win32op->exset_out->fd_count) {
|
||||
@ -340,7 +340,7 @@ win32_dispatch(struct event_base *base, struct timeval *tv)
|
||||
if (++i >= win32op->exset_out->fd_count)
|
||||
i = 0;
|
||||
s = win32op->exset_out->fd_array[i];
|
||||
evmap_io_active(base, s, EV_WRITE);
|
||||
evmap_io_active_(base, s, EV_WRITE);
|
||||
}
|
||||
}
|
||||
if (win32op->writeset_out->fd_count) {
|
||||
@ -350,7 +350,7 @@ win32_dispatch(struct event_base *base, struct timeval *tv)
|
||||
if (++i >= win32op->writeset_out->fd_count)
|
||||
i = 0;
|
||||
s = win32op->writeset_out->fd_array[i];
|
||||
evmap_io_active(base, s, EV_WRITE);
|
||||
evmap_io_active_(base, s, EV_WRITE);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
@ -361,7 +361,7 @@ win32_dealloc(struct event_base *_base)
|
||||
{
|
||||
struct win32op *win32op = _base->evbase;
|
||||
|
||||
evsig_dealloc(_base);
|
||||
evsig_dealloc_(_base);
|
||||
if (win32op->readset_in)
|
||||
mm_free(win32op->readset_in);
|
||||
if (win32op->writeset_in)
|
||||
|
Loading…
x
Reference in New Issue
Block a user