commit - 8d9aeea2c909b41533ac80622b532f93657fb815
commit + a0ec9cd6ce94b26faa1ab2f4407e6b0d0d43045d
blob - 8c8ec7c513c627a32563450da7ea4622807fc12a
blob + c6cdf5586d0d1fdfafc4b4d381167e34885c01d4
--- gmid.h
+++ gmid.h
#define BUFLAYER_MAX 108
-struct buflayer
-{
+struct buflayer {
char data[BUFLAYER_MAX];
size_t len;
ssize_t read_pos;
struct client {
struct conf *conf;
- struct address *addr;
- int should_buffer;
- struct buflayer buf;
- uint32_t id;
+ struct address *addr;
+ int should_buffer;
+ struct buflayer buf;
+ uint32_t id;
struct tls *ctx;
char *req;
- size_t reqlen;
- struct iri iri;
- char domain[DOMAIN_NAME_LEN];
- char rhost[NI_MAXHOST];
- char rserv[NI_MAXSERV];
+ size_t reqlen;
+ struct iri iri;
+ char domain[DOMAIN_NAME_LEN];
+ char rhost[NI_MAXHOST];
+ char rserv[NI_MAXSERV];
struct bufferevent *bev;
blob - f3e34f3ad580b73b4818c9e57ffe2643ac5b5008
blob + 69f358ab46252a0749527eb12dc3766f69ba9575
--- server.c
+++ server.c
struct client *c = cb_arg;
if (!c->should_buffer) {
- // no buffer to cache into, read into libtls buffer
+ /* no buffer to cache into, read into libtls buffer */
errno = 0;
ssize_t ret = read(c->fd, buf, buflen);
if (ret == -1 && errno == EWOULDBLOCK)
}
if (c->buf.has_tail) {
- // we have leftover data from a previous call to read_cb
+ /* we have leftover data from a previous call to read_cb */
size_t left = BUFLAYER_MAX - c->buf.read_pos;
size_t copy_len = MINIMUM(buflen, left);
memcpy(buf, c->buf.data + c->buf.read_pos, copy_len);
c->buf.read_pos += copy_len;
if (left == copy_len) {
- // memset(buflayer, 0, BUFLAYER_MAX);
c->should_buffer = 0;
c->buf.has_tail = 0;
}
return copy_len;
}
- // buffer layer exists, we expect proxy protocol
+ /* buffer layer exists, we expect proxy protocol */
ssize_t n_read = read(
c->fd,
c->buf.data + c->buf.len,
log_debug("proxy-protocol v1: %s", protostr);
if (consumed < c->buf.len) {
- // we have some leftover
+ /* we have some leftover */
c->buf.read_pos = consumed;
c->buf.has_tail = 1;
} else {
- // we consumed the whole buffer
+ /* we consumed the whole buffer */
c->should_buffer = c->buf.read_pos = 0;
c->buf.has_tail = 0;
}
return TLS_WANT_POLLIN;
}
-static ssize_t write_cb(struct tls *ctx, const void *buf, size_t buflen, void *cb_arg)
+static ssize_t
+write_cb(struct tls *ctx, const void *buf, size_t buflen, void *cb_arg)
{
struct client *c = cb_arg;