mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-10 04:50:37 -04:00
Do not use the "evbuffer_" prefix to denote parts of bufferevents.
This is a bit of an interface doozy, but it's really needed in order to be able to document this stuff without apologizing it. This patch does the following renamings: evbuffercb -> bufferevent_data_cb everrorcb -> bufferevent_event_cb EVBUFFER_(READ,WRITE,...) -> BEV_EVENT_(...) EVBUFFER_(INPUT,OUTPUT) -> bufferevent_get_(input,output) All the old names are available in event2/bufferevent_compat.h svn:r1283
This commit is contained in:
parent
f11dff2c7a
commit
83f46e51d7
@ -19,7 +19,9 @@ Changes in 2.0.2-alpha:
|
|||||||
o New function to automate connecting on a socket-based bufferevent.
|
o New function to automate connecting on a socket-based bufferevent.
|
||||||
o New functions to automate listening for incoming TCP connections.
|
o New functions to automate listening for incoming TCP connections.
|
||||||
o Do case-insensitive checks with a locale-independent comparison function.
|
o Do case-insensitive checks with a locale-independent comparison function.
|
||||||
|
o Rename the evbuffercb and everrorcb callbacks to bufferevent_data_cb and bufferevent_event_cb respectively. The old names are available in bufferevent_compat.h.
|
||||||
|
o Rename the EVBUFFER_* codes used by bufferevent event callbacks to BEV_EVENT_*, to avoid namespace collision with evbuffer flags. The old names are available in bufferevent_compat.h.
|
||||||
|
o Move the EVBUFFER_INPUT and EVBUFFER_OUTPUT macros to bufferevent_compat.h
|
||||||
|
|
||||||
Changes in 2.0.1-alpha:
|
Changes in 2.0.1-alpha:
|
||||||
o free minheap on event_base_free(); from Christopher Layne
|
o free minheap on event_base_free(); from Christopher Layne
|
||||||
|
@ -252,7 +252,8 @@ bufferevent_init_common(struct bufferevent_private *bufev_private,
|
|||||||
|
|
||||||
void
|
void
|
||||||
bufferevent_setcb(struct bufferevent *bufev,
|
bufferevent_setcb(struct bufferevent *bufev,
|
||||||
evbuffercb readcb, evbuffercb writecb, everrorcb errorcb, void *cbarg)
|
bufferevent_data_cb readcb, bufferevent_data_cb writecb,
|
||||||
|
bufferevent_event_cb errorcb, void *cbarg)
|
||||||
{
|
{
|
||||||
BEV_LOCK(bufev);
|
BEV_LOCK(bufev);
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ be_pair_flush(struct bufferevent *bev, short iotype,
|
|||||||
if (mode == BEV_FINISHED) {
|
if (mode == BEV_FINISHED) {
|
||||||
if (partner->errorcb)
|
if (partner->errorcb)
|
||||||
(*partner->errorcb)(partner,
|
(*partner->errorcb)(partner,
|
||||||
iotype|EVBUFFER_EOF, partner->cbarg);
|
iotype|BEV_EVENT_EOF, partner->cbarg);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -115,11 +115,11 @@ bufferevent_readcb(evutil_socket_t fd, short event, void *arg)
|
|||||||
struct bufferevent *bufev = arg;
|
struct bufferevent *bufev = arg;
|
||||||
struct evbuffer *input;
|
struct evbuffer *input;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
short what = EVBUFFER_READ;
|
short what = BEV_EVENT_READING;
|
||||||
int howmuch = -1;
|
int howmuch = -1;
|
||||||
|
|
||||||
if (event == EV_TIMEOUT) {
|
if (event == EV_TIMEOUT) {
|
||||||
what |= EVBUFFER_TIMEOUT;
|
what |= BEV_EVENT_TIMEOUT;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,10 +147,10 @@ bufferevent_readcb(evutil_socket_t fd, short event, void *arg)
|
|||||||
if (EVUTIL_ERR_RW_RETRIABLE(err))
|
if (EVUTIL_ERR_RW_RETRIABLE(err))
|
||||||
goto reschedule;
|
goto reschedule;
|
||||||
/* error case */
|
/* error case */
|
||||||
what |= EVBUFFER_ERROR;
|
what |= BEV_EVENT_ERROR;
|
||||||
} else if (res == 0) {
|
} else if (res == 0) {
|
||||||
/* eof case */
|
/* eof case */
|
||||||
what |= EVBUFFER_EOF;
|
what |= BEV_EVENT_EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res <= 0)
|
if (res <= 0)
|
||||||
@ -179,15 +179,15 @@ bufferevent_writecb(evutil_socket_t fd, short event, void *arg)
|
|||||||
struct bufferevent_private *bufev_p =
|
struct bufferevent_private *bufev_p =
|
||||||
EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
|
EVUTIL_UPCAST(bufev, struct bufferevent_private, bev);
|
||||||
int res = 0;
|
int res = 0;
|
||||||
short what = EVBUFFER_WRITE;
|
short what = BEV_EVENT_WRITING;
|
||||||
|
|
||||||
if (event == EV_TIMEOUT) {
|
if (event == EV_TIMEOUT) {
|
||||||
what |= EVBUFFER_TIMEOUT;
|
what |= BEV_EVENT_TIMEOUT;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (bufev_p->connecting) {
|
if (bufev_p->connecting) {
|
||||||
bufev_p->connecting = 0;
|
bufev_p->connecting = 0;
|
||||||
_bufferevent_run_errorcb(bufev, EVBUFFER_CONNECTED);
|
_bufferevent_run_errorcb(bufev, BEV_EVENT_CONNECTED);
|
||||||
if (!(bufev->enabled & EV_WRITE)) {
|
if (!(bufev->enabled & EV_WRITE)) {
|
||||||
event_del(&bufev->ev_write);
|
event_del(&bufev->ev_write);
|
||||||
return;
|
return;
|
||||||
@ -202,10 +202,10 @@ bufferevent_writecb(evutil_socket_t fd, short event, void *arg)
|
|||||||
int err = evutil_socket_geterror(fd);
|
int err = evutil_socket_geterror(fd);
|
||||||
if (EVUTIL_ERR_RW_RETRIABLE(err))
|
if (EVUTIL_ERR_RW_RETRIABLE(err))
|
||||||
goto reschedule;
|
goto reschedule;
|
||||||
what |= EVBUFFER_ERROR;
|
what |= BEV_EVENT_ERROR;
|
||||||
} else if (res == 0) {
|
} else if (res == 0) {
|
||||||
/* eof case */
|
/* eof case */
|
||||||
what |= EVBUFFER_EOF;
|
what |= BEV_EVENT_EOF;
|
||||||
}
|
}
|
||||||
if (res <= 0)
|
if (res <= 0)
|
||||||
goto error;
|
goto error;
|
||||||
@ -298,11 +298,11 @@ bufferevent_socket_connect(struct bufferevent *bev,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_bufferevent_run_errorcb(bev, EVBUFFER_ERROR);
|
_bufferevent_run_errorcb(bev, BEV_EVENT_ERROR);
|
||||||
/* do something about the error? */
|
/* do something about the error? */
|
||||||
} else {
|
} else {
|
||||||
/* The connect succeeded already. How odd. */
|
/* The connect succeeded already. How odd. */
|
||||||
_bufferevent_run_errorcb(bev, EVBUFFER_CONNECTED);
|
_bufferevent_run_errorcb(bev, BEV_EVENT_CONNECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -320,8 +320,9 @@ bufferevent_socket_connect(struct bufferevent *bev,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
struct bufferevent *
|
struct bufferevent *
|
||||||
bufferevent_new(evutil_socket_t fd, evbuffercb readcb, evbuffercb writecb,
|
bufferevent_new(evutil_socket_t fd,
|
||||||
everrorcb errorcb, void *cbarg)
|
bufferevent_data_cb readcb, bufferevent_data_cb writecb,
|
||||||
|
bufferevent_event_cb errorcb, void *cbarg)
|
||||||
{
|
{
|
||||||
struct bufferevent *bufev;
|
struct bufferevent *bufev;
|
||||||
|
|
||||||
|
8
http.c
8
http.c
@ -1092,7 +1092,7 @@ evhttp_error_cb(struct bufferevent *bufev, short what, void *arg)
|
|||||||
|
|
||||||
switch (evcon->state) {
|
switch (evcon->state) {
|
||||||
case EVCON_CONNECTING:
|
case EVCON_CONNECTING:
|
||||||
if (what == EVBUFFER_TIMEOUT) {
|
if (what == BEV_EVENT_TIMEOUT) {
|
||||||
event_debug(("%s: connection timeout for \"%s:%d\" on %d",
|
event_debug(("%s: connection timeout for \"%s:%d\" on %d",
|
||||||
__func__, evcon->address, evcon->port,
|
__func__, evcon->address, evcon->port,
|
||||||
evcon->fd));
|
evcon->fd));
|
||||||
@ -1103,7 +1103,7 @@ evhttp_error_cb(struct bufferevent *bufev, short what, void *arg)
|
|||||||
|
|
||||||
case EVCON_READING_BODY:
|
case EVCON_READING_BODY:
|
||||||
if (!req->chunked && req->ntoread < 0
|
if (!req->chunked && req->ntoread < 0
|
||||||
&& what == (EVBUFFER_READ|EVBUFFER_EOF)) {
|
&& what == (BEV_EVENT_READING|BEV_EVENT_EOF)) {
|
||||||
/* EOF on read can be benign */
|
/* EOF on read can be benign */
|
||||||
evhttp_connection_done(evcon);
|
evhttp_connection_done(evcon);
|
||||||
return;
|
return;
|
||||||
@ -1135,9 +1135,9 @@ evhttp_error_cb(struct bufferevent *bufev, short what, void *arg)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (what & EVBUFFER_TIMEOUT) {
|
if (what & BEV_EVENT_TIMEOUT) {
|
||||||
evhttp_connection_fail(evcon, EVCON_HTTP_TIMEOUT);
|
evhttp_connection_fail(evcon, EVCON_HTTP_TIMEOUT);
|
||||||
} else if (what & (EVBUFFER_EOF|EVBUFFER_ERROR)) {
|
} else if (what & (BEV_EVENT_EOF|BEV_EVENT_ERROR)) {
|
||||||
evhttp_connection_fail(evcon, EVCON_HTTP_EOF);
|
evhttp_connection_fail(evcon, EVCON_HTTP_EOF);
|
||||||
} else {
|
} else {
|
||||||
evhttp_connection_fail(evcon, EVCON_HTTP_BUFFER_ERROR);
|
evhttp_connection_fail(evcon, EVCON_HTTP_BUFFER_ERROR);
|
||||||
|
@ -73,12 +73,12 @@ extern "C" {
|
|||||||
|
|
||||||
|
|
||||||
/* Just for error reporting - use other constants otherwise */
|
/* Just for error reporting - use other constants otherwise */
|
||||||
#define EVBUFFER_READ 0x01 /**< error encountered while reading */
|
#define BEV_EVENT_READING 0x01 /**< error encountered while reading */
|
||||||
#define EVBUFFER_WRITE 0x02 /**< error encountered while writing */
|
#define BEV_EVENT_WRITING 0x02 /**< error encountered while writing */
|
||||||
#define EVBUFFER_EOF 0x10 /**< eof file reached */
|
#define BEV_EVENT_EOF 0x10 /**< eof file reached */
|
||||||
#define EVBUFFER_ERROR 0x20 /**< unrecoverable error encountered */
|
#define BEV_EVENT_ERROR 0x20 /**< unrecoverable error encountered */
|
||||||
#define EVBUFFER_TIMEOUT 0x40 /**< user specified timeout reached */
|
#define BEV_EVENT_TIMEOUT 0x40 /**< user specified timeout reached */
|
||||||
#define EVBUFFER_CONNECTED 0x80 /**< connect operation finished. */
|
#define BEV_EVENT_CONNECTED 0x80 /**< connect operation finished. */
|
||||||
struct bufferevent;
|
struct bufferevent;
|
||||||
struct event_base;
|
struct event_base;
|
||||||
struct evbuffer;
|
struct evbuffer;
|
||||||
@ -97,9 +97,7 @@ struct sockaddr;
|
|||||||
@param bev the bufferevent that triggered the callback
|
@param bev the bufferevent that triggered the callback
|
||||||
@param ctx the user specified context for this bufferevent
|
@param ctx the user specified context for this bufferevent
|
||||||
*/
|
*/
|
||||||
/* XXXX we should rename this to bufferevent_cb; evbuffercb implies that it's
|
typedef void (*bufferevent_data_cb)(struct bufferevent *bev, void *ctx);
|
||||||
* a cb on an evbuffer. We should retain the old name in bufferevent_compat. */
|
|
||||||
typedef void (*evbuffercb)(struct bufferevent *bev, void *ctx);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
type defintion for the error callback of a bufferevent.
|
type defintion for the error callback of a bufferevent.
|
||||||
@ -108,14 +106,14 @@ typedef void (*evbuffercb)(struct bufferevent *bev, void *ctx);
|
|||||||
unrecoverable error was encountered.
|
unrecoverable error was encountered.
|
||||||
|
|
||||||
@param bev the bufferevent for which the error condition was reached
|
@param bev the bufferevent for which the error condition was reached
|
||||||
@param what a conjunction of flags: EVBUFFER_READ or EVBUFFER write to
|
@param what a conjunction of flags: BEV_EVENT_READING or BEV_EVENT_WRITING
|
||||||
indicate if the error was encountered on the read or write path,
|
to indicate if the error was encountered on the read or write path,
|
||||||
and one of the following flags: EVBUFFER_EOF, EVBUFFER_ERROR or
|
and one of the following flags: BEV_EVENT_EOF, BEV_EVENT_ERROR,
|
||||||
EVBUFFER_TIMEOUT.
|
BEV_EVENT_TIMEOUT, BEV_EVENT_CONNECTED.
|
||||||
|
|
||||||
@param ctx the user specified context for this bufferevent
|
@param ctx the user specified context for this bufferevent
|
||||||
*/
|
*/
|
||||||
/* XXXX we should rename this to bufferevent_error_cb; see above. */
|
typedef void (*bufferevent_event_cb)(struct bufferevent *bev, short what, void *ctx);
|
||||||
typedef void (*everrorcb)(struct bufferevent *bev, short what, void *ctx);
|
|
||||||
|
|
||||||
/** Options that can be specified when creating a bufferevent */
|
/** Options that can be specified when creating a bufferevent */
|
||||||
enum bufferevent_options {
|
enum bufferevent_options {
|
||||||
@ -147,7 +145,7 @@ struct bufferevent *bufferevent_socket_new(struct event_base *base, evutil_socke
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Launch a connect() attempt with a socket. When the connect succeeds,
|
Launch a connect() attempt with a socket. When the connect succeeds,
|
||||||
the errorcb will be invoked with EVBUFFER_CONNECTED set.
|
the errorcb will be invoked with BEV_EVENT_CONNECTED set.
|
||||||
|
|
||||||
If the bufferevent does not already have a socket set, we allocate a new
|
If the bufferevent does not already have a socket set, we allocate a new
|
||||||
socket here and make it nonblocking before we begin.
|
socket here and make it nonblocking before we begin.
|
||||||
@ -204,7 +202,8 @@ void bufferevent_free(struct bufferevent *bufev);
|
|||||||
@see bufferevent_new()
|
@see bufferevent_new()
|
||||||
*/
|
*/
|
||||||
void bufferevent_setcb(struct bufferevent *bufev,
|
void bufferevent_setcb(struct bufferevent *bufev,
|
||||||
evbuffercb readcb, evbuffercb writecb, everrorcb errorcb, void *cbarg);
|
bufferevent_data_cb readcb, bufferevent_data_cb writecb,
|
||||||
|
bufferevent_event_cb errorcb, void *cbarg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Changes the file descriptor on which the bufferevent operates.
|
Changes the file descriptor on which the bufferevent operates.
|
||||||
@ -342,11 +341,6 @@ void bufferevent_set_timeouts(struct bufferevent *bufev,
|
|||||||
void bufferevent_setwatermark(struct bufferevent *bufev, short events,
|
void bufferevent_setwatermark(struct bufferevent *bufev, short events,
|
||||||
size_t lowmark, size_t highmark);
|
size_t lowmark, size_t highmark);
|
||||||
|
|
||||||
/** macro for getting access to the input buffer of a bufferevent */
|
|
||||||
#define EVBUFFER_INPUT(x) bufferevent_get_input(x)
|
|
||||||
/** macro for getting access to the output buffer of a bufferevent */
|
|
||||||
#define EVBUFFER_OUTPUT(x) bufferevent_get_output(x)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Flags that can be passed into filters to let them know how to
|
Flags that can be passed into filters to let them know how to
|
||||||
deal with the incoming data.
|
deal with the incoming data.
|
||||||
|
@ -28,6 +28,9 @@
|
|||||||
#ifndef _EVENT2_BUFFEREVENT_COMPAT_H_
|
#ifndef _EVENT2_BUFFEREVENT_COMPAT_H_
|
||||||
#define _EVENT2_BUFFEREVENT_COMPAT_H_
|
#define _EVENT2_BUFFEREVENT_COMPAT_H_
|
||||||
|
|
||||||
|
#define evbuffercb bufferevent_data_cb
|
||||||
|
#define everrorcb bufferevent_event_cb
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Create a new bufferevent for an fd.
|
Create a new bufferevent for an fd.
|
||||||
|
|
||||||
@ -79,4 +82,16 @@ struct bufferevent *bufferevent_new(evutil_socket_t fd,
|
|||||||
void bufferevent_settimeout(struct bufferevent *bufev,
|
void bufferevent_settimeout(struct bufferevent *bufev,
|
||||||
int timeout_read, int timeout_write);
|
int timeout_read, int timeout_write);
|
||||||
|
|
||||||
|
#define EVBUFFER_READ BEV_EVENT_READING
|
||||||
|
#define EVBUFFER_WRITE BEV_EVENT_WRITING
|
||||||
|
#define EVBUFFER_EOF BEV_EVENT_EOF
|
||||||
|
#define EVBUFFER_ERROR BEV_EVENT_ERROR
|
||||||
|
#define EVBUFFER_TIMEOUT BEV_EVENT_TIMEOUT
|
||||||
|
#define EVBUFFER_CONNECTED BEV_EVENT_CONNECTED
|
||||||
|
|
||||||
|
/** macro for getting access to the input buffer of a bufferevent */
|
||||||
|
#define EVBUFFER_INPUT(x) bufferevent_get_input(x)
|
||||||
|
/** macro for getting access to the output buffer of a bufferevent */
|
||||||
|
#define EVBUFFER_OUTPUT(x) bufferevent_get_output(x)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -97,9 +97,9 @@ struct bufferevent {
|
|||||||
struct event_watermark wm_read;
|
struct event_watermark wm_read;
|
||||||
struct event_watermark wm_write;
|
struct event_watermark wm_write;
|
||||||
|
|
||||||
evbuffercb readcb;
|
bufferevent_data_cb readcb;
|
||||||
evbuffercb writecb;
|
bufferevent_data_cb writecb;
|
||||||
everrorcb errorcb;
|
bufferevent_event_cb errorcb;
|
||||||
void *cbarg;
|
void *cbarg;
|
||||||
|
|
||||||
struct timeval timeout_read;
|
struct timeval timeout_read;
|
||||||
|
@ -81,7 +81,7 @@ errorcb(struct bufferevent *b, short what, void *arg)
|
|||||||
{
|
{
|
||||||
struct request_info *ri = arg;
|
struct request_info *ri = arg;
|
||||||
struct timeval now, diff;
|
struct timeval now, diff;
|
||||||
if (what & EVBUFFER_EOF) {
|
if (what & BEV_EVENT_EOF) {
|
||||||
++total_n_handled;
|
++total_n_handled;
|
||||||
total_n_bytes += ri->n_read;
|
total_n_bytes += ri->n_read;
|
||||||
gettimeofday(&now, NULL);
|
gettimeofday(&now, NULL);
|
||||||
|
@ -405,15 +405,15 @@ static void
|
|||||||
reader_eventcb(struct bufferevent *bev, short what, void *ctx)
|
reader_eventcb(struct bufferevent *bev, short what, void *ctx)
|
||||||
{
|
{
|
||||||
struct event_base *base = ctx;
|
struct event_base *base = ctx;
|
||||||
if (what & EVBUFFER_ERROR) {
|
if (what & BEV_EVENT_ERROR) {
|
||||||
perror("foobar");
|
perror("foobar");
|
||||||
TT_FAIL(("got connector error %d", (int)what));
|
TT_FAIL(("got connector error %d", (int)what));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (what & EVBUFFER_CONNECTED) {
|
if (what & BEV_EVENT_CONNECTED) {
|
||||||
bufferevent_enable(bev, EV_READ);
|
bufferevent_enable(bev, EV_READ);
|
||||||
}
|
}
|
||||||
if (what & EVBUFFER_EOF) {
|
if (what & BEV_EVENT_EOF) {
|
||||||
char buf[512];
|
char buf[512];
|
||||||
size_t n;
|
size_t n;
|
||||||
n = bufferevent_read(bev, buf, sizeof(buf)-1);
|
n = bufferevent_read(bev, buf, sizeof(buf)-1);
|
||||||
|
@ -178,19 +178,19 @@ http_readcb(struct bufferevent *bev, void *arg)
|
|||||||
{
|
{
|
||||||
const char *what = BASIC_REQUEST_BODY;
|
const char *what = BASIC_REQUEST_BODY;
|
||||||
|
|
||||||
event_debug(("%s: %s\n", __func__, EVBUFFER_DATA(EVBUFFER_INPUT(bev))));
|
event_debug(("%s: %s\n", __func__, EVBUFFER_DATA(bufferevent_get_input(bev))));
|
||||||
|
|
||||||
if (evbuffer_find(EVBUFFER_INPUT(bev),
|
if (evbuffer_find(bufferevent_get_input(bev),
|
||||||
(const unsigned char*) what, strlen(what)) != NULL) {
|
(const unsigned char*) what, strlen(what)) != NULL) {
|
||||||
struct evhttp_request *req = evhttp_request_new(NULL, NULL);
|
struct evhttp_request *req = evhttp_request_new(NULL, NULL);
|
||||||
enum message_read_status done;
|
enum message_read_status done;
|
||||||
|
|
||||||
req->kind = EVHTTP_RESPONSE;
|
req->kind = EVHTTP_RESPONSE;
|
||||||
done = evhttp_parse_firstline(req, EVBUFFER_INPUT(bev));
|
done = evhttp_parse_firstline(req, bufferevent_get_input(bev));
|
||||||
if (done != ALL_DATA_READ)
|
if (done != ALL_DATA_READ)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
done = evhttp_parse_headers(req, EVBUFFER_INPUT(bev));
|
done = evhttp_parse_headers(req, bufferevent_get_input(bev));
|
||||||
if (done != ALL_DATA_READ)
|
if (done != ALL_DATA_READ)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@ -212,7 +212,7 @@ http_readcb(struct bufferevent *bev, void *arg)
|
|||||||
static void
|
static void
|
||||||
http_writecb(struct bufferevent *bev, void *arg)
|
http_writecb(struct bufferevent *bev, void *arg)
|
||||||
{
|
{
|
||||||
if (EVBUFFER_LENGTH(EVBUFFER_OUTPUT(bev)) == 0) {
|
if (EVBUFFER_LENGTH(bufferevent_get_output(bev)) == 0) {
|
||||||
/* enable reading of the reply */
|
/* enable reading of the reply */
|
||||||
bufferevent_enable(bev, EV_READ);
|
bufferevent_enable(bev, EV_READ);
|
||||||
test_ok++;
|
test_ok++;
|
||||||
@ -1171,7 +1171,7 @@ static void
|
|||||||
http_failure_readcb(struct bufferevent *bev, void *arg)
|
http_failure_readcb(struct bufferevent *bev, void *arg)
|
||||||
{
|
{
|
||||||
const char *what = "400 Bad Request";
|
const char *what = "400 Bad Request";
|
||||||
if (evbuffer_find(EVBUFFER_INPUT(bev),
|
if (evbuffer_find(bufferevent_get_input(bev),
|
||||||
(const unsigned char*) what, strlen(what)) != NULL) {
|
(const unsigned char*) what, strlen(what)) != NULL) {
|
||||||
test_ok = 2;
|
test_ok = 2;
|
||||||
bufferevent_disable(bev, EV_READ);
|
bufferevent_disable(bev, EV_READ);
|
||||||
@ -1480,7 +1480,7 @@ http_incomplete_writecb(struct bufferevent *bev, void *arg)
|
|||||||
/* terminate the write side to simulate EOF */
|
/* terminate the write side to simulate EOF */
|
||||||
shutdown(fd, SHUT_WR);
|
shutdown(fd, SHUT_WR);
|
||||||
}
|
}
|
||||||
if (EVBUFFER_LENGTH(EVBUFFER_OUTPUT(bev)) == 0) {
|
if (EVBUFFER_LENGTH(bufferevent_get_output(bev)) == 0) {
|
||||||
/* enable reading of the reply */
|
/* enable reading of the reply */
|
||||||
bufferevent_enable(bev, EV_READ);
|
bufferevent_enable(bev, EV_READ);
|
||||||
test_ok++;
|
test_ok++;
|
||||||
@ -1574,11 +1574,11 @@ http_chunked_errorcb(struct bufferevent *bev, short what, void *arg)
|
|||||||
enum message_read_status done;
|
enum message_read_status done;
|
||||||
|
|
||||||
req->kind = EVHTTP_RESPONSE;
|
req->kind = EVHTTP_RESPONSE;
|
||||||
done = evhttp_parse_firstline(req, EVBUFFER_INPUT(bev));
|
done = evhttp_parse_firstline(req, bufferevent_get_input(bev));
|
||||||
if (done != ALL_DATA_READ)
|
if (done != ALL_DATA_READ)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
done = evhttp_parse_headers(req, EVBUFFER_INPUT(bev));
|
done = evhttp_parse_headers(req, bufferevent_get_input(bev));
|
||||||
if (done != ALL_DATA_READ)
|
if (done != ALL_DATA_READ)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@ -1590,7 +1590,7 @@ http_chunked_errorcb(struct bufferevent *bev, short what, void *arg)
|
|||||||
if (header == NULL || strcmp(header, "close"))
|
if (header == NULL || strcmp(header, "close"))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
header = evbuffer_readln(EVBUFFER_INPUT(bev), NULL, EVBUFFER_EOL_CRLF);
|
header = evbuffer_readln(bufferevent_get_input(bev), NULL, EVBUFFER_EOL_CRLF);
|
||||||
if (header == NULL)
|
if (header == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
/* 13 chars */
|
/* 13 chars */
|
||||||
@ -1598,13 +1598,13 @@ http_chunked_errorcb(struct bufferevent *bev, short what, void *arg)
|
|||||||
goto out;
|
goto out;
|
||||||
free((char*)header);
|
free((char*)header);
|
||||||
|
|
||||||
if (strncmp((char *)evbuffer_pullup(EVBUFFER_INPUT(bev), 13),
|
if (strncmp((char *)evbuffer_pullup(bufferevent_get_input(bev), 13),
|
||||||
"This is funny", 13))
|
"This is funny", 13))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
evbuffer_drain(EVBUFFER_INPUT(bev), 13 + 2);
|
evbuffer_drain(bufferevent_get_input(bev), 13 + 2);
|
||||||
|
|
||||||
header = evbuffer_readln(EVBUFFER_INPUT(bev), NULL, EVBUFFER_EOL_CRLF);
|
header = evbuffer_readln(bufferevent_get_input(bev), NULL, EVBUFFER_EOL_CRLF);
|
||||||
if (header == NULL)
|
if (header == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
/* 18 chars */
|
/* 18 chars */
|
||||||
@ -1612,13 +1612,13 @@ http_chunked_errorcb(struct bufferevent *bev, short what, void *arg)
|
|||||||
goto out;
|
goto out;
|
||||||
free((char *)header);
|
free((char *)header);
|
||||||
|
|
||||||
if (strncmp((char *)evbuffer_pullup(EVBUFFER_INPUT(bev), 18),
|
if (strncmp((char *)evbuffer_pullup(bufferevent_get_input(bev), 18),
|
||||||
"but not hilarious.", 18))
|
"but not hilarious.", 18))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
evbuffer_drain(EVBUFFER_INPUT(bev), 18 + 2);
|
evbuffer_drain(bufferevent_get_input(bev), 18 + 2);
|
||||||
|
|
||||||
header = evbuffer_readln(EVBUFFER_INPUT(bev), NULL, EVBUFFER_EOL_CRLF);
|
header = evbuffer_readln(bufferevent_get_input(bev), NULL, EVBUFFER_EOL_CRLF);
|
||||||
if (header == NULL)
|
if (header == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
/* 8 chars */
|
/* 8 chars */
|
||||||
@ -1626,13 +1626,13 @@ http_chunked_errorcb(struct bufferevent *bev, short what, void *arg)
|
|||||||
goto out;
|
goto out;
|
||||||
free((char *)header);
|
free((char *)header);
|
||||||
|
|
||||||
if (strncmp((char *)evbuffer_pullup(EVBUFFER_INPUT(bev), 8),
|
if (strncmp((char *)evbuffer_pullup(bufferevent_get_input(bev), 8),
|
||||||
"bwv 1052.", 8))
|
"bwv 1052.", 8))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
evbuffer_drain(EVBUFFER_INPUT(bev), 8 + 2);
|
evbuffer_drain(bufferevent_get_input(bev), 8 + 2);
|
||||||
|
|
||||||
header = evbuffer_readln(EVBUFFER_INPUT(bev), NULL, EVBUFFER_EOL_CRLF);
|
header = evbuffer_readln(bufferevent_get_input(bev), NULL, EVBUFFER_EOL_CRLF);
|
||||||
if (header == NULL)
|
if (header == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
/* 0 chars */
|
/* 0 chars */
|
||||||
@ -1652,7 +1652,7 @@ out:
|
|||||||
static void
|
static void
|
||||||
http_chunked_writecb(struct bufferevent *bev, void *arg)
|
http_chunked_writecb(struct bufferevent *bev, void *arg)
|
||||||
{
|
{
|
||||||
if (EVBUFFER_LENGTH(EVBUFFER_OUTPUT(bev)) == 0) {
|
if (EVBUFFER_LENGTH(bufferevent_get_output(bev)) == 0) {
|
||||||
/* enable reading of the reply */
|
/* enable reading of the reply */
|
||||||
bufferevent_enable(bev, EV_READ);
|
bufferevent_enable(bev, EV_READ);
|
||||||
test_ok++;
|
test_ok++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user