Projectname large_stringclasses 15
values | Filepath large_stringlengths 4 106 ⌀ | Function large_stringlengths 11 3.45k | Label list |
|---|---|---|---|
Chromium | base/third_party/libevent/event.c |
int event_base_loopexit(struct event_base *event_base,
const struct timeval *tv) {
return (event_base_once(event_base, -1, EV_TIMEOUT, event_loopexit_cb,
event_base, tv));
} | [
0,
0
] |
Chromium | base/third_party/libevent/event.c | int event_loop(int flags) { return event_base_loop(current_base, flags); } | [
0,
0
] |
Chromium | base/third_party/libevent/event.c | static void event_once_cb(int fd, short events, void *arg) {
struct event_once *eonce = arg;
(*eonce->cb)(fd, events, eonce->arg);
free(eonce);
} | [
1,
0
] |
Chromium | base/third_party/libevent/event.c | int event_base_set(struct event_base *base, struct event *ev) {
if (ev->ev_flags != EVLIST_INIT)
return (-1);
ev->ev_base = base;
ev->ev_pri = base->nactivequeues / 2;
return (0);
} | [
1,
0
] |
Chromium | base/third_party/libevent/event.c | int event_del(struct event *ev) {
struct event_base *base;
event_debug(("event_del: %p, callback %p", ev, ev->ev_callback));
if (ev->ev_base == NULL)
return (-1);
base = ev->ev_base;
assert(!(ev->ev_flags & ~EVLIST_ALL));
/* See if we are just active executing this event in a loop */
if (ev->ev_n... | [
1,
0
] |
Chromium | base/third_party/libevent/event.c | static void timeout_correct(struct event_base *base, struct timeval *tv) {
struct event **pev;
unsigned int size;
struct timeval off;
if (use_monotonic)
return;
gettime(base, tv);
if (evutil_timercmp(tv, &base->event_tv, >=)) {
base->event_tv = *tv;
return;
}
event_debug(("%s: time is run... | [
0,
0
] |
Chromium | base/third_party/libevent/event_tagging.c | void encode_int(struct evbuffer *evbuf, ev_uint32_t number) {
int off = 1, nibbles = 0;
ev_uint8_t data[5];
memset(data, 0, sizeof(ev_uint32_t) + 1);
while (number) {
if (off & 0x1)
data[off / 2] = (data[off / 2] & 0xf0) | (number & 0x0f);
else
data[off / 2] = (data[off / 2] & 0x0f) | ((num... | [
1,
0
] |
Chromium | base/third_party/libevent/event_tagging.c |
void evtag_marshal_string(struct evbuffer *buf, ev_uint32_t tag,
const char *string) {
evtag_marshal(buf, tag, string, strlen(string));
} | [
0,
0
] |
Chromium | base/third_party/libevent/event_tagging.c | int evtag_peek_length(struct evbuffer *evbuf, ev_uint32_t *plength) {
struct evbuffer tmp;
int res, len;
len = decode_tag_internal(NULL, evbuf, 0);
if (len == -1)
return (-1);
tmp = *evbuf;
tmp.buffer += len;
tmp.off -= len;
res = decode_int_internal(plength, &tmp, 0);
if (res == -1)
return... | [
1,
0
] |
Chromium | base/third_party/libevent/event_tagging.c | int evtag_payload_length(struct evbuffer *evbuf, ev_uint32_t *plength) {
struct evbuffer tmp;
int res, len;
len = decode_tag_internal(NULL, evbuf, 0);
if (len == -1)
return (-1);
tmp = *evbuf;
tmp.buffer += len;
tmp.off -= len;
res = decode_int_internal(plength, &tmp, 0);
if (res == -1)
ret... | [
0,
0
] |
Chromium | base/third_party/libevent/event_tagging.c | int evtag_unmarshal_int(struct evbuffer *evbuf, ev_uint32_t need_tag,
ev_uint32_t *pinteger) {
ev_uint32_t tag;
ev_uint32_t len;
ev_uint32_t integer;
if (decode_tag_internal(&tag, evbuf, 1) == -1)
return (-1);
if (need_tag != tag)
return (-1);
if (evtag_decode_int(&integer, ... | [
0,
0
] |
Chromium | base/third_party/libevent/evport.c | static void *evport_init(struct event_base *base) {
struct evport_data *evpd;
int i;
if (evutil_getenv("EVENT_NOEVPORT"))
return (NULL);
if (!(evpd = calloc(1, sizeof(struct evport_data))))
return (NULL);
if ((evpd->ed_port = port_create()) == -1) {
free(evpd);
return (NULL);
}
/*
*... | [
1,
0
] |
Chromium | base/third_party/libevent/evport.c | static int evport_add(void *arg, struct event *ev) {
struct evport_data *evpd = arg;
struct fd_info *fdi;
int factor;
check_evportop(evpd);
if (ev->ev_events & EV_SIGNAL)
return (evsignal_add(ev));
/*
* If necessary, grow the file descriptor info table
*/
factor = 1;
while (ev->ev_fd >= fa... | [
0,
0
] |
Chromium | base/third_party/libevent/evrpc.c |
void *evrpc_add_hook(void *vbase, enum EVRPC_HOOK_TYPE hook_type,
int (*cb)(struct evhttp_request *, struct evbuffer *,
void *),
void *cb_arg) {
struct _evrpc_hooks *base = vbase;
struct evrpc_hook_list *head = NULL;
struct evrpc_hook *hook... | [
1,
0
] |
Chromium | base/third_party/libevent/evrpc.c |
static int evrpc_remove_hook_internal(struct evrpc_hook_list *head,
void *handle) {
struct evrpc_hook *hook = NULL;
TAILQ_FOREACH(hook, head, next) {
if (hook == handle) {
TAILQ_REMOVE(head, hook, next);
free(hook);
return (1);
}
}
return (0);
} | [
1,
0
] |
Chromium | base/third_party/libevent/evrpc.c | static char *evrpc_construct_uri(const char *uri) {
char *constructed_uri;
int constructed_uri_len;
constructed_uri_len = strlen(EVRPC_URI_PREFIX) + strlen(uri) + 1;
if ((constructed_uri = malloc(constructed_uri_len)) == NULL)
event_err(1, "%s: failed to register rpc at %s", __func__, uri);
memcpy(constr... | [
1,
0
] |
Chromium | base/third_party/libevent/evrpc.c |
int evrpc_register_rpc(struct evrpc_base *base, struct evrpc *rpc,
void (*cb)(struct evrpc_req_generic *, void *),
void *cb_arg) {
char *constructed_uri = evrpc_construct_uri(rpc->uri);
rpc->base = base;
rpc->cb = cb;
rpc->cb_arg = cb_arg;
TAILQ_INSERT_TAIL(&ba... | [
1,
0
] |
Chromium | base/third_party/libevent/evrpc.c |
struct evrpc_pool *evrpc_pool_new(struct event_base *base) {
struct evrpc_pool *pool = calloc(1, sizeof(struct evrpc_pool));
if (pool == NULL)
return (NULL);
TAILQ_INIT(&pool->connections);
TAILQ_INIT(&pool->requests);
TAILQ_INIT(&pool->input_hooks);
TAILQ_INIT(&pool->output_hooks);
pool->base = b... | [
1,
0
] |
Chromium | base/third_party/libevent/evrpc.c |
static void evrpc_request_wrapper_free(struct evrpc_request_wrapper *request) {
free(request->name);
free(request);
} | [
1,
0
] |
Chromium | base/third_party/libevent/evrpc.c | void evrpc_pool_free(struct evrpc_pool *pool) {
struct evhttp_connection *connection;
struct evrpc_request_wrapper *request;
struct evrpc_hook *hook;
while ((request = TAILQ_FIRST(&pool->requests)) != NULL) {
TAILQ_REMOVE(&pool->requests, request, next);
evrpc_request_wrapper_free(request);
}
whi... | [
1,
0
] |
Chromium | base/third_party/libevent/evrpc.c | static struct evhttp_connection *
evrpc_pool_find_connection(struct evrpc_pool *pool) {
struct evhttp_connection *connection;
TAILQ_FOREACH(connection, &pool->connections, next) {
if (TAILQ_FIRST(&connection->requests) == NULL)
return (connection);
}
return (NULL);
} | [
0,
0
] |
Chromium | base/third_party/libevent/evutil.c |
int evutil_snprintf(char *buf, size_t buflen, const char *format, ...) {
int r;
va_list ap;
va_start(ap, format);
r = evutil_vsnprintf(buf, buflen, format, ap);
va_end(ap);
return r;
} | [
0,
0
] |
Chromium | base/third_party/libevent/http.c | static int fake_getaddrinfo(const char *hostname, struct addrinfo *ai) {
struct hostent *he = NULL;
struct sockaddr_in *sa;
if (hostname) {
he = gethostbyname(hostname);
if (!he)
return (-1);
}
ai->ai_family = he ? he->h_addrtype : AF_INET;
ai->ai_socktype = SOCK_STREAM;
ai->ai_protocol = 0;... | [
1,
0
] |
Chromium | base/third_party/libevent/http.c | static void fake_freeaddrinfo(struct addrinfo *ai) { free(ai->ai_addr); }
#endif
#ifndef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif
#define EVHTTP_BASE_SET(x, y) \
do { \
if ((x)-... | [
1,
0
] |
Chromium | base/third_party/libevent/http.c |
static const char *evhttp_method(enum evhttp_cmd_type type) {
const char *method;
switch (type) {
case EVHTTP_REQ_GET:
method = "GET";
break;
case EVHTTP_REQ_POST:
method = "POST";
break;
case EVHTTP_REQ_HEAD:
method = "HEAD";
break;
default:
method = NULL;
break;
}
re... | [
0,
0
] |
Chromium | base/third_party/libevent/http.c | void evhttp_write_buffer(struct evhttp_connection *evcon,
void (*cb)(struct evhttp_connection *, void *),
void *arg) {
event_debug(("%s: preparing to write buffer\n", __func__));
evcon->cb = cb;
evcon->cb_arg = arg;
/* check if the event is already pending */
... | [
0,
0
] |
Chromium | base/third_party/libevent/http.c |
static int evhttp_connected(struct evhttp_connection *evcon) {
switch (evcon->state) {
case EVCON_DISCONNECTED:
case EVCON_CONNECTING:
return (0);
case EVCON_IDLE:
case EVCON_READING_FIRSTLINE:
case EVCON_READING_HEADERS:
case EVCON_READING_BODY:
case EVCON_READING_TRAILER:
case EVCON_WRITING:
... | [
0,
0
] |
Chromium | base/third_party/libevent/http.c | static int evhttp_is_connection_close(int flags, struct evkeyvalq *headers) {
if (flags & EVHTTP_PROXY_REQUEST) {
const char *connection = evhttp_find_header(headers, "Proxy-Connection");
return (connection == NULL || strcasecmp(connection, "keep-alive") != 0);
} else {
const char *connection = evhttp_... | [
1,
0
] |
Chromium | base/third_party/libevent/http.c |
static void evhttp_maybe_add_content_length_header(struct evkeyvalq *headers,
long content_length) {
if (evhttp_find_header(headers, "Transfer-Encoding") == NULL &&
evhttp_find_header(headers, "Content-Length") == NULL) {
char len[22];
evutil_snprintf(... | [
1,
0
] |
Chromium | base/third_party/libevent/http.c | static void evhttp_make_header_response(struct evhttp_connection *evcon,
struct evhttp_request *req) {
int is_keepalive = evhttp_is_connection_keepalive(req->input_headers);
evbuffer_add_printf(evcon->output_buffer, "HTTP/%d.%d %d %s\r\n", req->major,
re... | [
1,
0
] |
Chromium | base/third_party/libevent/http.c | void evhttp_read(int fd, short what, void *arg) {
struct evhttp_connection *evcon = arg;
struct evhttp_request *req = TAILQ_FIRST(&evcon->requests);
struct evbuffer *buf = evcon->input_buffer;
int n, len;
if (what == EV_TIMEOUT) {
evhttp_connection_fail(evcon, EVCON_HTTP_TIMEOUT);
return;
}
n = e... | [
1,
0
] |
Chromium | base/third_party/libevent/http.c | static void evhttp_request_dispatch(struct evhttp_connection *evcon) {
struct evhttp_request *req = TAILQ_FIRST(&evcon->requests);
if (req == NULL)
return;
/* delete possible close detection events */
evhttp_connection_stop_detectclose(evcon);
/* we assume that the connection is connected already */
... | [
0,
0
] |
Chromium | base/third_party/libevent/http.c | void evhttp_connection_reset(struct evhttp_connection *evcon) {
if (event_initialized(&evcon->ev))
event_del(&evcon->ev);
if (evcon->fd != -1) {
if (evhttp_connected(evcon) && evcon->closecb != NULL)
(*evcon->closecb)(evcon, evcon->closecb_arg);
EVUTIL_CLOSESOCKET(evcon->fd);
evcon->fd = -1... | [
1,
0
] |
Chromium | base/third_party/libevent/http.c |
static void evhttp_detect_close_cb(int fd, short what, void *arg) {
struct evhttp_connection *evcon = arg;
evhttp_connection_reset(evcon);
} | [
0,
0
] |
Chromium | base/third_party/libevent/http.c |
static void
evhttp_connection_start_detectclose(struct evhttp_connection *evcon) {
evcon->flags |= EVHTTP_CON_CLOSEDETECT;
if (event_initialized(&evcon->close_ev))
event_del(&evcon->close_ev);
event_set(&evcon->close_ev, evcon->fd, EV_READ, evhttp_detect_close_cb,
evcon);
EVHTTP_BASE_SET(evcon... | [
0,
0
] |
Chromium | base/third_party/libevent/http.c | int evhttp_remove_header(struct evkeyvalq *headers, const char *key) {
struct evkeyval *header;
TAILQ_FOREACH(header, headers, next) {
if (strcasecmp(header->key, key) == 0)
break;
}
if (header == NULL)
return (-1);
TAILQ_REMOVE(headers, header, next);
free(header->key);
free(header->valu... | [
1,
0
] |
Chromium | base/third_party/libevent/http.c |
static int evhttp_append_to_last_header(struct evkeyvalq *headers,
const char *line) {
struct evkeyval *header = TAILQ_LAST(headers, evkeyvalq);
char *newval;
size_t old_len, line_len;
if (header == NULL)
return (-1);
old_len = strlen(header->value);
line_len =... | [
1,
0
] |
Chromium | base/third_party/libevent/http.c | static void evhttp_get_body(struct evhttp_connection *evcon,
struct evhttp_request *req) {
const char *xfer_enc;
if (req->kind == EVHTTP_REQUEST && req->type != EVHTTP_REQ_POST) {
evhttp_connection_done(evcon);
return;
}
evcon->state = EVCON_READING_BODY;
xfer_enc = evhttp... | [
1,
0
] |
Chromium | base/third_party/libevent/http.c | static void evhttp_read_header(struct evhttp_connection *evcon,
struct evhttp_request *req) {
enum message_read_status res;
int fd = evcon->fd;
res = evhttp_parse_headers(req, evcon->input_buffer);
if (res == DATA_CORRUPTED) {
event_debug(("%s: bad header lines on %d\n", __f... | [
1,
0
] |
Chromium | base/third_party/libevent/http.c |
void evhttp_connection_set_retries(struct evhttp_connection *evcon,
int retry_max) {
evcon->retry_max = retry_max;
} | [
0,
0
] |
Chromium | base/third_party/libevent/http.c |
void evhttp_connection_get_peer(struct evhttp_connection *evcon, char **address,
u_short *port) {
*address = evcon->address;
*port = evcon->port;
} | [
0,
0
] |
Chromium | base/third_party/libevent/http.c | int evhttp_make_request(struct evhttp_connection *evcon,
struct evhttp_request *req, enum evhttp_cmd_type type,
const char *uri) {
req->kind = EVHTTP_REQUEST;
req->type = type;
if (req->uri != NULL)
free(req->uri);
if ((req->uri = strdup(uri)) == NULL)
ev... | [
1,
0
] |
Chromium | base/third_party/libevent/http.c | static void evhttp_send_done(struct evhttp_connection *evcon, void *arg) {
int need_close;
struct evhttp_request *req = TAILQ_FIRST(&evcon->requests);
TAILQ_REMOVE(&evcon->requests, req, next);
evhttp_connection_stop_detectclose(evcon);
need_close = (req->minor == 0 &&
!evhttp_is_connection_... | [
1,
0
] |
Chromium | base/third_party/libevent/http.c |
void evhttp_send_reply(struct evhttp_request *req, int code, const char *reason,
struct evbuffer *databuf) {
evhttp_response_code(req, code, reason);
evhttp_send(req, databuf);
} | [
0,
0
] |
Chromium | base/third_party/libevent/http.c | void evhttp_send_reply_start(struct evhttp_request *req, int code,
const char *reason) {
evhttp_response_code(req, code, reason);
if (req->major == 1 && req->minor == 1) {
evhttp_add_header(req->output_headers, "Transfer-Encoding", "chunked");
req->chunked = 1;
}
evhttp_mak... | [
1,
0
] |
Chromium | base/third_party/libevent/http.c |
void evhttp_send_reply_chunk(struct evhttp_request *req,
struct evbuffer *databuf) {
struct evhttp_connection *evcon = req->evcon;
if (evcon == NULL)
return;
if (req->chunked) {
evbuffer_add_printf(evcon->output_buffer, "%x\r\n",
(unsigned)EVBUFFER_L... | [
0,
0
] |
Chromium | base/third_party/libevent/http.c |
void evhttp_send_page(struct evhttp_request *req, struct evbuffer *databuf) {
if (!req->major || !req->minor) {
req->major = 1;
req->minor = 1;
}
if (req->kind != EVHTTP_RESPONSE)
evhttp_response_code(req, 200, "OK");
evhttp_clear_headers(req->output_headers);
evhttp_add_header(req->output_head... | [
0,
0
] |
Chromium | base/third_party/libevent/http.c | void evhttp_parse_query(const char *uri, struct evkeyvalq *headers) {
char *line;
char *argument;
char *p;
TAILQ_INIT(headers);
if (strchr(uri, '?') == NULL)
return;
if ((line = strdup(uri)) == NULL)
event_err(1, "%s: strdup", __func__);
argument = line;
/* We already know that there has to... | [
1,
0
] |
Chromium | base/third_party/libevent/http.c | static void evhttp_handle_request(struct evhttp_request *req, void *arg) {
struct evhttp *http = arg;
struct evhttp_cb *cb = NULL;
event_debug(("%s: req->uri=%s", __func__, req->uri));
if (req->uri == NULL) {
event_debug(("%s: bad request", __func__));
if (req->evcon->state == EVCON_DISCONNECTED) {
... | [
1,
0
] |
Chromium | base/third_party/libevent/http.c |
static void accept_socket(int fd, short what, void *arg) {
struct evhttp *http = arg;
struct sockaddr_storage ss;
socklen_t addrlen = sizeof(ss);
int nfd;
if ((nfd = accept(fd, (struct sockaddr *)&ss, &addrlen)) == -1) {
if (errno != EAGAIN && errno != EINTR)
event_warn("%s: bad accept", __func__)... | [
1,
0
] |
Chromium | base/third_party/libevent/http.c | int evhttp_bind_socket(struct evhttp *http, const char *address, u_short port) {
int fd;
int res;
if ((fd = bind_socket(address, port, 1)) == -1)
return (-1);
if (listen(fd, 128) == -1) {
event_warn("%s: listen", __func__);
EVUTIL_CLOSESOCKET(fd);
return (-1);
}
res = evhttp_accept_socket... | [
1,
0
] |
Chromium | base/third_party/libevent/http.c | int evhttp_accept_socket(struct evhttp *http, int fd) {
struct evhttp_bound_socket *bound;
struct event *ev;
int res;
bound = malloc(sizeof(struct evhttp_bound_socket));
if (bound == NULL)
return (-1);
ev = &bound->bind_ev;
event_set(ev, fd, EV_READ | EV_PERSIST, accept_socket, http);
EVHTTP_BASE... | [
1,
0
] |
Chromium | base/third_party/libevent/http.c |
static struct evhttp *evhttp_new_object(void) {
struct evhttp *http = NULL;
if ((http = calloc(1, sizeof(struct evhttp))) == NULL) {
event_warn("%s: calloc", __func__);
return (NULL);
}
http->timeout = -1;
TAILQ_INIT(&http->sockets);
TAILQ_INIT(&http->callbacks);
TAILQ_INIT(&http->connections)... | [
1,
0
] |
Chromium | base/third_party/libevent/http.c | struct evhttp *evhttp_start(const char *address, u_short port) {
struct evhttp *http = evhttp_new_object();
if (evhttp_bind_socket(http, address, port) == -1) {
free(http);
return (NULL);
}
return (http);
} | [
1,
0
] |
Chromium | base/third_party/libevent/http.c |
void evhttp_set_gencb(struct evhttp *http,
void (*cb)(struct evhttp_request *, void *),
void *cbarg) {
http->gencb = cb;
http->gencbarg = cbarg;
} | [
0,
0
] |
Chromium | base/third_party/libevent/http.c | struct evhttp_request *
evhttp_request_new(void (*cb)(struct evhttp_request *, void *), void *arg) {
struct evhttp_request *req = NULL;
if ((req = calloc(1, sizeof(struct evhttp_request))) == NULL) {
event_warn("%s: calloc", __func__);
goto error;
}
req->kind = EVHTTP_RESPONSE;
req->input_headers = ... | [
1,
0
] |
Chromium | base/third_party/libevent/http.c | const char *evhttp_request_uri(struct evhttp_request *req) {
if (req->uri == NULL)
event_debug(("%s: request %p has no uri\n", __func__, req));
return (req->uri);
} | [
0,
0
] |
Chromium | base/third_party/libevent/http.c | static struct evhttp_connection *
evhttp_get_request_connection(struct evhttp *http, int fd, struct sockaddr *sa,
socklen_t salen) {
struct evhttp_connection *evcon;
char *hostname = NULL, *portname = NULL;
name_from_addr(sa, salen, &hostname, &portname);
if (hostname == NULL || p... | [
1,
0
] |
Chromium | base/third_party/libevent/http.c | static int bind_socket_ai(struct addrinfo *ai, int reuse) {
int fd, on = 1, r;
int serrno;
fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd == -1) {
event_warn("socket");
return (-1);
}
if (evutil_make_socket_nonblocking(fd) < 0)
goto out;
#ifndef WIN32
if (fcntl(fd, F_SETFD, 1) == -1) {
ev... | [
1,
1
] |
Chromium | base/third_party/libevent/http.c | static int bind_socket(const char *address, u_short port, int reuse) {
int fd;
struct addrinfo *aitop = NULL;
if (address == NULL && port == 0)
return bind_socket_ai(NULL, 0);
aitop = make_addrinfo(address, port);
if (aitop == NULL)
return (-1);
fd = bind_socket_ai(aitop, reuse);
#ifdef HAVE_GE... | [
0,
0
] |
Chromium | base/third_party/libevent/http.c | static int socket_connect(int fd, const char *address, unsigned short port) {
struct addrinfo *ai = make_addrinfo(address, port);
int res = -1;
if (ai == NULL) {
event_debug(("%s: make_addrinfo: \"%s:%d\"", __func__, address, port));
return (-1);
}
if (connect(fd, ai->ai_addr, ai->ai_addrlen) == -1)... | [
1,
0
] |
Chromium | base/third_party/libevent/kqueue.c | static void *kq_init(struct event_base *base) {
int i, kq;
struct kqop *kqueueop;
if (evutil_getenv("EVENT_NOKQUEUE"))
return (NULL);
if (!(kqueueop = calloc(1, sizeof(struct kqop))))
return (NULL);
/* Initalize the kernel queue */
if ((kq = kqueue()) == -1) {
event_warn("kqueue");
free(... | [
1,
0
] |
Chromium | base/third_party/libevent/kqueue.c | static int kq_insert(struct kqop *kqop, struct kevent *kev) {
int nevents = kqop->nevents;
if (kqop->nchanges == nevents) {
struct kevent *newchange;
struct kevent *newresult;
nevents *= 2;
newchange = realloc(kqop->changes, nevents * sizeof(struct kevent));
if (newchange == NULL) {
eve... | [
1,
0
] |
Chromium | base/third_party/libevent/log.c |
void event_err(int eval, const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
_warn_helper(_EVENT_LOG_ERR, errno, fmt, ap);
va_end(ap);
exit(eval);
} | [
0,
0
] |
Chromium | base/third_party/libevent/log.c |
void event_warn(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
_warn_helper(_EVENT_LOG_WARN, errno, fmt, ap);
va_end(ap);
} | [
0,
0
] |
Chromium | base/third_party/libevent/log.c |
static void _warn_helper(int severity, int log_errno, const char *fmt,
va_list ap) {
char buf[1024];
size_t len;
if (fmt != NULL)
evutil_vsnprintf(buf, sizeof(buf), fmt, ap);
else
buf[0] = '\0';
if (log_errno >= 0) {
len = strlen(buf);
if (len < sizeof(buf) - 3) {
... | [
1,
0
] |
Chromium | base/third_party/libevent/min_heap.h |
void min_heap_ctor(min_heap_t *s) {
s->p = 0;
s->n = 0;
s->a = 0;
} | [
1,
0
] |
Chromium | base/third_party/libevent/min_heap.h | int min_heap_empty(min_heap_t *s) { return 0u == s->n; } | [
0,
0
] |
Chromium | base/third_party/libevent/min_heap.h | unsigned min_heap_size(min_heap_t *s) { return s->n; } | [
0,
0
] |
Chromium | base/third_party/libevent/min_heap.h |
int min_heap_reserve(min_heap_t *s, unsigned n) {
if (s->a < n) {
struct event **p;
unsigned a = s->a ? s->a * 2 : 8;
if (a < n)
a = n;
if (!(p = (struct event **)realloc(s->p, a * sizeof *p)))
return -1;
s->p = p;
s->a = a;
}
return 0;
} | [
1,
0
] |
Chromium | base/third_party/libevent/min_heap.h |
void min_heap_shift_up_(min_heap_t *s, unsigned hole_index, struct event *e) {
unsigned parent = (hole_index - 1) / 2;
while (hole_index && min_heap_elem_greater(s->p[parent], e)) {
(s->p[hole_index] = s->p[parent])->min_heap_idx = hole_index;
hole_index = parent;
parent = (hole_index - 1) / 2;
}
(... | [
1,
0
] |
Chromium | base/third_party/libevent/nacl_nonsfi/signal_stub.c | int evsignal_init(struct event_base *base) { return 0; } | [
0,
0
] |
Chromium | base/third_party/libevent/nacl_nonsfi/signal_stub.c |
void evsignal_dealloc(struct event_base *base) {} | [
0,
0
] |
Chromium | base/third_party/libevent/poll.c | static int poll_del(void *arg, struct event *ev) {
struct pollop *pop = arg;
struct pollfd *pfd = NULL;
int i;
if (ev->ev_events & EV_SIGNAL)
return (evsignal_del(ev));
if (!(ev->ev_events & (EV_READ | EV_WRITE)))
return (0);
poll_check_ok(pop);
i = pop->idxplus1_by_fd[ev->ev_fd] - 1;
if (i <... | [
1,
0
] |
Chromium | base/third_party/libevent/sample/event-test.c | static void fifo_read(int fd, short event, void *arg) {
char buf[255];
int len;
struct event *ev = arg;
#ifdef WIN32
DWORD dwBytesRead;
#endif
event_add(ev, NULL);
fprintf(stderr, "fifo_read called with fd: %d, event: %d, arg: %p\n", fd,
event, arg);
#ifdef WIN32
len = ReadFile((HANDLE)fd, buf... | [
1,
0
] |
Chromium | base/third_party/libevent/sample/time-test.c | int main(int argc, char **argv) {
struct event timeout;
struct timeval tv;
event_init();
/* Initalize one event */
evtimer_set(&timeout, timeout_cb, &timeout);
evutil_timerclear(&tv);
tv.tv_sec = 2;
event_add(&timeout, &tv);
lasttime = time(NULL);
event_dispatch();
return (0);
} | [
0,
0
] |
Chromium | base/third_party/libevent/select.c | static void check_selectop(struct selectop *sop) {
int i;
for (i = 0; i <= sop->event_fds; ++i) {
if (FD_ISSET(i, sop->event_readset_in)) {
assert(sop->event_r_by_fd[i]);
assert(sop->event_r_by_fd[i]->ev_events & EV_READ);
assert(sop->event_r_by_fd[i]->ev_fd == i);
} else {
assert(!s... | [
1,
0
] |
Chromium | base/third_party/libevent/select.c |
static int select_dispatch(struct event_base *base, void *arg,
struct timeval *tv) {
int res, i, j;
struct selectop *sop = arg;
check_selectop(sop);
memcpy(sop->event_readset_out, sop->event_readset_in, sop->event_fdsz);
memcpy(sop->event_writeset_out, sop->event_writeset_in, sop... | [
1,
0
] |
Chromium | base/third_party/libevent/select.c | static int select_del(void *arg, struct event *ev) {
struct selectop *sop = arg;
check_selectop(sop);
if (ev->ev_events & EV_SIGNAL)
return (evsignal_del(ev));
if (sop->event_fds < ev->ev_fd) {
check_selectop(sop);
return (0);
}
if (ev->ev_events & EV_READ) {
FD_CLR(ev->ev_fd, sop->event_... | [
0,
0
] |
Chromium | base/third_party/libevent/signal.c | static void evsignal_cb(int fd, short what, void *arg) {
static char signals[1];
#ifdef WIN32
SSIZE_T n;
#else
ssize_t n;
#endif
n = recv(fd, signals, sizeof(signals), 0);
if (n == -1) {
int err = EVUTIL_SOCKET_ERROR();
if (!error_is_eagain(err))
event_err(1, "%s: read", __func__);
}
}
#ifde... | [
1,
0
] |
Chromium | base/third_party/libevent/signal.c | int evsignal_init(struct event_base *base) {
int i;
if (evutil_socketpair(AF_UNIX, SOCK_STREAM, 0, base->sig.ev_signal_pair) ==
-1) {
#ifdef WIN32
/* Make this nonfatal on win32, where sometimes people
have localhost firewalled. */
event_warn("%s: socketpair", __func__);
#else
event_err(1,... | [
1,
0
] |
Chromium | base/third_party/libevent/signal.c | int _evsignal_set_handler(struct event_base *base, int evsignal,
void (*handler)(int)) {
#ifdef HAVE_SIGACTION
struct sigaction sa;
#else
ev_sighandler_t sh;
#endif
struct evsignal_info *sig = &base->sig;
void *p;
if (evsignal >= sig->sh_old_max) {
int new_max = evsignal + 1;
... | [
1,
0
] |
Chromium | base/third_party/libevent/test/bench.c |
int main(int argc, char **argv) {
#ifndef WIN32
struct rlimit rl;
#endif
int i, c;
struct timeval *tv;
int *cp;
num_pipes = 100;
num_active = 1;
num_writes = num_pipes;
while ((c = getopt(argc, argv, "n:a:w:")) != -1) {
switch (c) {
case 'n':
num_pipes = atoi(optarg);
break;
ca... | [
1,
0
] |
Chromium | base/third_party/libevent/test/regress.c |
static void simple_read_cb(int fd, short event, void *arg) {
char buf[256];
int len;
if (arg == NULL)
return;
len = read(fd, buf, sizeof(buf));
if (len) {
if (!called) {
if (event_add(arg, NULL) == -1)
exit(1);
}
} else if (called == 1)
test_ok = 1;
called++;
} | [
1,
0
] |
Chromium | base/third_party/libevent/test/regress.c |
static void timeout_cb(int fd, short event, void *arg) {
struct timeval tv;
int diff;
evutil_gettimeofday(&tcalled, NULL);
if (evutil_timercmp(&tcalled, &tset, >))
evutil_timersub(&tcalled, &tset, &tv);
else
evutil_timersub(&tset, &tcalled, &tv);
diff = tv.tv_sec * 1000 + tv.tv_usec / 1000 - SECO... | [
1,
0
] |
Chromium | base/third_party/libevent/test/regress.c | static void test_registerfds(void) {
int i, j;
int pair[2];
struct event read_evs[512];
struct event write_evs[512];
struct event_base *base = event_base_new();
fprintf(stdout, "Testing register fds: ");
for (i = 0; i < 512; ++i) {
if (evutil_socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == -1) {
... | [
0,
0
] |
Chromium | base/third_party/libevent/test/regress.c |
static void test_combined(void) {
struct both r1, r2, w1, w2;
setup_test("Combined read/write: ");
memset(&r1, 0, sizeof(r1));
memset(&r2, 0, sizeof(r2));
memset(&w1, 0, sizeof(w1));
memset(&w2, 0, sizeof(w2));
w1.nread = 4096;
w2.nread = 8192;
event_set(&r1.ev, pair[0], EV_READ, combined_read_cb,... | [
1,
0
] |
Chromium | base/third_party/libevent/test/regress.c | static void test_signal_switchbase(void) {
struct event ev1, ev2;
struct event_base *base1, *base2;
int is_kqueue;
test_ok = 0;
printf("Signal switchbase: ");
base1 = event_init();
base2 = event_init();
is_kqueue = !strcmp(event_get_method(), "kqueue");
signal_set(&ev1, SIGUSR1, signal_cb, &ev1);
si... | [
0,
0
] |
Chromium | base/third_party/libevent/test/regress.c | static void timeout_cb_swp(int fd, short event, void *arg) {
if (called == -1) {
struct timeval tv = {5, 0};
called = 0;
evtimer_add((struct event *)arg, &tv);
raise(SIGUSR1);
return;
}
test_ok = 0;
event_loopexit(NULL);
} | [
0,
0
] |
Chromium | base/third_party/libevent/test/regress.c |
static void break_cb(int fd, short events, void *arg) {
test_ok = 1;
event_loopbreak();
} | [
0,
0
] |
Chromium | base/third_party/libevent/test/regress.c | static void readcb(struct bufferevent *bev, void *arg) {
if (EVBUFFER_LENGTH(bev->input) == 8333) {
bufferevent_disable(bev, EV_READ);
test_ok++;
}
} | [
0,
0
] |
Chromium | base/third_party/libevent/test/regress.c |
static void wm_writecb(struct bufferevent *bev, void *arg) {
if (EVBUFFER_LENGTH(bev->output) == 0)
test_ok++;
} | [
0,
0
] |
Chromium | base/third_party/libevent/test/regress.c |
static void wm_errorcb(struct bufferevent *bev, short what, void *arg) {
test_ok = -2;
} | [
0,
0
] |
Chromium | base/third_party/libevent/test/regress.c |
static void test_multiple_cb(int fd, short event, void *arg) {
if (event & EV_READ)
test_ok |= 1;
else if (event & EV_WRITE)
test_ok |= 2;
} | [
0,
0
] |
Chromium | base/third_party/libevent/test/regress.c | static void test_want_only_once(void) {
struct event ev;
struct timeval tv;
setup_test("Want read only once: ");
write(pair[0], TEST1, strlen(TEST1) + 1);
/* Setup the loop termination */
evutil_timerclear(&tv);
tv.tv_sec = 1;
event_loopexit(&tv);
event_set(&ev, pair[1], EV_READ, read_once_cb, &ev... | [
0,
0
] |
Chromium | base/third_party/libevent/test/regress.c |
static void evtag_tag_encoding(void) {
struct evbuffer *tmp = evbuffer_new();
uint32_t integers[TEST_MAX_INT] = {0xaf0, 0x1000, 0x1,
0xdeadbeef, 0x00, 0xbef000};
uint32_t integer;
int i;
for (i = 0; i < TEST_MAX_INT; i++) {
int oldlen, newlen;
oldlen = EVB... | [
0,
0
] |
Chromium | base/third_party/libevent/test/regress_dns.c | static void dns_gethostbyname_cb(int result, char type, int count, int ttl,
void *addresses, void *arg) {
dns_ok = dns_err = 0;
if (result == DNS_ERR_TIMEOUT) {
fprintf(stdout, "[Timed out] ");
dns_err = result;
goto out;
}
if (result != DNS_ERR_NONE) {
fprintf... | [
0,
0
] |
Chromium | base/third_party/libevent/test/regress_dns.c |
static void dns_gethostbyname6(void) {
fprintf(stdout, "IPv6 DNS resolve: ");
dns_ok = 0;
evdns_resolve_ipv6("www.ietf.org", 0, dns_gethostbyname_cb, NULL);
event_dispatch();
if (dns_ok == DNS_IPv6_AAAA) {
fprintf(stdout, "OK\n");
} else if (!dns_ok && dns_err == DNS_ERR_TIMEOUT) {
fprintf(stdout,... | [
1,
0
] |
Chromium | base/third_party/libevent/test/regress_dns.c | static void dns_server(void) {
int sock;
struct sockaddr_in my_addr;
struct evdns_server_port *port;
struct in_addr resolve_addr;
dns_ok = 1;
fprintf(stdout, "DNS server support: ");
evdns_nameserver_ip_add("127.0.0.1:35353");
if (evdns_count_nameservers() != 1) {
fprintf(stdout, "Couldn't set up.... | [
1,
0
] |
Chromium | base/third_party/libevent/test/regress_http.c | static struct evhttp *http_setup(short *pport, struct event_base *base) {
int i;
struct evhttp *myhttp;
short port = -1;
myhttp = evhttp_new(base);
for (i = 0; i < 50; ++i) {
if (evhttp_bind_socket(myhttp, "127.0.0.1", 8080 + i) != -1) {
port = 8080 + i;
break;
}
}
if (port == -1)
... | [
1,
0
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.