mirror of
https://github.com/cuberite/libevent.git
synced 2025-08-04 01:36:23 -04:00
Merge remote-tracking branch 'origin/patches-2.0'
This commit is contained in:
commit
b260065ab6
@ -114,8 +114,9 @@ bufferevent_socket_outbuf_cb(struct evbuffer *buf,
|
|||||||
!bufev_p->write_suspended) {
|
!bufev_p->write_suspended) {
|
||||||
/* Somebody added data to the buffer, and we would like to
|
/* Somebody added data to the buffer, and we would like to
|
||||||
* write, and we were not writing. So, start writing. */
|
* write, and we were not writing. So, start writing. */
|
||||||
be_socket_add(&bufev->ev_write, &bufev->timeout_write);
|
if (be_socket_add(&bufev->ev_write, &bufev->timeout_write) == -1) {
|
||||||
/* XXXX handle failure from be_socket_add */
|
// Should we log this?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
21
evrpc.c
21
evrpc.c
@ -339,8 +339,12 @@ static void
|
|||||||
evrpc_request_cb_closure(void *arg, enum EVRPC_HOOK_RESULT hook_res)
|
evrpc_request_cb_closure(void *arg, enum EVRPC_HOOK_RESULT hook_res)
|
||||||
{
|
{
|
||||||
struct evrpc_req_generic *rpc_state = arg;
|
struct evrpc_req_generic *rpc_state = arg;
|
||||||
struct evrpc *rpc = rpc_state->rpc;
|
struct evrpc *rpc;
|
||||||
struct evhttp_request *req = rpc_state->http_req;
|
struct evhttp_request *req;
|
||||||
|
|
||||||
|
EVUTIL_ASSERT(rpc_state);
|
||||||
|
rpc = rpc_state->rpc;
|
||||||
|
req = rpc_state->http_req;
|
||||||
|
|
||||||
if (hook_res == EVRPC_TERMINATE)
|
if (hook_res == EVRPC_TERMINATE)
|
||||||
goto error;
|
goto error;
|
||||||
@ -400,8 +404,13 @@ evrpc_request_done_closure(void *, enum EVRPC_HOOK_RESULT);
|
|||||||
void
|
void
|
||||||
evrpc_request_done(struct evrpc_req_generic *rpc_state)
|
evrpc_request_done(struct evrpc_req_generic *rpc_state)
|
||||||
{
|
{
|
||||||
struct evhttp_request *req = rpc_state->http_req;
|
struct evhttp_request *req;
|
||||||
struct evrpc *rpc = rpc_state->rpc;
|
struct evrpc *rpc;
|
||||||
|
|
||||||
|
EVUTIL_ASSERT(rpc_state);
|
||||||
|
|
||||||
|
req = rpc_state->http_req;
|
||||||
|
rpc = rpc_state->rpc;
|
||||||
|
|
||||||
if (rpc->reply_complete(rpc_state->reply) == -1) {
|
if (rpc->reply_complete(rpc_state->reply) == -1) {
|
||||||
/* the reply was not completely filled in. error out */
|
/* the reply was not completely filled in. error out */
|
||||||
@ -467,7 +476,9 @@ static void
|
|||||||
evrpc_request_done_closure(void *arg, enum EVRPC_HOOK_RESULT hook_res)
|
evrpc_request_done_closure(void *arg, enum EVRPC_HOOK_RESULT hook_res)
|
||||||
{
|
{
|
||||||
struct evrpc_req_generic *rpc_state = arg;
|
struct evrpc_req_generic *rpc_state = arg;
|
||||||
struct evhttp_request *req = rpc_state->http_req;
|
struct evhttp_request *req;
|
||||||
|
EVUTIL_ASSERT(rpc_state);
|
||||||
|
req = rpc_state->http_req;
|
||||||
|
|
||||||
if (hook_res == EVRPC_TERMINATE)
|
if (hook_res == EVRPC_TERMINATE)
|
||||||
goto error;
|
goto error;
|
||||||
|
2
evutil.c
2
evutil.c
@ -459,9 +459,9 @@ evutil_socket_connect(evutil_socket_t *fd_ptr, struct sockaddr *sa, int socklen)
|
|||||||
int made_fd = 0;
|
int made_fd = 0;
|
||||||
|
|
||||||
if (*fd_ptr < 0) {
|
if (*fd_ptr < 0) {
|
||||||
made_fd = 1;
|
|
||||||
if ((*fd_ptr = socket(sa->sa_family, SOCK_STREAM, 0)) < 0)
|
if ((*fd_ptr = socket(sa->sa_family, SOCK_STREAM, 0)) < 0)
|
||||||
goto err;
|
goto err;
|
||||||
|
made_fd = 1;
|
||||||
if (evutil_make_socket_nonblocking(*fd_ptr) < 0) {
|
if (evutil_make_socket_nonblocking(*fd_ptr) < 0) {
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
@ -173,6 +173,10 @@ main(int c, char **v) {
|
|||||||
evutil_socket_t sock;
|
evutil_socket_t sock;
|
||||||
struct sockaddr_in my_addr;
|
struct sockaddr_in my_addr;
|
||||||
sock = socket(PF_INET, SOCK_DGRAM, 0);
|
sock = socket(PF_INET, SOCK_DGRAM, 0);
|
||||||
|
if (sock == -1) {
|
||||||
|
perror("socket");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
evutil_make_socket_nonblocking(sock);
|
evutil_make_socket_nonblocking(sock);
|
||||||
my_addr.sin_family = AF_INET;
|
my_addr.sin_family = AF_INET;
|
||||||
my_addr.sin_port = htons(10053);
|
my_addr.sin_port = htons(10053);
|
||||||
|
@ -133,7 +133,8 @@ dump_request_cb(struct evhttp_request *req, void *arg)
|
|||||||
int n;
|
int n;
|
||||||
char cbuf[128];
|
char cbuf[128];
|
||||||
n = evbuffer_remove(buf, cbuf, sizeof(buf)-1);
|
n = evbuffer_remove(buf, cbuf, sizeof(buf)-1);
|
||||||
fwrite(cbuf, 1, n, stdout);
|
if (n > 0)
|
||||||
|
fwrite(cbuf, 1, n, stdout);
|
||||||
}
|
}
|
||||||
puts(">>>");
|
puts(">>>");
|
||||||
|
|
||||||
@ -179,6 +180,8 @@ send_document_cb(struct evhttp_request *req, void *arg)
|
|||||||
|
|
||||||
/* We need to decode it, to see what path the user really wanted. */
|
/* We need to decode it, to see what path the user really wanted. */
|
||||||
decoded_path = evhttp_uridecode(path, 0, NULL);
|
decoded_path = evhttp_uridecode(path, 0, NULL);
|
||||||
|
if (decoded_path == NULL)
|
||||||
|
goto err;
|
||||||
/* Don't allow any ".."s in the path, to avoid exposing stuff outside
|
/* Don't allow any ".."s in the path, to avoid exposing stuff outside
|
||||||
* of the docroot. This test is both overzealous and underzealous:
|
* of the docroot. This test is both overzealous and underzealous:
|
||||||
* it forbids aceptable paths like "/this/one..here", but it doesn't
|
* it forbids aceptable paths like "/this/one..here", but it doesn't
|
||||||
|
@ -91,6 +91,7 @@ main(int argc, char **argv)
|
|||||||
int c;
|
int c;
|
||||||
int use_iocp = 0;
|
int use_iocp = 0;
|
||||||
unsigned short port = 8080;
|
unsigned short port = 8080;
|
||||||
|
char *endptr = NULL;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
WSADATA WSAData;
|
WSADATA WSAData;
|
||||||
@ -113,11 +114,23 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'p':
|
case 'p':
|
||||||
port = atoi(argv[i+1]);
|
if (i+1 >= argc || !argv[i+1]) {
|
||||||
|
fprintf(stderr, "Missing port\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
port = (int)strtol(argv[i+1], &endptr, 10);
|
||||||
|
if (*endptr != '\0') {
|
||||||
|
fprintf(stderr, "Bad port\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
content_len = atol(argv[i+1]);
|
if (i+1 >= argc || !argv[i+1]) {
|
||||||
if (content_len == 0) {
|
fprintf(stderr, "Missing content length\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
content_len = (size_t)strtol(argv[i+1], &endptr, 10);
|
||||||
|
if (*endptr != '\0' || content_len == 0) {
|
||||||
fprintf(stderr, "Bad content length\n");
|
fprintf(stderr, "Bad content length\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user