stream: Change api for stream_write
parent
caf9fe0130
commit
fef9ca1d7c
|
@ -81,7 +81,9 @@ struct stream* stream_new(int fd, stream_event_fn on_event, void* userdata);
|
||||||
int stream_close(struct stream* self);
|
int stream_close(struct stream* self);
|
||||||
void stream_destroy(struct stream* self);
|
void stream_destroy(struct stream* self);
|
||||||
ssize_t stream_read(struct stream* self, void* dst, size_t size);
|
ssize_t stream_read(struct stream* self, void* dst, size_t size);
|
||||||
int stream_write(struct stream* self, struct rcbuf* payload,
|
int stream_write(struct stream* self, const void* payload, size_t len,
|
||||||
|
stream_req_fn on_done, void* userdata);
|
||||||
|
int stream_send(struct stream* self, struct rcbuf* payload,
|
||||||
stream_req_fn on_done, void* userdata);
|
stream_req_fn on_done, void* userdata);
|
||||||
|
|
||||||
#ifdef ENABLE_TLS
|
#ifdef ENABLE_TLS
|
||||||
|
|
|
@ -304,7 +304,7 @@ failure:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int stream_write(struct stream* self, struct rcbuf* payload,
|
int stream_send(struct stream* self, struct rcbuf* payload,
|
||||||
stream_req_fn on_done, void* userdata)
|
stream_req_fn on_done, void* userdata)
|
||||||
{
|
{
|
||||||
if (self->state == STREAM_STATE_CLOSED)
|
if (self->state == STREAM_STATE_CLOSED)
|
||||||
|
@ -323,6 +323,13 @@ int stream_write(struct stream* self, struct rcbuf* payload,
|
||||||
return stream__flush(self);
|
return stream__flush(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int stream_write(struct stream* self, const void* payload, size_t len,
|
||||||
|
stream_req_fn on_done, void* userdata)
|
||||||
|
{
|
||||||
|
struct rcbuf* buf = rcbuf_from_mem(payload, len);
|
||||||
|
return buf ? stream_send(self, buf, on_done, userdata) : -1;
|
||||||
|
}
|
||||||
|
|
||||||
ssize_t stream__read_plain(struct stream* self, void* dst, size_t size)
|
ssize_t stream__read_plain(struct stream* self, void* dst, size_t size)
|
||||||
{
|
{
|
||||||
return read(self->fd, dst, size);
|
return read(self->fd, dst, size);
|
||||||
|
|
Loading…
Reference in New Issue